From 9051e411d074a300686868724831f150e099c2c1 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 18 Dec 2023 12:00:41 +0100 Subject: [PATCH 01/20] FIX Multilangs : PDF lines description --- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/core/lib/pdf.lib.php | 26 ++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 2dbaeaf056e..536e7fb59e0 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1680,7 +1680,7 @@ class Propal extends CommonObject $this->lines = array(); // Lines - $result = $this->fetch_lines(); + $result = $this->fetch_lines(0, (!empty(getDolGlobalInt('MAIN_MULTILANGS')) ? 1 : 0)); if ($result < 0) { return -3; } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d6a22f64de5..d5da41777ab 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1410,12 +1410,28 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { global $db, $conf, $langs; + $multilangsactive = getDolGlobalInt('MAIN_MULTILANGS'); + + //id $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); - $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); - $desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); + //label + if(!empty($object->lines[$i]->label)){ + $label = $object->lines[$i]->label; + } else { + $label = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['label'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['label'] : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); + } + //description + if(!empty($object->lines[$i]->desc)){ + $desc = $object->lines[$i]->desc; + } else { + $desc = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['description'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['description'] : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); + } + //ref supplier $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders - $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''); - $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); + //note + $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''); + //dbatch + $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); if ($issupplierline) { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; @@ -1432,7 +1448,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if ($idprod) { $prodser->fetch($idprod); // If a predefined product and multilang and on other lang, we renamed label with label translated - if (getDolGlobalInt('MAIN_MULTILANGS') && ($outputlangs->defaultlang != $langs->defaultlang)) { + if ($multilangsactive && ($outputlangs->defaultlang != $langs->defaultlang)) { $translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) // TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation From ec19dcc8f85afab59a816a4bdba6103fa875e810 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 18 Dec 2023 13:34:50 +0100 Subject: [PATCH 02/20] Invoice --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7232137ae1c..faa54322c49 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2076,7 +2076,7 @@ class Facture extends CommonInvoice // Lines $this->lines = array(); - $result = $this->fetch_lines(); + $result = $this->fetch_lines(0, (!empty(getDolGlobalInt('MAIN_MULTILANGS')) ? 1 : 0)); if ($result < 0) { $this->error = $this->db->error(); return -3; From abc9eb7bdc21dff0608c12bd6ee0ec075c4d7251 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 18 Dec 2023 13:44:19 +0100 Subject: [PATCH 03/20] Clean Code --- htdocs/core/lib/pdf.lib.php | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d5da41777ab..cb242fdf1f4 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1410,28 +1410,27 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { global $db, $conf, $langs; - $multilangsactive = getDolGlobalInt('MAIN_MULTILANGS'); - - //id + $multilangsactive = getDolGlobalInt('MAIN_MULTILANGS'); + //id $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); - //label - if(!empty($object->lines[$i]->label)){ - $label = $object->lines[$i]->label; - } else { - $label = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['label'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['label'] : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); - } - //description - if(!empty($object->lines[$i]->desc)){ - $desc = $object->lines[$i]->desc; - } else { - $desc = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['description'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['description'] : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); - } - //ref supplier + //label + if (!empty($object->lines[$i]->label)) { + $label = $object->lines[$i]->label; + } else { + $label = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['label'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['label'] : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); + } + //description + if (!empty($object->lines[$i]->desc)) { + $desc = $object->lines[$i]->desc; + } else { + $desc = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['description'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['description'] : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); + } + //ref supplier $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders //note - $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''); + $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''); //dbatch - $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); + $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); if ($issupplierline) { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; From 4d32d93ee2c065e5db590bb64796939e8074d8d9 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 18 Dec 2023 17:28:41 +0100 Subject: [PATCH 04/20] Clean Travis --- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 536e7fb59e0..bdc3ee4d7f1 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1680,7 +1680,7 @@ class Propal extends CommonObject $this->lines = array(); // Lines - $result = $this->fetch_lines(0, (!empty(getDolGlobalInt('MAIN_MULTILANGS')) ? 1 : 0)); + $result = $this->fetch_lines(0, (getDolGlobalInt('MAIN_MULTILANGS') ? 1 : 0)); if ($result < 0) { return -3; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index faa54322c49..f3466a73eba 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2076,7 +2076,7 @@ class Facture extends CommonInvoice // Lines $this->lines = array(); - $result = $this->fetch_lines(0, (!empty(getDolGlobalInt('MAIN_MULTILANGS')) ? 1 : 0)); + $result = $this->fetch_lines(0, (getDolGlobalInt('MAIN_MULTILANGS') ? 1 : 0)); if ($result < 0) { $this->error = $this->db->error(); return -3; From 86971c7b863c1b891c30f901b5ed3751eeaa720d Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 22 Dec 2023 09:30:35 +0100 Subject: [PATCH 05/20] Clean Conditions --- htdocs/core/lib/pdf.lib.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index cb242fdf1f4..4b9fdb6e7c3 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1417,13 +1417,29 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($object->lines[$i]->label)) { $label = $object->lines[$i]->label; } else { - $label = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['label'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['label'] : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); + if (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['label']) && $multilangsactive) { + $label = $object->lines[$i]->multilangs[$langs->defaultlang]['label']; + } else { + if (!empty($object->lines[$i]->product_label)) { + $label = $object->lines[$i]->product_label; + } else { + $label = ''; + } + } } //description if (!empty($object->lines[$i]->desc)) { $desc = $object->lines[$i]->desc; } else { - $desc = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['description'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['description'] : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); + if (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['description']) && $multilangsactive) { + $desc = $object->lines[$i]->multilangs[$langs->defaultlang]['description']; + } else { + if (!empty($object->lines[$i]->description)) { + $desc = $object->lines[$i]->description; + } else { + $desc = ''; + } + } } //ref supplier $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders From e24da3242440e88a840accf45bd6c805a47001e7 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 16 Jan 2024 14:13:28 +0100 Subject: [PATCH 06/20] Load multilangs in function pdf_getlinedesc() --- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/core/lib/pdf.lib.php | 34 ++++++++++++------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index bdc3ee4d7f1..2dbaeaf056e 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1680,7 +1680,7 @@ class Propal extends CommonObject $this->lines = array(); // Lines - $result = $this->fetch_lines(0, (getDolGlobalInt('MAIN_MULTILANGS') ? 1 : 0)); + $result = $this->fetch_lines(); if ($result < 0) { return -3; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a4ba1d4896f..9d96dce5088 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2076,7 +2076,7 @@ class Facture extends CommonInvoice // Lines $this->lines = array(); - $result = $this->fetch_lines(0, (getDolGlobalInt('MAIN_MULTILANGS') ? 1 : 0)); + $result = $this->fetch_lines(); if ($result < 0) { $this->error = $this->db->error(); return -3; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 4b9fdb6e7c3..3cd9a055bac 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1411,8 +1411,29 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, global $db, $conf, $langs; $multilangsactive = getDolGlobalInt('MAIN_MULTILANGS'); + + if ($issupplierline) { + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $prodser = new ProductFournisseur($db); + } else { + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $prodser = new Product($db); + + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + } + } + //id $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); + if($idprod) { + $prodser->fetch($idprod); + //load multilangs + if($multilangsactive){ + $prodser->getMultiLangs(); + $object->lines[$i]->multilangs = $prodser->multilangs; + } + } //label if (!empty($object->lines[$i]->label)) { $label = $object->lines[$i]->label; @@ -1448,20 +1469,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, //dbatch $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); - if ($issupplierline) { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $prodser = new ProductFournisseur($db); - } else { - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $prodser = new Product($db); - - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - } - } - if ($idprod) { - $prodser->fetch($idprod); // If a predefined product and multilang and on other lang, we renamed label with label translated if ($multilangsactive && ($outputlangs->defaultlang != $langs->defaultlang)) { $translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) From 66a175e48d975e9239cf4874d9864fae6aee80b8 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 22 Jan 2024 14:52:51 +0100 Subject: [PATCH 07/20] langs of recipient --- htdocs/core/lib/pdf.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 3cd9a055bac..6dd5345be66 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1438,8 +1438,8 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($object->lines[$i]->label)) { $label = $object->lines[$i]->label; } else { - if (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['label']) && $multilangsactive) { - $label = $object->lines[$i]->multilangs[$langs->defaultlang]['label']; + if (!empty($object->lines[$i]->multilangs[$outputlangs->defaultlang]['label']) && $multilangsactive) { + $label = $object->lines[$i]->multilangs[$outputlangs->defaultlang]['label']; } else { if (!empty($object->lines[$i]->product_label)) { $label = $object->lines[$i]->product_label; @@ -1452,8 +1452,8 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($object->lines[$i]->desc)) { $desc = $object->lines[$i]->desc; } else { - if (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['description']) && $multilangsactive) { - $desc = $object->lines[$i]->multilangs[$langs->defaultlang]['description']; + if (!empty($object->lines[$i]->multilangs[$outputlangs->defaultlang]['description']) && $multilangsactive) { + $desc = $object->lines[$i]->multilangs[$outputlangs->defaultlang]['description']; } else { if (!empty($object->lines[$i]->description)) { $desc = $object->lines[$i]->description; From 77f982d1a8c3fa490c40c95e06d39f51731da055 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 10 Jan 2025 16:25:27 +0100 Subject: [PATCH 08/20] FIX 17.0 - collisions in cache for dol_getIdFromCode --- htdocs/core/lib/functions.lib.php | 49 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7fe94ff83c4..61bb1c78a2e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8876,12 +8876,13 @@ function dol_osencode($str) * @param string $fieldid Field to get * @param int $entityfilter Filter by entity * @param string $filters Filters to add. WARNING: string must be escaped for SQL and not coming from user input. + * @param bool $useCache If true (default), cache will be queried and updated. * @return int <0 if KO, Id of code if OK * @see $langs->getLabelFromKey */ -function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '') +function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '', $useCache = true) { - global $cache_codes; + static $cache_codes = array(); // If key empty if ($key == '') { @@ -8889,8 +8890,8 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = } // Check in cache - if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or '' - return $cache_codes[$tablename][$key][$fieldid]; // Found in cache + if ($useCache && isset($cache_codes[$tablename][$fieldkey][$fieldid][$entityfilter][$filters][$key])) { // Can be defined to 0 or '' + return $cache_codes[$tablename][$fieldkey][$fieldid][$entityfilter][$filters][$key]; // Found in cache } dol_syslog('dol_getIdFromCode (value for field '.$fieldid.' from key '.$key.' not found into cache)', LOG_DEBUG); @@ -8908,13 +8909,15 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); + $valuetoget = ''; if ($obj) { - $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget; - } else { - $cache_codes[$tablename][$key][$fieldid] = ''; + $valuetoget = $obj->valuetoget; } $db->free($resql); - return $cache_codes[$tablename][$key][$fieldid]; + if ($useCache) { + $cache_codes[$tablename][$fieldkey][$fieldid][$entityfilter][$filters][$key] = $valuetoget; + } + return $valuetoget; } else { return -1; } @@ -10839,21 +10842,21 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * @param int|boolean $userRight User action right * // phpcs:disable * @param array $params = [ // Various params for future : recommended rather than adding more function arguments - * 'attr' => [ // to add or override button attributes - * 'xxxxx' => '', // your xxxxx attribute you want - * 'class' => 'reposition', // to add more css class to the button class attribute - * 'classOverride' => '' // to replace class attribute of the button - * ], - * 'confirm' => [ - * 'url' => 'http://', // Overide Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm. - * 'title' => '', // Overide title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key - * 'action-btn-label' => '', // Overide label of action button, if empty default label use "Confirm" lang key - * 'cancel-btn-label' => '', // Overide label of cancel button, if empty default label use "CloseDialog" lang key - * 'content' => '', // Overide text of content, if empty default content use "ConfirmBtnCommonContent" lang key - * 'modal' => true, // true|false to display dialog as a modal (with dark background) - * 'isDropDrown' => false, // true|false to display dialog as a dropdown (with dark background) - * ], - * ] + * 'attr' => [ // to add or override button attributes + * 'xxxxx' => '', // your xxxxx attribute you want + * 'class' => 'reposition', // to add more css class to the button class attribute + * 'classOverride' => '' // to replace class attribute of the button + * ], + * 'confirm' => [ + * 'url' => 'http://', // Overide Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm. + * 'title' => '', // Overide title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key + * 'action-btn-label' => '', // Overide label of action button, if empty default label use "Confirm" lang key + * 'cancel-btn-label' => '', // Overide label of cancel button, if empty default label use "CloseDialog" lang key + * 'content' => '', // Overide text of content, if empty default content use "ConfirmBtnCommonContent" lang key + * 'modal' => true, // true|false to display dialog as a modal (with dark background) + * 'isDropDrown' => false, // true|false to display dialog as a dropdown (with dark background) + * ], + * ] * // phpcs:enable * @return string html button */ From 762e4ec8d1c720785a4f4adb309798acd7f12959 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 10 Jan 2025 17:01:59 +0100 Subject: [PATCH 09/20] updated local pre-commit hook -> fix typo --- htdocs/core/lib/functions.lib.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 61bb1c78a2e..610e19b293a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10848,11 +10848,11 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * 'classOverride' => '' // to replace class attribute of the button * ], * 'confirm' => [ - * 'url' => 'http://', // Overide Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm. - * 'title' => '', // Overide title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key - * 'action-btn-label' => '', // Overide label of action button, if empty default label use "Confirm" lang key - * 'cancel-btn-label' => '', // Overide label of cancel button, if empty default label use "CloseDialog" lang key - * 'content' => '', // Overide text of content, if empty default content use "ConfirmBtnCommonContent" lang key + * 'url' => 'http://', // Override Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm. + * 'title' => '', // Override title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key + * 'action-btn-label' => '', // Override label of action button, if empty default label use "Confirm" lang key + * 'cancel-btn-label' => '', // Override label of cancel button, if empty default label use "CloseDialog" lang key + * 'content' => '', // Override text of content, if empty default content use "ConfirmBtnCommonContent" lang key * 'modal' => true, // true|false to display dialog as a modal (with dark background) * 'isDropDrown' => false, // true|false to display dialog as a dropdown (with dark background) * ], From 79c55149b2ffc99b7f7178087bb305f77b736cd7 Mon Sep 17 00:00:00 2001 From: Florian Mortgat <50440633+atm-florianm@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:00:38 +0100 Subject: [PATCH 10/20] Update htdocs/core/lib/functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 610e19b293a..621b0987b08 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8882,7 +8882,7 @@ function dol_osencode($str) */ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '', $useCache = true) { - static $cache_codes = array(); + global $cache_codes; // If key empty if ($key == '') { From df992477be752c137e09a3ff9b5455292972c7fd Mon Sep 17 00:00:00 2001 From: atm-florian Date: Tue, 14 Jan 2025 14:34:09 +0100 Subject: [PATCH 11/20] Apply suggestion by @mdeweerd to ensure pre-commit will pass. --- .../DataCollector/PDO/TraceablePDO.php | 88 +++++++++++-------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/htdocs/includes/maximebf/debugbar/src/DebugBar/DataCollector/PDO/TraceablePDO.php b/htdocs/includes/maximebf/debugbar/src/DebugBar/DataCollector/PDO/TraceablePDO.php index e448a794ad3..753964a343c 100644 --- a/htdocs/includes/maximebf/debugbar/src/DebugBar/DataCollector/PDO/TraceablePDO.php +++ b/htdocs/includes/maximebf/debugbar/src/DebugBar/DataCollector/PDO/TraceablePDO.php @@ -23,13 +23,13 @@ class TraceablePDO extends PDO $this->pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, [TraceablePDOStatement::class, [$this]]); } - /** - * Initiates a transaction - * - * @link http://php.net/manual/en/pdo.begintransaction.php - * @return bool TRUE on success or FALSE on failure. - */ - public function beginTransaction() + /** + * Initiates a transaction + * + * @link http://php.net/manual/en/pdo.begintransaction.php + * @return bool TRUE on success or FALSE on failure. + */ + public function beginTransaction() : bool { return $this->pdo->beginTransaction(); } @@ -40,7 +40,7 @@ class TraceablePDO extends PDO * @link http://php.net/manual/en/pdo.commit.php * @return bool TRUE on success or FALSE on failure. */ - public function commit() + public function commit() : bool { return $this->pdo->commit(); } @@ -51,6 +51,7 @@ class TraceablePDO extends PDO * @link http://php.net/manual/en/pdo.errorinfo.php * @return array PDO::errorInfo returns an array of error information */ + #[\ReturnTypeWillChange] public function errorCode() { return $this->pdo->errorCode(); @@ -62,7 +63,7 @@ class TraceablePDO extends PDO * @link http://php.net/manual/en/pdo.errorinfo.php * @return array PDO::errorInfo returns an array of error information */ - public function errorInfo() + public function errorInfo() : array { return $this->pdo->errorInfo(); } @@ -77,6 +78,7 @@ class TraceablePDO extends PDO * return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. * Please read the section on Booleans for more information */ + #[\ReturnTypeWillChange] public function exec($statement) { return $this->profileCall('exec', $statement, func_get_args()); @@ -90,6 +92,7 @@ class TraceablePDO extends PDO * @return mixed A successful call returns the value of the requested PDO attribute. * An unsuccessful call returns null. */ + #[\ReturnTypeWillChange] public function getAttribute($attribute) { return $this->pdo->getAttribute($attribute); @@ -101,7 +104,7 @@ class TraceablePDO extends PDO * @link http://php.net/manual/en/pdo.intransaction.php * @return bool TRUE if a transaction is currently active, and FALSE if not. */ - public function inTransaction() + public function inTransaction() : bool { return $this->pdo->inTransaction(); } @@ -114,36 +117,41 @@ class TraceablePDO extends PDO * @return string If a sequence name was not specified for the name parameter, PDO::lastInsertId * returns a string representing the row ID of the last row that was inserted into the database. */ + #[\ReturnTypeWillChange] public function lastInsertId($name = null) { return $this->pdo->lastInsertId($name); } - /** - * Prepares a statement for execution and returns a statement object - * - * @link http://php.net/manual/en/pdo.prepare.php - * @param string $statement This must be a valid SQL statement template for the target DB server. - * @param array $driver_options [optional] This array holds one or more key=>value pairs to - * set attribute values for the PDOStatement object that this method returns. - * @return TraceablePDOStatement|bool If the database server successfully prepares the statement, - * PDO::prepare returns a PDOStatement object. If the database server cannot successfully prepare - * the statement, PDO::prepare returns FALSE or emits PDOException (depending on error handling). - */ + /** + * Prepares a statement for execution and returns a statement object + * + * @link http://php.net/manual/en/pdo.prepare.php + * @param string $statement This must be a valid SQL statement template for the target DB server. + * @param array $driver_options [optional] This array holds one or more key=>value pairs to + * set attribute values for the PDOStatement object that this method returns. + * @return TraceablePDOStatement|bool If the database server successfully prepares the statement, + * PDO::prepare returns a PDOStatement object. If the database server cannot successfully prepare + * the statement, PDO::prepare returns FALSE or emits PDOException (depending on error handling). + */ + #[\ReturnTypeWillChange] public function prepare($statement, $driver_options = []) { return $this->pdo->prepare($statement, $driver_options); } - /** - * Executes an SQL statement, returning a result set as a PDOStatement object - * - * @link http://php.net/manual/en/pdo.query.php - * @param string $statement - * @return TraceablePDOStatement|bool PDO::query returns a PDOStatement object, or FALSE on - * failure. - */ - public function query($statement) + /** + * Executes an SQL statement, returning a result set as a PDOStatement object + * + * @link http://php.net/manual/en/pdo.query.php + * @param string $statement + * @param int $fetchMode + * @param mixed ...$fetchModeArgs + * @return TraceablePDOStatement|bool PDO::query returns a PDOStatement object, or FALSE on + * failure. + */ + #[\ReturnTypeWillChange] + public function query($statement, $fetchMode = null, ...$fetchModeArgs) { return $this->profileCall('query', $statement, func_get_args()); } @@ -158,6 +166,7 @@ class TraceablePDO extends PDO * @return string|bool A quoted string that is theoretically safe to pass into an SQL statement. * Returns FALSE if the driver does not support quoting in this way. */ + #[\ReturnTypeWillChange] public function quote($string, $parameter_type = PDO::PARAM_STR) { return $this->pdo->quote($string, $parameter_type); @@ -169,7 +178,7 @@ class TraceablePDO extends PDO * @link http://php.net/manual/en/pdo.rollback.php * @return bool TRUE on success or FALSE on failure. */ - public function rollBack() + public function rollBack() : bool { return $this->pdo->rollBack(); } @@ -182,7 +191,7 @@ class TraceablePDO extends PDO * @param mixed $value * @return bool TRUE on success or FALSE on failure. */ - public function setAttribute($attribute, $value) + public function setAttribute($attribute, $value) : bool { return $this->pdo->setAttribute($attribute, $value); } @@ -195,6 +204,7 @@ class TraceablePDO extends PDO * @param array $args * @return mixed The result of the call */ + #[\ReturnTypeWillChange] protected function profileCall($method, $sql, array $args) { $trace = new TracedStatement($sql); @@ -226,7 +236,7 @@ class TraceablePDO extends PDO * * @param TracedStatement $stmt */ - public function addExecutedStatement(TracedStatement $stmt) + public function addExecutedStatement(TracedStatement $stmt) : void { $this->executedStatements[] = $stmt; } @@ -234,9 +244,9 @@ class TraceablePDO extends PDO /** * Returns the accumulated execution time of statements * - * @return int + * @return float */ - public function getAccumulatedStatementsDuration() + public function getAccumulatedStatementsDuration() : float { return array_reduce($this->executedStatements, function ($v, $s) { return $v + $s->getDuration(); }); } @@ -246,7 +256,7 @@ class TraceablePDO extends PDO * * @return int */ - public function getMemoryUsage() + public function getMemoryUsage() : int { return array_reduce($this->executedStatements, function ($v, $s) { return $v + $s->getMemoryUsage(); }); } @@ -256,7 +266,7 @@ class TraceablePDO extends PDO * * @return int */ - public function getPeakMemoryUsage() + public function getPeakMemoryUsage() : int { return array_reduce($this->executedStatements, function ($v, $s) { $m = $s->getEndMemory(); return $m > $v ? $m : $v; }); } @@ -266,7 +276,7 @@ class TraceablePDO extends PDO * * @return TracedStatement[] */ - public function getExecutedStatements() + public function getExecutedStatements() : array { return $this->executedStatements; } @@ -276,7 +286,7 @@ class TraceablePDO extends PDO * * @return TracedStatement[] */ - public function getFailedExecutedStatements() + public function getFailedExecutedStatements() : array { return array_filter($this->executedStatements, function ($s) { return !$s->isSuccess(); }); } From a34eaa07ed7a7491c82ddb92246c429487ccdf85 Mon Sep 17 00:00:00 2001 From: Irvine Fleith Date: Tue, 14 Jan 2025 16:19:52 +0100 Subject: [PATCH 12/20] fix(services-list): search thirdparty by name --- htdocs/contrat/services_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 21f49ebc789..7b75c4aa9d3 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -281,7 +281,7 @@ if ($filter == "notexpired") { $sql .= " AND cd.date_fin_validite >= '".$db->idate($now)."'"; } if ($search_name) { - $sql .= natural_search("c.ref", $search_name); + $sql .= natural_search("s.nom", $search_name); } if ($search_contract) { $sql .= natural_search("c.ref", $search_contract); From 748dcd088136882906f855de955e1d4a882721d5 Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Wed, 15 Jan 2025 10:12:16 +0100 Subject: [PATCH 13/20] FIX selectcontact is loading all contacts if socid is empty and MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT is not set --- htdocs/comm/action/card.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 0310ac0b225..681a977adb1 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1670,7 +1670,12 @@ if ($id > 0) { // related contact print ''.$langs->trans("ActionOnContact").''; print '
'; - print img_picto('', 'contact', 'class="paddingrightonly"').$form->selectcontacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid'); + if (getDolGlobalInt('MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT')) { + $select_contact_default = 0; // select "all" contacts by default : avoid to use it if there is a lot of contacts + } else { + $select_contact_default = -1; // select "none" by default + } + print img_picto('', 'contact', 'class="paddingrightonly"').$form->selectcontacts(!empty($object->socid) ? $object->socid : $select_contact_default, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid'); print '
'; print ''; print ''; From 628189f57f6ecdd89d27d29df65ee35d5a9fd627 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 00:49:59 +0200 Subject: [PATCH 14/20] Backport of #00e65eb Fix bad management when inserting contacts of actioncomm --- htdocs/comm/action/class/actioncomm.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 9b006c83ab6..9e1e471bbd3 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1203,11 +1203,14 @@ class ActionComm extends CommonObject if (!empty($this->socpeopleassigned)) { $already_inserted = array(); - foreach (array_keys($this->socpeopleassigned) as $id) { + foreach (array_keys($this->socpeopleassigned) as $key => $val) { + if (!is_array($val)) { // For backward compatibility when val=id + $val = array('id'=>$val); + } if (!empty($already_inserted[$val['id']])) continue; $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; + $sql .= " VALUES(".((int) $this->id).", 'socpeople', ".((int) $val['id']).", 0, 0, 0)"; $resql = $this->db->query($sql); if (!$resql) { From bd35af136098dc6a6881110ee07b284c4945b233 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 15 Jan 2025 20:07:31 +0100 Subject: [PATCH 15/20] Fix phpunit --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d6a22f64de5..44ff8a217c9 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -36,7 +36,7 @@ */ include_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; - + /** * Return array head with list of tabs to view object informations. From 8b7eaf360e58693a9365544cb1520f28ced7e626 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 15 Jan 2025 20:08:13 +0100 Subject: [PATCH 16/20] Fix phpunit --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 42fee8bfa7b..163fdefb2b0 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1426,7 +1426,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, //id $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); - if($idprod) { + if ($idprod) { $prodser->fetch($idprod); //load multilangs if($multilangsactive){ From c4529ed9869b59d4f34865e79dd5ad419a45c204 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 00:35:38 +0100 Subject: [PATCH 17/20] Clean file --- htdocs/core/lib/pdf.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 163fdefb2b0..c2078f2c74a 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -36,7 +36,7 @@ */ include_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; - + /** * Return array head with list of tabs to view object informations. @@ -1412,8 +1412,8 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $multilangsactive = getDolGlobalInt('MAIN_MULTILANGS'); - if ($issupplierline) { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + if ($issupplierline) { + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $prodser = new ProductFournisseur($db); } else { include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -1429,7 +1429,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if ($idprod) { $prodser->fetch($idprod); //load multilangs - if($multilangsactive){ + if ($multilangsactive) { $prodser->getMultiLangs(); $object->lines[$i]->multilangs = $prodser->multilangs; } From c2c3879032ac2fe80e397835b2d784168b0f5d57 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 00:36:56 +0100 Subject: [PATCH 18/20] Clean php file --- htdocs/core/lib/pdf.lib.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index c2078f2c74a..7bb8e4d8a1e 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1414,26 +1414,26 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if ($issupplierline) { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $prodser = new ProductFournisseur($db); - } else { - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $prodser = new Product($db); + $prodser = new ProductFournisseur($db); + } else { + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $prodser = new Product($db); - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - } - } + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + } + } //id $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); - if ($idprod) { - $prodser->fetch($idprod); - //load multilangs - if ($multilangsactive) { - $prodser->getMultiLangs(); - $object->lines[$i]->multilangs = $prodser->multilangs; - } - } + if ($idprod) { + $prodser->fetch($idprod); + //load multilangs + if ($multilangsactive) { + $prodser->getMultiLangs(); + $object->lines[$i]->multilangs = $prodser->multilangs; + } + } //label if (!empty($object->lines[$i]->label)) { $label = $object->lines[$i]->label; From ba4e97f07bb69031deefd9f5fffbb86869bcf609 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Thu, 16 Jan 2025 10:37:29 +0100 Subject: [PATCH 19/20] FIX 17.0 API endpoints "PUT": prevent overwriting all extrafields if only some are supplied in the request cf. PR #29237 + security for Tickets API: disable updating rowid --- htdocs/adherents/class/api_members.class.php | 6 ++++++ htdocs/adherents/class/api_memberstypes.class.php | 6 ++++++ htdocs/adherents/class/api_subscriptions.class.php | 6 ++++++ htdocs/bom/class/api_boms.class.php | 6 ++++++ htdocs/categories/class/api_categories.class.php | 6 ++++++ htdocs/comm/action/class/api_agendaevents.class.php | 6 ++++++ htdocs/comm/propal/class/api_proposals.class.php | 6 ++++++ htdocs/commande/class/api_orders.class.php | 6 ++++++ htdocs/compta/bank/class/api_bankaccounts.class.php | 6 ++++++ htdocs/compta/facture/class/api_invoices.class.php | 6 ++++++ htdocs/contrat/class/api_contracts.class.php | 6 ++++++ htdocs/don/class/api_donations.class.php | 6 ++++++ htdocs/expedition/class/api_shipments.class.php | 6 ++++++ htdocs/expensereport/class/api_expensereports.class.php | 6 ++++++ htdocs/fourn/class/api_supplier_invoices.class.php | 6 ++++++ htdocs/fourn/class/api_supplier_orders.class.php | 6 ++++++ .../class/api_knowledgemanagement.class.php | 6 ++++++ .../modulebuilder/template/class/api_mymodule.class.php | 6 ++++++ htdocs/mrp/class/api_mos.class.php | 6 ++++++ htdocs/partnership/class/api_partnership.class.php | 6 ++++++ htdocs/product/class/api_products.class.php | 6 ++++++ htdocs/product/stock/class/api_warehouses.class.php | 6 ++++++ htdocs/projet/class/api_projects.class.php | 6 ++++++ htdocs/projet/class/api_tasks.class.php | 6 ++++++ htdocs/reception/class/api_receptions.class.php | 6 ++++++ htdocs/societe/class/api_contacts.class.php | 6 ++++++ htdocs/societe/class/api_thirdparties.class.php | 6 ++++++ htdocs/ticket/class/api_tickets.class.php | 9 +++++++++ htdocs/user/class/api_users.class.php | 6 ++++++ 29 files changed, 177 insertions(+) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 4ecf79d9079..a224bbdda44 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -348,6 +348,12 @@ class Members extends DolibarrApi } } } else { + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $member->array_options[$index] = $this->_checkValForAPI($field, $val, $member); + } + continue; + } $member->$field = $value; } } diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 8179612d769..46443b7b063 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -193,6 +193,12 @@ class MembersTypes extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $membertype->array_options[$index] = $this->_checkValForAPI($field, $val, $membertype); + } + continue; + } // Process the status separately because it must be updated using // the validate(), resiliate() and exclude() methods of the class AdherentType. $membertype->$field = $value; diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index dfde21dc5a1..be97312280c 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -186,6 +186,12 @@ class Subscriptions extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $subscription->array_options[$index] = $this->_checkValForAPI($field, $val, $subscription); + } + continue; + } $subscription->$field = $value; } diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 57b0d26e80a..255934368a8 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -237,6 +237,12 @@ class Boms extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->bom->array_options[$index] = $this->_checkValForAPI($field, $val, $this->bom); + } + continue; + } $this->bom->$field = $value; } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 77356ba2a87..44aefd694ba 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -237,6 +237,12 @@ class Categories extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->category->array_options[$index] = $this->_checkValForAPI($field, $val, $this->category); + } + continue; + } $this->category->$field = $value; } diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 058de48542d..cfb933ed695 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -270,6 +270,12 @@ class AgendaEvents extends DolibarrApi continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->actioncomm->array_options[$index] = $this->_checkValForAPI($field, $val, $this->actioncomm); + } + continue; + } $this->actioncomm->$field = $this->_checkValForAPI($field, $value, $this->actioncomm); } diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index bbdc3cab71d..14ba90aef18 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -696,6 +696,12 @@ class Proposals extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->propal->array_options[$index] = $this->_checkValForAPI($field, $val, $this->propal); + } + continue; + } $this->propal->$field = $value; } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index af460b3b459..b1571052a2b 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -652,6 +652,12 @@ class Orders extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->commande->array_options[$index] = $this->_checkValForAPI($field, $val, $this->commande); + } + continue; + } $this->commande->$field = $value; } diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 052c45fbc56..1da37b2c760 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -332,6 +332,12 @@ class BankAccounts extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $account->array_options[$index] = $this->_checkValForAPI($field, $val, $account); + } + continue; + } $account->$field = $this->_checkValForAPI($field, $value, $account); } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 47fd0263d7e..4dfd1f023aa 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -627,6 +627,12 @@ class Invoices extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->invoice->array_options[$index] = $this->_checkValForAPI($field, $val, $this->invoice); + } + continue; + } $this->invoice->$field = $value; } diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 2becf6fcfb7..5bbdf7d1525 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -510,6 +510,12 @@ class Contracts extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->contract->array_options[$index] = $this->_checkValForAPI($field, $val, $this->contract); + } + continue; + } $this->contract->$field = $value; } diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index fee513f2ed7..472c5f8d4b2 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -231,6 +231,12 @@ class Donations extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->don->array_options[$index] = $this->_checkValForAPI($field, $val, $this->don); + } + continue; + } $this->don->$field = $value; } diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index fea57fbea10..23e1b1d0c84 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -447,6 +447,12 @@ class Shipments extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->shipment->array_options[$index] = $this->_checkValForAPI($field, $val, $this->shipment); + } + continue; + } $this->shipment->$field = $value; } diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index c3bfeb2264d..c985c5fe813 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -420,6 +420,12 @@ class ExpenseReports extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->expensereport->array_options[$index] = $this->_checkValForAPI($field, $val, $this->expensereport); + } + continue; + } $this->expensereport->$field = $value; } diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index cb7072fdca1..84568f2b13c 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -263,6 +263,12 @@ class SupplierInvoices extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->invoice->array_options[$index] = $this->_checkValForAPI($field, $val, $this->invoice); + } + continue; + } $this->invoice->$field = $value; } diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 4ad1f951883..b56c5195ee7 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -277,6 +277,12 @@ class SupplierOrders extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->order->array_options[$index] = $this->_checkValForAPI($field, $val, $this->order); + } + continue; + } $this->order->$field = $value; } diff --git a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php index 6d5c15c0dc6..7d777530166 100644 --- a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php +++ b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php @@ -298,6 +298,12 @@ class KnowledgeManagement extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->knowledgerecord->array_options[$index] = $this->_checkValForAPI($field, $val, $this->knowledgerecord); + } + continue; + } $this->knowledgerecord->$field = $this->_checkValForAPI($field, $value, $this->knowledgerecord); } diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index fdb56ff3c67..19bb4f50781 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -255,6 +255,12 @@ class MyModuleApi extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->myobject->array_options[$index] = $this->_checkValForAPI($field, $val, $this->myobject); + } + continue; + } $this->myobject->$field = $this->_checkValForAPI($field, $value, $this->myobject); } diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 2312f4bd636..c524d5533d6 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -238,6 +238,12 @@ class Mos extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->mo->array_options[$index] = $this->_checkValForAPI($field, $val, $this->mo); + } + continue; + } $this->mo->$field = $value; } diff --git a/htdocs/partnership/class/api_partnership.class.php b/htdocs/partnership/class/api_partnership.class.php index 13bc447c51d..f5cb7293081 100644 --- a/htdocs/partnership/class/api_partnership.class.php +++ b/htdocs/partnership/class/api_partnership.class.php @@ -255,6 +255,12 @@ class PartnershipApi extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->partnership->array_options[$index] = $this->_checkValForAPI($field, $val, $this->partnership); + } + continue; + } $this->partnership->$field = $this->_checkValForAPI($field, $value, $this->partnership); } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index e95db77d0cc..eeb8427596a 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -361,6 +361,12 @@ class Products extends DolibarrApi if ($field == 'stock_reel') { throw new RestException(400, 'Stock reel cannot be updated here. Use the /stockmovements endpoint instead'); } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->product->array_options[$index] = $this->_checkValForAPI($field, $val, $this->product); + } + continue; + } $this->product->$field = $value; } diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php index a0646598d96..f39a9fa88d8 100644 --- a/htdocs/product/stock/class/api_warehouses.class.php +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -206,6 +206,12 @@ class Warehouses extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->warehouse->array_options[$index] = $this->_checkValForAPI($field, $val, $this->warehouse); + } + continue; + } $this->warehouse->$field = $value; } diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index f5c23f4b040..9eed224e99a 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -462,6 +462,12 @@ class Projects extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->project->array_options[$index] = $this->_checkValForAPI($field, $val, $this->project); + } + continue; + } $this->project->$field = $value; } diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 80fede57563..bb65cfa31e5 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -460,6 +460,12 @@ class Tasks extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->task->array_options[$index] = $this->_checkValForAPI($field, $val, $this->task); + } + continue; + } $this->task->$field = $value; } diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php index 55e3fa59165..70088db3455 100644 --- a/htdocs/reception/class/api_receptions.class.php +++ b/htdocs/reception/class/api_receptions.class.php @@ -447,6 +447,12 @@ class Receptions extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->reception->array_options[$index] = $this->_checkValForAPI($field, $val, $this->reception); + } + continue; + } $this->reception->$field = $value; } diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index d8839c9a122..efbc1625ea0 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -330,6 +330,12 @@ class Contacts extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->contact->array_options[$index] = $this->_checkValForAPI($field, $val, $this->contact); + } + continue; + } $this->contact->$field = $value; } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index ef54c3a2299..f35521689da 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -301,6 +301,12 @@ class Thirdparties extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->company->array_options[$index] = $this->_checkValForAPI($field, $val, $this->company); + } + continue; + } $this->company->$field = $value; } diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index c27d9195683..d07687ff192 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -381,6 +381,15 @@ class Tickets extends DolibarrApi } foreach ($request_data as $field => $value) { + if ($field == 'id') { + continue; + } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->ticket->array_options[$index] = $this->_checkValForAPI($field, $val, $this->ticket); + } + continue; + } $this->ticket->$field = $value; } diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 781de4d23cd..fadcde59d53 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -406,6 +406,12 @@ class Users extends DolibarrApi throw new RestException(500, 'Error when updating status of user: '.$this->useraccount->error); } } else { + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->useraccount->array_options[$index] = $this->_checkValForAPI($field, $val, $this->useraccount); + } + continue; + } $this->useraccount->$field = $value; } } From 736890b244e3de3d6c397310cf339d8ced9604fe Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 20 Jan 2025 10:15:31 +0100 Subject: [PATCH 20/20] Merge --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 68d17fe99f6..cf1898daa07 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -619,7 +619,7 @@ class ActionComm extends CommonObject foreach ($this->userassigned as $key => $val) { // Common value with new behavior is to have $val = array('id'=>iduser, 'transparency'=>0|1) and $this->userassigned is an array of iduser => $val. if (!is_array($val)) { // For backward compatibility when $val='id'. - $val = array('id'=>$val); + $val = array('id' => $val); } if ($val['id'] > 0) {