From 5fad2c3a14c9e3014510f1934ffabaffeaec60c0 Mon Sep 17 00:00:00 2001 From: John BOTELLA <68917336+thersane-john@users.noreply.github.com> Date: Mon, 3 Mar 2025 10:15:25 +0100 Subject: [PATCH 01/10] Fix dolGetButton Tooltip --- 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 95f69e8e3fe..461b6b43c52 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12520,7 +12520,7 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = } // escape all attribute - $attr = array_map('dol_escape_htmltag', $attr); + $attr = array_map('dol_htmlentities', $attr); $TCompiledAttr = array(); foreach ($attr as $key => $value) { From ef97849883d88e24e9ee74d0b4b39c2fb05899f4 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 5 Mar 2025 10:50:44 +0100 Subject: [PATCH 02/10] fix: php warning Attempt to read property piece_num on null in accountancy/class/bookkeeping.class.php on line 373 --- htdocs/accountancy/class/bookkeeping.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 03fffa54ed4..b8d9604ae54 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -369,8 +369,13 @@ class BookKeeping extends CommonObject dol_syslog(get_class($this).":: create sqlnum=".$sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { - $objnum = $this->db->fetch_object($resqlnum); - $this->piece_num = $objnum->piece_num; + $num = $this->db->num_rows($resqlnum); + if ($num>0) { + $objnum = $this->db->fetch_object($resqlnum); + $this->piece_num = $objnum->piece_num; + } else { + $this->piece_num = ""; + } } dol_syslog(get_class($this)."::create this->piece_num=".$this->piece_num, LOG_DEBUG); From 4b640e4cad9311834515f0acc079d8557dcdf191 Mon Sep 17 00:00:00 2001 From: John BOTELLA <68917336+thersane-john@users.noreply.github.com> Date: Wed, 5 Mar 2025 13:29:47 +0100 Subject: [PATCH 03/10] Add params --- htdocs/core/lib/functions.lib.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 461b6b43c52..b610cc4decf 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12344,6 +12344,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * '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 + * 'use_unsecured_unescapedattr' => [] | bool // on true will use unsecured fonction to escape all attributes, if use array it will use unsecured fonction to escape attribute key present in this array * ], * 'confirm' => [ * '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. @@ -12519,8 +12520,22 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = unset($attr['href']); } - // escape all attribute - $attr = array_map('dol_htmlentities', $attr); + // Escape all attributes + if (!empty($params['use_unsecured_unescapedattr'])) { + if (is_array($params['use_unsecured_unescapedattr'])) { + foreach ($attr as $attrK => $attrV) { + if (in_array($attrK, $params['use_unsecured_unescapedattr'])) { + $attr[$attrK] = dol_htmlentities($attrV, ENT_QUOTES | ENT_SUBSTITUTE); + } else { + $attr[$attrK] = dolPrintHtmlForAttribute($attrV); + } + } + } else { + $attr = array_map('dol_htmlentities', $attr); + } + } else { + $attr = array_map('dolPrintHtmlForAttribute', $attr); + } $TCompiledAttr = array(); foreach ($attr as $key => $value) { From da8d69e1abbb919d54e56aa9723bf3ef02aac802 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Mar 2025 14:57:54 +0100 Subject: [PATCH 04/10] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b610cc4decf..6b804f62a19 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12521,20 +12521,20 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = } // Escape all attributes - if (!empty($params['use_unsecured_unescapedattr'])) { + if (!empty($params['use_unsecured_unescapedattr'])) { // Not recommended. if (is_array($params['use_unsecured_unescapedattr'])) { foreach ($attr as $attrK => $attrV) { if (in_array($attrK, $params['use_unsecured_unescapedattr'])) { $attr[$attrK] = dol_htmlentities($attrV, ENT_QUOTES | ENT_SUBSTITUTE); } else { - $attr[$attrK] = dolPrintHtmlForAttribute($attrV); + $attr[$attrK] = dolPrintHTMLForAttribute($attrV); } } } else { $attr = array_map('dol_htmlentities', $attr); } } else { - $attr = array_map('dolPrintHtmlForAttribute', $attr); + $attr = array_map('dolPrintHTMLForAttribute', $attr); } $TCompiledAttr = array(); From d1263c125602178fe72b19684f42db17cb158a47 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Mar 2025 15:34:04 +0100 Subject: [PATCH 05/10] Update bookkeeping.class.php --- htdocs/accountancy/class/bookkeeping.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index b8d9604ae54..ffb0a48e48b 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -374,7 +374,7 @@ class BookKeeping extends CommonObject $objnum = $this->db->fetch_object($resqlnum); $this->piece_num = $objnum->piece_num; } else { - $this->piece_num = ""; + $this->piece_num = 0; } } From 955083d6de3fdc2e98e3951cb1bb0cd151fc3f51 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Mar 2025 15:34:45 +0100 Subject: [PATCH 06/10] Update bookkeeping.class.php --- htdocs/accountancy/class/bookkeeping.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index ffb0a48e48b..f8a90cb0381 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -370,7 +370,7 @@ class BookKeeping extends CommonObject $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { $num = $this->db->num_rows($resqlnum); - if ($num>0) { + if ($num > 0) { $objnum = $this->db->fetch_object($resqlnum); $this->piece_num = $objnum->piece_num; } else { From 8f44b0a97415fa8d843756effaea35f4f9ab05d6 Mon Sep 17 00:00:00 2001 From: EnjoyFelix <100382087+EnjoyFelix@users.noreply.github.com> Date: Thu, 6 Mar 2025 13:37:37 +0100 Subject: [PATCH 07/10] # FIX The "AfterImportInsert" hook is not triggered during the simulation. #33260 (#33261) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * AfterImport hook in the simulation of the import * Update import.php * Update import.php * Update import.php --------- Co-authored-by: Elisée Chemin Co-authored-by: Laurent Destailleur --- htdocs/imports/import.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index b3159796514..90d9ef53f22 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1924,6 +1924,13 @@ if ($step == 5 && $datatoimport) { $nbok++; } } + + $reshook = $hookmanager->executeHooks('AfterImportInsert', $parameters); + if ($reshook < 0) { + $arrayoferrors[$sourcelinenb][] = [ + 'lib' => implode("
", array_merge([$hookmanager->error], $hookmanager->errors)) + ]; + } } // Close file $obj->import_close_file(); From 07177fab0a8a5931813cbc189f504a5d311fe8ce Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Fri, 7 Mar 2025 13:15:01 +0100 Subject: [PATCH 08/10] Fix join into implde --- htdocs/core/db/DoliDB.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 3a2346c2356..d415e3effa5 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -201,7 +201,7 @@ abstract class DoliDB implements Database $newstringarray[] = str_replace("'", "", $tmpchar); } } - $result = join(',', $newstringarray); + $result = implode(',', $newstringarray); } return $result; From a5125bdbd821325d62fd92e42ae52025bf683eed Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Fri, 7 Mar 2025 13:38:45 +0100 Subject: [PATCH 09/10] FIX Link to country setup on company setup page --- htdocs/admin/company.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 68856768f08..ca9f5a41b22 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -419,7 +419,7 @@ $formother = new FormOther($db); $formcompany = new FormCompany($db); $formfile = new FormFile($db); -$countrynotdefined = ''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = ''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup'); @@ -477,10 +477,10 @@ print '