From b54a15f5047ae977bf39ec959161aa6931c7763f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 15 Jan 2023 09:11:29 +0100 Subject: [PATCH 01/10] Fix missing keywords in dol_dir_list_in_database --- htdocs/core/lib/files.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 21c290b595d..4195dee8dc1 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -344,6 +344,7 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir) $filearray[$key]['position_name'] = ($filearrayindatabase[$key2]['position'] ? $filearrayindatabase[$key2]['position'] : '0').'_'.$filearrayindatabase[$key2]['name']; $filearray[$key]['position'] = $filearrayindatabase[$key2]['position']; $filearray[$key]['cover'] = $filearrayindatabase[$key2]['cover']; + $filearray[$key]['keywords'] = $filearrayindatabase[$key2]['keywords']; $filearray[$key]['acl'] = $filearrayindatabase[$key2]['acl']; $filearray[$key]['rowid'] = $filearrayindatabase[$key2]['rowid']; $filearray[$key]['label'] = $filearrayindatabase[$key2]['label']; From e5d4ea1b7cc6184bafa1aa0ccda8ee829af0f14d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 17 Jan 2023 18:30:06 +0100 Subject: [PATCH 02/10] FIX error with dol_banner_tab, ref is needed --- htdocs/contrat/agenda.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index d654ac38d9f..3e51e9a1de5 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -54,7 +54,11 @@ $ref = GETPOST('ref', 'alpha'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'contrat', $id, ''); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($id) ? 'rowid' : 'ref'); +$result = restrictedArea($user, 'contrat', $fieldvalue, '', '', '', $fieldtype); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -73,6 +77,13 @@ if (!$sortorder) { $sortorder = 'DESC,DESC'; } + +$object = new Contrat($db); + +if ($id > 0 || !empty($ref)) { + $result = $object->fetch($id, $ref); +} + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agendacontract', 'globalcard')); @@ -81,7 +92,7 @@ $hookmanager->initHooks(array('agendacontract', 'globalcard')); * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $id, 'ref' => $ref); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -102,8 +113,6 @@ if (empty($reshook)) { } - - /* * View */ @@ -114,7 +123,7 @@ if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } -if ($id > 0) { +if ($object->id > 0) { // Load object modContract $module = (!empty($conf->global->CONTRACT_ADDON) ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis'); if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') { @@ -128,8 +137,6 @@ if ($id > 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $object = new Contrat($db); - $result = $object->fetch($id); $object->fetch_thirdparty(); $title = $langs->trans("Agenda"); @@ -205,13 +212,13 @@ if ($id > 0) { } $morehtmlref .= ''; - dol_banner_tab($object, 'id', $linkback, 1, 'ref', 'none', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); print '
'; print '
'; - $object->info($id); + $object->info($object->id); dol_print_object_info($object, 1); print '
'; @@ -254,7 +261,7 @@ if ($id > 0) { if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { print '
'; - $param = '&id='.$id; + $param = '&id='.$object->id; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.$contextpage; } From 29966d8499b59a9f01562979c7f472f1ab1cd44a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Wed, 18 Jan 2023 09:29:11 +0100 Subject: [PATCH 03/10] FIX: Add missing token when deleting template inn order_supplier admin menu --- htdocs/admin/supplier_order.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 7cf64e4800d..5b7a9845c10 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -381,7 +381,7 @@ foreach ($dirmodels as $reldir) { if (in_array($name, $def)) { print ''."\n"; if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") { - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; } else { From d344e108c95d29e2d6d4101148ce9fae4f37baab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Wed, 18 Jan 2023 09:44:23 +0100 Subject: [PATCH 04/10] FIX: Errors Handling for CreateFrom Hooks --- htdocs/comm/action/class/actioncomm.class.php | 2 ++ htdocs/comm/propal/card.php | 1 + htdocs/comm/propal/class/propal.class.php | 2 ++ htdocs/commande/card.php | 1 + htdocs/commande/class/commande.class.php | 4 ++++ htdocs/compta/facture/class/facture.class.php | 4 ++++ htdocs/contrat/card.php | 1 + htdocs/contrat/class/contrat.class.php | 2 ++ htdocs/expensereport/class/expensereport.class.php | 2 ++ htdocs/fichinter/class/fichinter.class.php | 2 ++ htdocs/fourn/class/fournisseur.commande.class.php | 2 ++ htdocs/fourn/commande/card.php | 1 + htdocs/supplier_proposal/card.php | 1 + htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 ++ 14 files changed, 27 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 769bd9ddd50..8032ead20ba 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -708,6 +708,8 @@ class ActionComm extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index da4c756705f..ea2ab40db42 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -567,6 +567,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f36b8027461..6567e11cdbf 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1412,6 +1412,8 @@ class Propal extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index d394df997ff..b74114164b0 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -445,6 +445,7 @@ if (empty($reshook)) { // Note that $action and $object may be modified by hook $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 33de271b45d..bd3be625561 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1252,6 +1252,8 @@ class Commande extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1406,6 +1408,8 @@ class Commande extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 862a86e9e16..ba5eab04d16 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1299,6 +1299,8 @@ class Facture extends CommonInvoice $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1432,6 +1434,8 @@ class Facture extends CommonInvoice $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 624d59b0d94..2acf59593ff 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -341,6 +341,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 309df80605e..3d397fcb6c1 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2564,6 +2564,8 @@ class Contrat extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $clonedObj, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 3f62087dd0b..fa69245dc58 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -455,6 +455,8 @@ class ExpenseReport extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 000b654bf72..d8e213d31e8 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1211,6 +1211,8 @@ class Fichinter extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e78dd9dd02a..c5f700dd6a7 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1654,6 +1654,8 @@ class CommandeFournisseur extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 86e34ce39a1..f7e339c6c9a 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1314,6 +1314,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 4ad5fa9ff56..2f4dd6e0540 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -407,6 +407,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 78fc1c7fd15..dc18f7dcb2b 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1160,6 +1160,8 @@ class SupplierProposal extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } From 4ee0ede6d8e8205e9431da95463de6ef886312f6 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 18 Jan 2023 08:53:28 +0000 Subject: [PATCH 05/10] Fixing style errors. --- htdocs/comm/action/class/actioncomm.class.php | 4 ++-- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/class/propal.class.php | 4 ++-- htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 8 ++++---- htdocs/compta/facture/class/facture.class.php | 8 ++++---- htdocs/contrat/card.php | 2 +- htdocs/contrat/class/contrat.class.php | 4 ++-- htdocs/expensereport/class/expensereport.class.php | 4 ++-- htdocs/fichinter/class/fichinter.class.php | 4 ++-- htdocs/fourn/class/fournisseur.commande.class.php | 4 ++-- htdocs/fourn/commande/card.php | 2 +- htdocs/supplier_proposal/card.php | 2 +- .../supplier_proposal/class/supplier_proposal.class.php | 4 ++-- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 8032ead20ba..f5e1fe40b1f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -708,8 +708,8 @@ class ActionComm extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index ea2ab40db42..e575195799c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -567,7 +567,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6567e11cdbf..edd443c1b58 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1412,8 +1412,8 @@ class Propal extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b74114164b0..e099aafc9ca 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -445,7 +445,7 @@ if (empty($reshook)) { // Note that $action and $object may be modified by hook $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index bd3be625561..c636b4e905d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1252,8 +1252,8 @@ class Commande extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1408,8 +1408,8 @@ class Commande extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ba5eab04d16..2af2b35240d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1299,8 +1299,8 @@ class Facture extends CommonInvoice $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1434,8 +1434,8 @@ class Facture extends CommonInvoice $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 2acf59593ff..a63e8d7c6ca 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -341,7 +341,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 3d397fcb6c1..f16b26646bc 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2564,8 +2564,8 @@ class Contrat extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $clonedObj, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index fa69245dc58..a0fe9fa8335 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -455,8 +455,8 @@ class ExpenseReport extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index d8e213d31e8..0205fec9e39 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1211,8 +1211,8 @@ class Fichinter extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c5f700dd6a7..112708a92b7 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1654,8 +1654,8 @@ class CommandeFournisseur extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f7e339c6c9a..a8ee29fc974 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1314,7 +1314,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 2f4dd6e0540..01f9ad5e2dd 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -407,7 +407,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index dc18f7dcb2b..088594f6ab4 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1160,8 +1160,8 @@ class SupplierProposal extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } From cb963780312edca5445f075d516eecd6955856a7 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Wed, 18 Jan 2023 10:48:18 +0100 Subject: [PATCH 06/10] FIX: API access for deactivated users --- htdocs/api/class/api_access.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 5a4097b089b..09bb46ed98e 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2023 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -147,6 +148,9 @@ class DolibarrApiAccess implements iAuthenticate if ($result <= 0) { throw new RestException(503, 'Error when fetching user :'.$fuser->error.' (conf->entity='.$conf->entity.')'); } + if ($fuser->statut == 0) { + throw new RestException(503, 'Error when fetching user. This user has been locked or disabled'); + } $fuser->getrights(); From 6d8f80d46e778dc65b5edbad47d0e3ae69a95b18 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 18 Jan 2023 16:10:21 +0100 Subject: [PATCH 07/10] fix: module builder, backport workgin solution form 15.0 --- htdocs/modulebuilder/index.php | 50 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 25034194119..fcfea65dd83 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1295,33 +1295,35 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); } - } - if (!$error) { - $addfieldentry = array( - 'name'=>GETPOST('propname', 'aZ09'), - 'label'=>GETPOST('proplabel', 'alpha'), - 'type'=>GETPOST('proptype', 'alpha'), - 'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'restricthtml'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' - 'visible'=>GETPOST('propvisible', 'int'), - 'enabled'=>GETPOST('propenabled', 'int'), - 'position'=>GETPOST('propposition', 'int'), - 'notnull'=>GETPOST('propnotnull', 'int'), - 'index'=>GETPOST('propindex', 'int'), - 'searchall'=>GETPOST('propsearchall', 'int'), - 'isameasure'=>GETPOST('propisameasure', 'int'), - 'comment'=>GETPOST('propcomment', 'alpha'), - 'help'=>GETPOST('prophelp', 'alpha'), - 'css'=>GETPOST('propcss', 'aZ09'), - 'cssview'=>GETPOST('propcssview', 'aZ09'), - 'csslist'=>GETPOST('propcsslist', 'aZ09'), - 'default'=>GETPOST('propdefault', 'restricthtml'), - 'noteditable'=>intval(GETPOST('propnoteditable', 'int')), - ); + if (!$error && !GETPOST('regenerateclasssql')&& !GETPOST('regeneratemissing')) { + $addfieldentry = array( + 'name'=>GETPOST('propname', 'aZ09'), + 'label'=>GETPOST('proplabel', 'alpha'), + 'type'=>GETPOST('proptype', 'alpha'), + 'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'restricthtml'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' + 'visible'=>GETPOST('propvisible', 'int'), + 'enabled'=>GETPOST('propenabled', 'int'), + 'position'=>GETPOST('propposition', 'int'), + 'notnull'=>GETPOST('propnotnull', 'int'), + 'index'=>GETPOST('propindex', 'int'), + 'searchall'=>GETPOST('propsearchall', 'int'), + 'isameasure'=>GETPOST('propisameasure', 'int'), + 'comment'=>GETPOST('propcomment', 'alpha'), + 'help'=>GETPOST('prophelp', 'alpha'), + 'css'=>GETPOST('propcss', 'aZ09'), + 'cssview'=>GETPOST('propcssview', 'aZ09'), + 'csslist'=>GETPOST('propcsslist', 'aZ09'), + 'default'=>GETPOST('propdefault', 'restricthtml'), + 'noteditable'=>intval(GETPOST('propnoteditable', 'int')), + ); - if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { - $addfieldentry['arrayofkeyval'] = json_decode($addfieldentry['arrayofkeyval'], true); + if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { + $addfieldentry['arrayofkeyval'] = json_decode($addfieldentry['arrayofkeyval'], true); + } } + } else { + $addfieldentry = array(); } /*if (GETPOST('regeneratemissing')) From a00fa5a192dd339c8ca49e7f489ce4ecb31a5feb Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Wed, 18 Jan 2023 16:11:22 +0100 Subject: [PATCH 08/10] FIX: Do not convert negative line to discount if variable is active --- htdocs/commande/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index eb8b824ef3e..2211422f3c5 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -9,7 +9,7 @@ * Copyright (C) 2015-2018 Frédéric France * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016-2021 Ferran Marcet + * Copyright (C) 2016-2023 Ferran Marcet * Copyright (C) 2018 Charlene Benke * Copyright (C) 2021 Anthony Berton * @@ -403,7 +403,7 @@ if (empty($reshook)) { $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); } - if ($lines[$i]->subprice < 0) { + if ($lines[$i]->subprice < 0 && empty($conf->global->INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN)) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); $discount->fk_soc = $objecttmp->socid; From a3d4eb404df858202eeacf5f872d6fc3d7b1cd3d Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 18 Jan 2023 17:36:05 +0100 Subject: [PATCH 09/10] Fix contact firstname lastname extrafields --- htdocs/core/class/extrafields.class.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 1d5bd8dc7ef..6644548d87c 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1457,15 +1457,15 @@ class ExtraFields $labeltoshow = dol_trunc($labeltoshow, 45); if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { + $labeltoshow = ''; foreach ($fields_label as $field_toshow) { $translabel = $langs->trans($obj->$field_toshow); if ($translabel != $obj->$field_toshow) { - $labeltoshow = dol_trunc($translabel, 18).' '; + $labeltoshow .= ' '.dol_trunc($translabel, 18).' '; } else { - $labeltoshow = dol_trunc($obj->$field_toshow, 18).' '; + $labeltoshow .= ' '.dol_trunc($obj->$field_toshow, 18).' '; } } - $data[$obj->rowid] = $labeltoshow; } else { if (!$notrans) { @@ -1774,17 +1774,20 @@ class ExtraFields $fields_label = explode('|', $InfoFieldList[1]); if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { if (is_array($fields_label) && count($fields_label) > 1) { + $label = '
  • '; foreach ($fields_label as $field_toshow) { $translabel = ''; if (!empty($obj->$field_toshow)) { $translabel = $langs->trans($obj->$field_toshow); } if ($translabel != $field_toshow) { - $toprint[] = '
  • '.dol_trunc($translabel, 18).'
  • '; + $label .= ' '.dol_trunc($translabel, 18); } else { - $toprint[] = '
  • '.$obj->$field_toshow.'
  • '; + $label .= ' '.$obj->$field_toshow; } } + $label .= ''; + $toprint[] = $label; } else { $translabel = ''; if (!empty($obj->{$InfoFieldList[1]})) { From aa273d215572d896ba26f1dae8489edd1238e4c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 18 Jan 2023 20:11:12 +0100 Subject: [PATCH 10/10] Update index.php --- htdocs/modulebuilder/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index fcfea65dd83..052b1189b3d 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1296,7 +1296,7 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); } - if (!$error && !GETPOST('regenerateclasssql')&& !GETPOST('regeneratemissing')) { + if (!$error && !GETPOST('regenerateclasssql') && !GETPOST('regeneratemissing')) { $addfieldentry = array( 'name'=>GETPOST('propname', 'aZ09'), 'label'=>GETPOST('proplabel', 'alpha'),