From 9051e411d074a300686868724831f150e099c2c1 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 18 Dec 2023 12:00:41 +0100 Subject: [PATCH 001/110] 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 002/110] 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 003/110] 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 004/110] 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 005/110] 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 006/110] 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 007/110] 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 0be0c1a1c15bf072bf2199cddf5a634db78825c7 Mon Sep 17 00:00:00 2001 From: mrozniecki Date: Tue, 10 Sep 2024 14:01:04 +0200 Subject: [PATCH 008/110] Backport #yogosha18281 --- htdocs/core/class/translate.class.php | 12 ++++++++++-- htdocs/core/js/lib_head.js.php | 2 +- htdocs/core/lib/functions.lib.php | 11 +++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 4b538021da4..4a5cd7e493a 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -580,7 +580,7 @@ class Translate */ private function getTradFromKey($key) { - global $conf, $db; + global $db; if (!is_string($key)) { //xdebug_print_function_stack('ErrorBadValueForParamNotAString'); @@ -660,7 +660,7 @@ class Translate } } - // Crypt string into HTML + // Encode string into HTML $str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are embraced by "). Use dol_escape_htmltag around text in HTML content // Restore reliable HTML tags into original translation string @@ -670,6 +670,10 @@ class Translate $str ); + // Remove dangerous sequence we should never have. Not needed into a translated response. + // %27 is entity code for ' and is replaced by browser automatically when translation is inside a javascript code called by a click like on a href link. + $str = str_replace(array('%27', '''), '', $str); + if ($maxsize) { $str = dol_trunc($str, $maxsize); } @@ -739,6 +743,10 @@ class Translate $str = sprintf($str, $param1, $param2, $param3, $param4, $param5); // Replace %s and %d except for FormatXXX strings. } + // Remove dangerous sequence we should never have. Not needed into a translated response. + // %27 is entity code for ' and is replaced by browser automatically when translation is inside a javascript code called by a click like on a href link. + $str = str_replace(array('%27', '''), '', $str); + return $str; } else { /*if ($key[0] == '$') { diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index c33cb7eb748..33f8526b000 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -996,7 +996,7 @@ function document_preview(file, type, title) var ValidImageTypes = ["image/gif", "image/jpeg", "image/png", "image/webp"]; var showOriginalSizeButton = false; - console.log("document_preview A click was done. file="+file+", type="+type+", title="+title); + console.log("document_preview A click was done: file="+file+", type="+type+", title="+title); if ($.inArray(type, ValidImageTypes) < 0) { /* Not an image */ diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 785889eab78..f3bbbc682c0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10349,7 +10349,7 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param if ($alldata == 1) { if ($isAllowedForPreview) { - return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : ''), 'mime'=>dol_mimetype($relativepath)); + return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.urlencode($modulepart).'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : ''), 'mime'=>dol_mimetype($relativepath)); } else { return array(); } @@ -10357,7 +10357,14 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param // old behavior, return a string if ($isAllowedForPreview) { - return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : '')).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')'; + $tmpurl = DOL_URL_ROOT.'/document.php?modulepart='.urlencode($modulepart).'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : ''); + $title = $langs->trans("Preview"); + //$title = '%27-alert(document.domain)-%27'; + //$tmpurl = 'file='.urlencode("'-alert(document.domain)-'_small.jpg"); + + // We need to urlencode the parameter after the dol_escape_js($tmpurl) because $tmpurl may contain n url with param file=abc%27def if file has a ' inside. + // and when we click on href with this javascript string, a urlcode is done by browser, converted the %27 of file param + return 'javascript:document_preview(\''.urlencode(dol_escape_js($tmpurl)).'\', \''.urlencode(dol_mimetype($relativepath)).'\', \''.urlencode(dol_escape_js($title)).'\')'; } else { return ''; } From 1ee3c5e5a078f090f314e5731dd7efd930082e43 Mon Sep 17 00:00:00 2001 From: mrozniecki Date: Fri, 13 Sep 2024 12:08:58 +0200 Subject: [PATCH 009/110] Backport fix title --- 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 f3bbbc682c0..12cacbb1549 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10358,7 +10358,7 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param // old behavior, return a string if ($isAllowedForPreview) { $tmpurl = DOL_URL_ROOT.'/document.php?modulepart='.urlencode($modulepart).'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : ''); - $title = $langs->trans("Preview"); + $title = $langs->transnoentities("Preview"); //$title = '%27-alert(document.domain)-%27'; //$tmpurl = 'file='.urlencode("'-alert(document.domain)-'_small.jpg"); From bad8ee865d1b78eeda7960388350921b0c4afe2c Mon Sep 17 00:00:00 2001 From: mrozniecki Date: Fri, 20 Sep 2024 14:34:34 +0200 Subject: [PATCH 010/110] Fix title encode --- 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 12cacbb1549..a0dfce0b0e0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10364,7 +10364,7 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param // We need to urlencode the parameter after the dol_escape_js($tmpurl) because $tmpurl may contain n url with param file=abc%27def if file has a ' inside. // and when we click on href with this javascript string, a urlcode is done by browser, converted the %27 of file param - return 'javascript:document_preview(\''.urlencode(dol_escape_js($tmpurl)).'\', \''.urlencode(dol_mimetype($relativepath)).'\', \''.urlencode(dol_escape_js($title)).'\')'; + return 'javascript:document_preview(\''.urlencode(dol_escape_js($tmpurl)).'\', \''.urlencode(dol_mimetype($relativepath)).'\', \''.rawurlencode(dol_escape_js($title)).'\')'; } else { return ''; } From 87c16498ca4d93db7ed69f9738182f7b88c33070 Mon Sep 17 00:00:00 2001 From: Kamel Khelifa Date: Fri, 18 Oct 2024 14:26:04 +0200 Subject: [PATCH 011/110] FIX: Fix return value of hook sendMail when hook return -1 who must be return false in sendfile() function --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index db8b30ed249..34b7c2757e5 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -687,7 +687,7 @@ class CMailFile $this->error = "Error in hook maildao sendMail ".$reshook; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - return $reshook; + return false; } if ($reshook == 1) { // Hook replace standard code return true; From 115323dec8e079da7768549da0189ed1e9b5d24c Mon Sep 17 00:00:00 2001 From: alkaan Date: Wed, 20 Nov 2024 20:57:22 +0100 Subject: [PATCH 012/110] FIX : removes traces of << --- htdocs/core/class/commonobject.class.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5333a0b6f17..b81688307b9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2156,12 +2156,7 @@ abstract class CommonObject if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) { $sql .= " AND te.entity IS NOT NULL"; // Show all users } else { -<<<<<<< HEAD - $sql .= " AND ug.fk_user = te.rowid"; - $sql .= " AND ug.entity IN (".getEntity('usergroup').")"; -======= $sql .= " AND ug.entity IN (".getEntity($this->element).")"; ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git } } else { $sql .= ' AND te.entity IN ('.getEntity($this->element).')'; From 3aad5fd28328ceb7b61ef51b1b436f269a9baa4a Mon Sep 17 00:00:00 2001 From: Irvine Fleith Date: Thu, 5 Dec 2024 09:02:51 +0100 Subject: [PATCH 013/110] Added new error message for CRON createRecurringInvoice --- htdocs/compta/facture/class/facture-rec.class.php | 1 + htdocs/langs/en_US/bills.lang | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 5b377edaee4..228badc04dc 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1395,6 +1395,7 @@ class FactureRec extends CommonInvoice $nb_create++; $this->output .= $langs->trans("InvoiceGeneratedFromTemplate", $facture->ref, $facturerec->ref)."\n"; } else { + $this->output .= $langs->trans("InvoiceGeneratedFromTemplateError", $facture->ref, $facturerec->ref, $this->error)."\n"; $this->db->rollback("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); } diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 7da96d61576..9af37bc3335 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -404,6 +404,7 @@ InvoiceAutoValidate=Validate invoices automatically GeneratedFromRecurringInvoice=Generated from template recurring invoice %s DateIsNotEnough=Date not reached yet InvoiceGeneratedFromTemplate=Invoice %s generated from recurring template invoice %s +InvoiceGeneratedFromTemplateError=Error Invoice %s generated from recurring template invoice %s : %s GeneratedFromTemplate=Generated from template invoice %s WarningInvoiceDateInFuture=Warning, the invoice date is higher than current date WarningInvoiceDateTooFarInFuture=Warning, the invoice date is too far from current date From c418a6ff576f3fdd7a8a2daf7eeb01a71ee8d1e7 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Thu, 5 Dec 2024 12:14:13 +0100 Subject: [PATCH 014/110] FIX 17.0 - missing error handling for FactureRec::fetch in card-rec.php --- htdocs/compta/facture/card-rec.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index ee260dc076f..93c70bb802d 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -91,7 +91,10 @@ $pagenext = $page + 1; $object = new FactureRec($db); if (($id > 0 || $ref) && $action != 'create' && $action != 'add') { $ret = $object->fetch($id, $ref); - if (!$ret) { + if ($ret < 0) { + dol_print_error($db, $object->error, $object->errors); + exit; + } elseif (! $ret) { setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors'); } } @@ -1300,11 +1303,11 @@ if ($action == 'create') { print ''; print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE) { - if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); - } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'none'); - } + if ($action == 'editconditions') { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); + } else { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'none'); + } } else { print ' '; } From 15c19b99c94a6da7650434f1f64766c946819b95 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Thu, 5 Dec 2024 12:15:20 +0100 Subject: [PATCH 015/110] FIX 17.0: warnings due to uninitialized variables + delete code that doesn't apply to recurring invoices (AFAIK, there is no recurring credit note feature) --- htdocs/compta/facture/card-rec.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 93c70bb802d..3d26894f231 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1178,6 +1178,7 @@ if ($action == 'create') { if ($object->id > 0) { $object->fetch_thirdparty(); + $formconfirm = ''; // Confirmation de la suppression d'une ligne produit if ($action == 'ask_deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); @@ -1302,15 +1303,11 @@ if ($action == 'create') { } print ''; print ''; - if ($object->type != Facture::TYPE_CREDIT_NOTE) { if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'none'); } - } else { - print ' '; - } print ''; // Payment mode @@ -1732,6 +1729,7 @@ if ($action == 'create') { // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); + $morehtmlcenter = ''; $somethingshown = $formactions->showactions($object, $object->element, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); print ''; From 2c4b3bf6ad32d77658be1a30e698d62b2360d372 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 12:52:44 +0100 Subject: [PATCH 016/110] Test --- .../changed-lines-count-labeler.yml | 3 +++ .github/workflows/pr-18-autolabel.yaml | 20 +++++++++++++++++++ .github/workflows/pr-18.yaml | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/changed-lines-count-labeler.yml create mode 100644 .github/workflows/pr-18-autolabel.yaml diff --git a/.github/workflows/changed-lines-count-labeler.yml b/.github/workflows/changed-lines-count-labeler.yml new file mode 100644 index 00000000000..39e663821fb --- /dev/null +++ b/.github/workflows/changed-lines-count-labeler.yml @@ -0,0 +1,3 @@ +# Add this tag for any changes for more than 1 line +"Pending analysis of PR (maintenance team)": + min: 1 diff --git a/.github/workflows/pr-18-autolabel.yaml b/.github/workflows/pr-18-autolabel.yaml new file mode 100644 index 00000000000..4524d02815b --- /dev/null +++ b/.github/workflows/pr-18-autolabel.yaml @@ -0,0 +1,20 @@ +name: "Set label for v18" +on: + pull_request: + types: [opened, synchronize, reopened] + branches: + - "18.0" + push: + branches: + - "18.0" + +jobs: + changed-lines-count-labeler: + runs-on: ubuntu-latest + name: An action for automatically labelling pull requests based on the changed lines count + steps: + - name: Set a label + uses: vkirilichev/changed-lines-count-labeler@v0.2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + configuration-path: .github/changed-lines-count-labeler.yml diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index 2682e99df38..be36aa8b246 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -7,7 +7,7 @@ on: branches: - "18.0" -permissions: write-all +#permissions: write-all jobs: run: From d3d534efeef6f599cdc87a44b9ee375351fd2c87 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 12:54:25 +0100 Subject: [PATCH 017/110] Test --- .github/workflows/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index cf263dd0b57..062de38b3a3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -13,6 +13,7 @@ jobs: steps: - name: Log run: | + echo "repo-token: ${{ secrets.GITHUB_TOKEN }}" echo "variable org: ${{vars.AAA}}" echo "env prg: ${{env.AAA}}" echo "secret org: ${{secrets.BBB}}" From a0864dfb3fcdeb11c175bb5d1959532af40c5406 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 13:05:24 +0100 Subject: [PATCH 018/110] Fix test --- .github/{workflows => }/changed-lines-count-labeler.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflows => }/changed-lines-count-labeler.yml (100%) diff --git a/.github/workflows/changed-lines-count-labeler.yml b/.github/changed-lines-count-labeler.yml similarity index 100% rename from .github/workflows/changed-lines-count-labeler.yml rename to .github/changed-lines-count-labeler.yml From 4bb2b9f97115a10cc32bfffebbd7d8575f2e0569 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 13:51:23 +0100 Subject: [PATCH 019/110] Test --- .github/workflows/pr-18.yaml | 8 ++++++-- .github/workflows/test.yaml | 38 +++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index be36aa8b246..8a4c916809f 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -10,12 +10,15 @@ on: #permissions: write-all jobs: - run: + pr18: + permissions: + issues: write + pull-requests: write runs-on: ubuntu-latest env: - # GH_TOKEN: ${{ secrets.GH_TOKEN }} GH_TOKEN: ${{ github.token }} + GH_TOKENS: ${{ secrets.GH_TOKEN }} steps: - name: Checkout repository @@ -37,6 +40,7 @@ jobs: REVIEWER: "rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer run: | echo "GH_TOKEN=$GH_TOKEN" + echo "GH_TOKENS=$GH_TOKENS" pr_number=$(jq --raw-output .number < $GITHUB_EVENT_PATH) gh pr edit $pr_number --add-reviewer "$REVIEWER" continue-on-error: true diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 062de38b3a3..a70171db729 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,12 +9,48 @@ permissions: write-all jobs: testjob: + permissions: + issues: write + pull-requests: write runs-on: ubuntu-latest + env: + ENVGHT: ${{ secrets.GH_TOKEN }} + ENVGHU: ${{ github.token }} + VARAAA: ${{ vars.AAA }} + ENVAAA: ${{ env.AAA }} + SECBBB: ${{ secrets.BBB }} + VARREPORGCCC: ${{ vars.CCC }} steps: - name: Log run: | - echo "repo-token: ${{ secrets.GITHUB_TOKEN }}" + echo "repo-token: ${{secrets.GITHUB_TOKEN}}" echo "variable org: ${{vars.AAA}}" echo "env prg: ${{env.AAA}}" echo "secret org: ${{secrets.BBB}}" echo "variable repository of orga: ${{vars.CCC}}" + echo "ENVGHT: ${{ENVGHT}}" + echo "ENVGHT: $ENVGHT" + echo "ENVGHU: ${{ENVGHU}}" + echo "ENVGHU: $ENVGHU" + echo "VARAAA: ${{VARAAA}}" + echo "VARAAA: $VARAAA" + echo "ENVAAA: ${{VARAAA}}" + echo "ENVAAA: $VARAAA" + echo "VARREPORGCCC: ${{VARREPORGCCC}}" + echo "VARREPORGCCC: $VARREPORGCCC" + echo "ENVGHTWITH: ${{ENVGHTWITH}}" + echo "ENVGHT: $ENVGHTWITH" + echo "ENVGHUWITH: ${{ENVGHUWITH}}" + echo "ENVGHU: $ENVGHUWITH" + echo "VARAAAWITH: ${{VARAAAWITH}}" + echo "VARAAAWITH: $VARAAAWITH" + echo "SECBBBWITH: ${{SECBBBWITH}}" + echo "SECBBBWITH: $SECBBBWITH" + with: + ENVGHW: $GH_TOKEN + ENVGHTWITH: $ENVGHT + ENVGHUWITH: $ENVGHU + VARAAAWITH: $VARAAA + SECBBBWITH: $SECBBB + VARREPORGCCCWITH: $VARREPORGCCC + From da6f1fbc9aa91b62ba5b411f3d32cfe0ab1fa34f Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 14:04:10 +0100 Subject: [PATCH 020/110] Test --- .github/workflows/test.yaml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a70171db729..2ac953064f9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,19 +7,20 @@ on: permissions: write-all +env: + ENVGHT: ${{ secrets.GH_TOKEN }} + ENVGHU: ${{ github.token }} + VARAAA: ${{ vars.AAA }} + ENVAAA: ${{ env.AAA }} + SECBBB: ${{ secrets.BBB }} + VARREPORGCCC: ${{ vars.CCC }} + jobs: testjob: permissions: issues: write pull-requests: write runs-on: ubuntu-latest - env: - ENVGHT: ${{ secrets.GH_TOKEN }} - ENVGHU: ${{ github.token }} - VARAAA: ${{ vars.AAA }} - ENVAAA: ${{ env.AAA }} - SECBBB: ${{ secrets.BBB }} - VARREPORGCCC: ${{ vars.CCC }} steps: - name: Log run: | From d9035eecdab96f893d83240c96a3a9d97dcec2fd Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 14:04:10 +0100 Subject: [PATCH 021/110] Test --- .github/workflows/test.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a70171db729..bf06e4fe065 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,19 +7,19 @@ on: permissions: write-all +env: + ENVGHT: ${{ secrets.GH_TOKEN }} + ENVGHU: ${{ github.token }} + VARAAA: ${{ vars.AAA }} + SECBBB: ${{ secrets.BBB }} + VARREPORGCCC: ${{ vars.CCC }} + jobs: testjob: permissions: issues: write pull-requests: write runs-on: ubuntu-latest - env: - ENVGHT: ${{ secrets.GH_TOKEN }} - ENVGHU: ${{ github.token }} - VARAAA: ${{ vars.AAA }} - ENVAAA: ${{ env.AAA }} - SECBBB: ${{ secrets.BBB }} - VARREPORGCCC: ${{ vars.CCC }} steps: - name: Log run: | From 6f2d8b23b43ebd71fefecc85c7cdf4306678dbf0 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 14:09:47 +0100 Subject: [PATCH 022/110] Test --- .github/workflows/test.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index bf06e4fe065..414f0f1e035 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -46,11 +46,11 @@ jobs: echo "VARAAAWITH: $VARAAAWITH" echo "SECBBBWITH: ${{SECBBBWITH}}" echo "SECBBBWITH: $SECBBBWITH" - with: - ENVGHW: $GH_TOKEN - ENVGHTWITH: $ENVGHT - ENVGHUWITH: $ENVGHU - VARAAAWITH: $VARAAA - SECBBBWITH: $SECBBB - VARREPORGCCCWITH: $VARREPORGCCC +# with: +# ENVGHW: $GH_TOKEN +# ENVGHTWITH: $ENVGHT +# ENVGHUWITH: $ENVGHU +# VARAAAWITH: $VARAAA +# SECBBBWITH: $SECBBB +# VARREPORGCCCWITH: $VARREPORGCCC From 3877f257b4f561ed138af7e4056b7f207b40c595 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 14:13:13 +0100 Subject: [PATCH 023/110] Test --- .github/workflows/test.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 414f0f1e035..96356ebb387 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -26,10 +26,11 @@ jobs: echo "repo-token: ${{secrets.GITHUB_TOKEN}}" echo "variable org: ${{vars.AAA}}" echo "env prg: ${{env.AAA}}" + echo "env prg: ${{env.VARAAA}}" echo "secret org: ${{secrets.BBB}}" echo "variable repository of orga: ${{vars.CCC}}" - echo "ENVGHT: ${{ENVGHT}}" - echo "ENVGHT: $ENVGHT" + #echo "ENVGHT: ${{ENVGHT}}" + #echo "ENVGHT: $ENVGHT" echo "ENVGHU: ${{ENVGHU}}" echo "ENVGHU: $ENVGHU" echo "VARAAA: ${{VARAAA}}" From 75e504ffbcd5dc7806a3153eee483c6be434015f Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 14:20:15 +0100 Subject: [PATCH 024/110] Test --- .github/workflows/test.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 96356ebb387..379426d8d66 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,8 +29,7 @@ jobs: echo "env prg: ${{env.VARAAA}}" echo "secret org: ${{secrets.BBB}}" echo "variable repository of orga: ${{vars.CCC}}" - #echo "ENVGHT: ${{ENVGHT}}" - #echo "ENVGHT: $ENVGHT" + echo "ENVGHT: ${{env.ENVGHT}}" echo "ENVGHU: ${{ENVGHU}}" echo "ENVGHU: $ENVGHU" echo "VARAAA: ${{VARAAA}}" From b4ece8d1543c542a0f04b03706e076a461c681f1 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 14:25:10 +0100 Subject: [PATCH 025/110] Fix --- .github/workflows/test.yaml | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 379426d8d66..0e9a823705b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -13,6 +13,7 @@ env: VARAAA: ${{ vars.AAA }} SECBBB: ${{ secrets.BBB }} VARREPORGCCC: ${{ vars.CCC }} + ENVFIX: "abc" jobs: testjob: @@ -30,27 +31,8 @@ jobs: echo "secret org: ${{secrets.BBB}}" echo "variable repository of orga: ${{vars.CCC}}" echo "ENVGHT: ${{env.ENVGHT}}" - echo "ENVGHU: ${{ENVGHU}}" - echo "ENVGHU: $ENVGHU" - echo "VARAAA: ${{VARAAA}}" - echo "VARAAA: $VARAAA" - echo "ENVAAA: ${{VARAAA}}" - echo "ENVAAA: $VARAAA" - echo "VARREPORGCCC: ${{VARREPORGCCC}}" - echo "VARREPORGCCC: $VARREPORGCCC" - echo "ENVGHTWITH: ${{ENVGHTWITH}}" - echo "ENVGHT: $ENVGHTWITH" - echo "ENVGHUWITH: ${{ENVGHUWITH}}" - echo "ENVGHU: $ENVGHUWITH" - echo "VARAAAWITH: ${{VARAAAWITH}}" - echo "VARAAAWITH: $VARAAAWITH" - echo "SECBBBWITH: ${{SECBBBWITH}}" - echo "SECBBBWITH: $SECBBBWITH" -# with: -# ENVGHW: $GH_TOKEN -# ENVGHTWITH: $ENVGHT -# ENVGHUWITH: $ENVGHU -# VARAAAWITH: $VARAAA -# SECBBBWITH: $SECBBB -# VARREPORGCCCWITH: $VARREPORGCCC - + echo "ENVGHU: ${{env.ENVGHU}}" + echo "VARAAA: ${{env.VARAAA}}" + echo "ENVAAA: ${{env.VARAAA}}" + echo "VARREPORGCCC: ${{env.VARREPORGCCC}}" + echo "ENVFIX: ${{env.abc}}" From ab5f9a0884ddef171b3afb6e8171f1513951762f Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 14:31:00 +0100 Subject: [PATCH 026/110] Tst --- .github/workflows/test.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0e9a823705b..8b056039f30 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,3 +1,4 @@ +name: Test github actions on: workflow_dispatch: pull_request: @@ -5,8 +6,6 @@ on: branches: - "18.0" -permissions: write-all - env: ENVGHT: ${{ secrets.GH_TOKEN }} ENVGHU: ${{ github.token }} From eb2b35e3b1e5d21a64b593d8fb1127e1efd51d64 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 14:32:16 +0100 Subject: [PATCH 027/110] Test --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8b056039f30..1ce087caeea 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,7 +7,7 @@ on: - "18.0" env: - ENVGHT: ${{ secrets.GH_TOKEN }} + ENVGHT: ${{ secrets.GITHUB_TOKEN }} ENVGHU: ${{ github.token }} VARAAA: ${{ vars.AAA }} SECBBB: ${{ secrets.BBB }} From 9411ac2144d64f8ac0f509b439c1f35172cc32c4 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 14:35:30 +0100 Subject: [PATCH 028/110] Test --- .github/workflows/pr-18.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index 8a4c916809f..c2ced3dede7 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -18,7 +18,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} - GH_TOKENS: ${{ secrets.GH_TOKEN }} + GH_TOKENS: ${{ secrets.GH_TOKEN }} steps: - name: Checkout repository @@ -40,7 +40,7 @@ jobs: REVIEWER: "rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer run: | echo "GH_TOKEN=$GH_TOKEN" - echo "GH_TOKENS=$GH_TOKENS" + echo "GH_TOKENS=$GH_TOKENS" pr_number=$(jq --raw-output .number < $GITHUB_EVENT_PATH) gh pr edit $pr_number --add-reviewer "$REVIEWER" continue-on-error: true From d055b1fb29913c92b387ab68ebe54425eca5016b Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 14:36:07 +0100 Subject: [PATCH 029/110] Test --- .github/workflows/pr-18.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index c2ced3dede7..91c3951c813 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -1,3 +1,4 @@ +name: Set reviewer for v18 on: pull_request: types: [opened, synchronize, reopened] From 9b46ed9c2d638635cabfbe6630b45c8ac0342330 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 14:57:17 +0100 Subject: [PATCH 030/110] Test --- .github/workflows/pr-18-autolabel.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pr-18-autolabel.yaml b/.github/workflows/pr-18-autolabel.yaml index 4524d02815b..c5a2d32b5db 100644 --- a/.github/workflows/pr-18-autolabel.yaml +++ b/.github/workflows/pr-18-autolabel.yaml @@ -8,6 +8,10 @@ on: branches: - "18.0" +permissions: + issues: write + pull-requests: write + jobs: changed-lines-count-labeler: runs-on: ubuntu-latest From 0960fcba2a8310bf1ce37e9c3a4147aae36e700c Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 15:02:43 +0100 Subject: [PATCH 031/110] Test --- .github/workflows/pr-18-autolabel.yaml | 7 ++++--- .github/workflows/stale-issues-safe.yml | 2 +- .github/workflows/test.yaml | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-18-autolabel.yaml b/.github/workflows/pr-18-autolabel.yaml index c5a2d32b5db..47a0edc4cbf 100644 --- a/.github/workflows/pr-18-autolabel.yaml +++ b/.github/workflows/pr-18-autolabel.yaml @@ -8,9 +8,10 @@ on: branches: - "18.0" -permissions: - issues: write - pull-requests: write +#permissions: +# issues: write +# pull-requests: write +permissions: {} # no restriction on permissions jobs: changed-lines-count-labeler: diff --git a/.github/workflows/stale-issues-safe.yml b/.github/workflows/stale-issues-safe.yml index af04675d48d..97d2992e2dd 100644 --- a/.github/workflows/stale-issues-safe.yml +++ b/.github/workflows/stale-issues-safe.yml @@ -8,7 +8,7 @@ on: types: [created] workflow_dispatch: -permissions: {} # none +permissions: {} # no restriction on permissions jobs: stale: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1ce087caeea..15c7e194b89 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -6,6 +6,8 @@ on: branches: - "18.0" +permissions: {} # no restriction on permissions + env: ENVGHT: ${{ secrets.GITHUB_TOKEN }} ENVGHU: ${{ github.token }} From 9a9602f41855403d9430ffc0cac2bdec57b43659 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 15:09:08 +0100 Subject: [PATCH 032/110] Test --- .github/workflows/pr-18-autolabel.yaml | 5 ----- .github/workflows/pr-18.yaml | 5 ----- .github/workflows/test.yaml | 5 ----- 3 files changed, 15 deletions(-) diff --git a/.github/workflows/pr-18-autolabel.yaml b/.github/workflows/pr-18-autolabel.yaml index 47a0edc4cbf..4524d02815b 100644 --- a/.github/workflows/pr-18-autolabel.yaml +++ b/.github/workflows/pr-18-autolabel.yaml @@ -8,11 +8,6 @@ on: branches: - "18.0" -#permissions: -# issues: write -# pull-requests: write -permissions: {} # no restriction on permissions - jobs: changed-lines-count-labeler: runs-on: ubuntu-latest diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index 91c3951c813..718a7c40d0a 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -8,13 +8,8 @@ on: branches: - "18.0" -#permissions: write-all - jobs: pr18: - permissions: - issues: write - pull-requests: write runs-on: ubuntu-latest env: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 15c7e194b89..78c29dd9388 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -6,8 +6,6 @@ on: branches: - "18.0" -permissions: {} # no restriction on permissions - env: ENVGHT: ${{ secrets.GITHUB_TOKEN }} ENVGHU: ${{ github.token }} @@ -18,9 +16,6 @@ env: jobs: testjob: - permissions: - issues: write - pull-requests: write runs-on: ubuntu-latest steps: - name: Log From 6920b72cf4bd2394ead8515d32e9b370c9f38a96 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 15:35:03 +0100 Subject: [PATCH 033/110] Test --- .github/workflows/pr-18.yaml | 9 +++++---- .github/workflows/stale-issues-safe.yml | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index 718a7c40d0a..8f7ae78409a 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -25,10 +25,10 @@ jobs: sudo apt update sudo apt install gh -y - #- name: Authenticate GitHub CLI - # run: | - # echo "GH_TOKEN=$GH_TOKEN" - # gh auth login --with-token <<< "$GH_TOKEN" + - name: Authenticate GitHub CLI + run: | + echo "GH_TOKEN=$GH_TOKEN" + gh auth login --with-token <<< "$GH_TOKEN" - name: Assign reviewer env: @@ -38,5 +38,6 @@ jobs: echo "GH_TOKEN=$GH_TOKEN" echo "GH_TOKENS=$GH_TOKENS" pr_number=$(jq --raw-output .number < $GITHUB_EVENT_PATH) + echo "pr_numer=$pr_number" gh pr edit $pr_number --add-reviewer "$REVIEWER" continue-on-error: true diff --git a/.github/workflows/stale-issues-safe.yml b/.github/workflows/stale-issues-safe.yml index 97d2992e2dd..1b0f78c2c21 100644 --- a/.github/workflows/stale-issues-safe.yml +++ b/.github/workflows/stale-issues-safe.yml @@ -8,7 +8,7 @@ on: types: [created] workflow_dispatch: -permissions: {} # no restriction on permissions +permissions: {} # no restriction by default jobs: stale: From 3d9b7ed7d3aa25501e431c6ac804af51cb5a68f5 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 15:40:35 +0100 Subject: [PATCH 034/110] Test --- .github/workflows/pr-18.yaml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index 8f7ae78409a..f1ef3fcea20 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -14,7 +14,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} - GH_TOKENS: ${{ secrets.GH_TOKEN }} + GH_TOKENS: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository @@ -25,11 +25,6 @@ jobs: sudo apt update sudo apt install gh -y - - name: Authenticate GitHub CLI - run: | - echo "GH_TOKEN=$GH_TOKEN" - gh auth login --with-token <<< "$GH_TOKEN" - - name: Assign reviewer env: #REVIEWER: "eldy,lvessiller-opendsi,rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer @@ -37,7 +32,10 @@ jobs: run: | echo "GH_TOKEN=$GH_TOKEN" echo "GH_TOKENS=$GH_TOKENS" + echo Get the pr_number pr_number=$(jq --raw-output .number < $GITHUB_EVENT_PATH) + echo authenticatenv + gh auth login --with-token <<< "$GH_TOKEN" echo "pr_numer=$pr_number" gh pr edit $pr_number --add-reviewer "$REVIEWER" continue-on-error: true From f9eb6b69f5a4f1232c0cf58ec29a9a3d38c431b1 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 15:40:35 +0100 Subject: [PATCH 035/110] Test --- .github/workflows/pr-18.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index 8f7ae78409a..049b2ce0133 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -14,7 +14,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} - GH_TOKENS: ${{ secrets.GH_TOKEN }} + GH_TOKENS: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository @@ -25,11 +25,6 @@ jobs: sudo apt update sudo apt install gh -y - - name: Authenticate GitHub CLI - run: | - echo "GH_TOKEN=$GH_TOKEN" - gh auth login --with-token <<< "$GH_TOKEN" - - name: Assign reviewer env: #REVIEWER: "eldy,lvessiller-opendsi,rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer @@ -37,7 +32,11 @@ jobs: run: | echo "GH_TOKEN=$GH_TOKEN" echo "GH_TOKENS=$GH_TOKENS" + echo Get the pr_number pr_number=$(jq --raw-output .number < $GITHUB_EVENT_PATH) echo "pr_numer=$pr_number" + echo Authenticate login gh + gh auth login --with-token <<< "$GH_TOKEN" + echo Set the PR gh pr edit $pr_number --add-reviewer "$REVIEWER" continue-on-error: true From ee7201fc6186d3b0d6104f352d32471aa6a765e0 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 15:43:42 +0100 Subject: [PATCH 036/110] Test --- .github/workflows/pr-18.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index 95d45a1ed8b..9633e3e05d3 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -30,6 +30,7 @@ jobs: #REVIEWER: "eldy,lvessiller-opendsi,rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer REVIEWER: "rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer run: | + echo "Run action by ${{ github.actor }}" echo "GH_TOKEN=$GH_TOKEN" echo "GH_TOKENS=$GH_TOKENS" echo Get the pr_number From 127b9701ff903ef0996ffd108cf07d17e31da5fc Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 15:43:42 +0100 Subject: [PATCH 037/110] Test --- .github/workflows/pr-18.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index 95d45a1ed8b..f89d29c68b3 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -12,9 +12,9 @@ jobs: pr18: runs-on: ubuntu-latest - env: - GH_TOKEN: ${{ github.token }} - GH_TOKENS: ${{ secrets.GITHUB_TOKEN }} + #env: + # GH_TOKEN: ${{ github.token }} + # GH_TOKENS: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository @@ -30,15 +30,15 @@ jobs: #REVIEWER: "eldy,lvessiller-opendsi,rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer REVIEWER: "rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer run: | - echo "GH_TOKEN=$GH_TOKEN" - echo "GH_TOKENS=$GH_TOKENS" + echo "Run action by ${{ github.actor }}" + echo "github.token=${{ github.token }}" + echo "secrets.GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" + echo "GITHUB_EVENT_PATH=$GITHUB_EVENT_PATH" echo Get the pr_number pr_number=$(jq --raw-output .number < $GITHUB_EVENT_PATH) - echo authenticatenv - gh auth login --with-token <<< "$GH_TOKEN" echo "pr_numer=$pr_number" echo Authenticate login gh - gh auth login --with-token <<< "$GH_TOKEN" + gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}" echo Set the PR gh pr edit $pr_number --add-reviewer "$REVIEWER" continue-on-error: true From c3ede4413d70988e7432626f807f62321db84ff0 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 8 Dec 2024 16:01:45 +0100 Subject: [PATCH 038/110] Test --- .github/workflows/pr-18.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index f89d29c68b3..015b7b25694 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -36,9 +36,9 @@ jobs: echo "GITHUB_EVENT_PATH=$GITHUB_EVENT_PATH" echo Get the pr_number pr_number=$(jq --raw-output .number < $GITHUB_EVENT_PATH) - echo "pr_numer=$pr_number" + echo "pr_number=$pr_number" echo Authenticate login gh gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}" - echo Set the PR + echo Set the reviewere gh pr edit $pr_number --add-reviewer "$REVIEWER" continue-on-error: true From 30893bf6760101bca7e42c2a55c9ae6ad6947b8c Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 9 Dec 2024 08:36:07 +0100 Subject: [PATCH 039/110] Test --- .github/workflows/pr-18.yaml | 3 ++- .github/workflows/test.yaml | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index 015b7b25694..692faf4ad2d 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -39,6 +39,7 @@ jobs: echo "pr_number=$pr_number" echo Authenticate login gh gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}" - echo Set the reviewere + gh auth setup-git + echo Set the reviewer gh pr edit $pr_number --add-reviewer "$REVIEWER" continue-on-error: true diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 78c29dd9388..86e2e445339 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -20,6 +20,10 @@ jobs: steps: - name: Log run: | + echo "Run action by ${{ github.actor }}" + echo "github.token=${{ github.token }}" + echo "secrets.GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" + echo "GITHUB_EVENT_PATH=$GITHUB_EVENT_PATH" echo "repo-token: ${{secrets.GITHUB_TOKEN}}" echo "variable org: ${{vars.AAA}}" echo "env prg: ${{env.AAA}}" From cfd491982902f0b78db51362d1af94394477a5c2 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 9 Dec 2024 08:40:25 +0100 Subject: [PATCH 040/110] Test --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 86e2e445339..30ccca5b0e9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -32,7 +32,7 @@ jobs: echo "variable repository of orga: ${{vars.CCC}}" echo "ENVGHT: ${{env.ENVGHT}}" echo "ENVGHU: ${{env.ENVGHU}}" - echo "VARAAA: ${{env.VARAAA}}" + echo "VARAAA: ${{vars.AAA}}" echo "ENVAAA: ${{env.VARAAA}}" echo "VARREPORGCCC: ${{env.VARREPORGCCC}}" - echo "ENVFIX: ${{env.abc}}" + echo "ENVFIX: ${{env.ENVFIX}}" From f1868ee1626426ce8517bbb4ac92472b74d03e39 Mon Sep 17 00:00:00 2001 From: Etienne BENDER Date: Mon, 9 Dec 2024 10:50:29 +0100 Subject: [PATCH 041/110] Replace dol_syslog throws by default log level --- htdocs/core/lib/functions.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dd1536e1245..4c423494196 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1658,8 +1658,11 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = if (!empty($message)) { // Test log level $logLevels = array(LOG_EMERG=>'EMERG', LOG_ALERT=>'ALERT', LOG_CRIT=>'CRITICAL', LOG_ERR=>'ERR', LOG_WARNING=>'WARN', LOG_NOTICE=>'NOTICE', LOG_INFO=>'INFO', LOG_DEBUG=>'DEBUG'); + $defaultLogLevel = getDolGlobalInt('DEFAULT_SYSLOG_LEVEL', $logLevels[LOG_ERR]); + if (!array_key_exists($level, $logLevels)) { - throw new Exception('Incorrect log level'); + dol_syslog('The given log level does not correspond to any of the available levels: '.$level, LOG_ERR); + $level = $defaultLogLevel; } if ($level > $conf->global->SYSLOG_LEVEL) { return; From a96d13d5aaf7f81bdf57aa7b445e425ee954bd12 Mon Sep 17 00:00:00 2001 From: Etienne BENDER Date: Mon, 9 Dec 2024 10:56:35 +0100 Subject: [PATCH 042/110] Add translation for bad log level --- htdocs/core/lib/functions.lib.php | 7 +++---- htdocs/langs/en_US/errors.lang | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4c423494196..19839800a7a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1627,7 +1627,7 @@ function dol_ucwords($string, $encoding = "UTF-8") */ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = '', $restricttologhandler = '', $logcontext = null) { - global $conf, $user, $debugbar; + global $conf, $user, $debugbar, $langs; // If syslog module enabled if (empty($conf->syslog->enabled)) { @@ -1658,11 +1658,10 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = if (!empty($message)) { // Test log level $logLevels = array(LOG_EMERG=>'EMERG', LOG_ALERT=>'ALERT', LOG_CRIT=>'CRITICAL', LOG_ERR=>'ERR', LOG_WARNING=>'WARN', LOG_NOTICE=>'NOTICE', LOG_INFO=>'INFO', LOG_DEBUG=>'DEBUG'); - $defaultLogLevel = getDolGlobalInt('DEFAULT_SYSLOG_LEVEL', $logLevels[LOG_ERR]); if (!array_key_exists($level, $logLevels)) { - dol_syslog('The given log level does not correspond to any of the available levels: '.$level, LOG_ERR); - $level = $defaultLogLevel; + dol_syslog($langs->trans('ErrorBadLogLevel', $level), LOG_ERR); + $level = getDolGlobalInt('DEFAULT_SYSLOG_LEVEL', $logLevels[LOG_ERR]); } if ($level > $conf->global->SYSLOG_LEVEL) { return; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 046809b9405..ccc5bc87eea 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -155,6 +155,7 @@ ErrorPHPNeedModule=Error, your PHP must have module %s installed to use t ErrorOpenIDSetupNotComplete=You setup Dolibarr config file to allow OpenID authentication, but URL of OpenID service is not defined into constant %s ErrorWarehouseMustDiffers=Source and target warehouses must differs ErrorBadFormat=Bad format! +ErrorBadLogLevel=The given log level does not correspond to any of the available levels: %s ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst=Error, this member is not yet linked to any third party. Link member to an existing third party or create a new third party before creating subscription with invoice. ErrorThereIsSomeDeliveries=Error, there is some deliveries linked to this shipment. Deletion refused. ErrorCantDeletePaymentReconciliated=Can't delete a payment that had generated a bank entry that was reconciled From 3c22179183b44f991b7437afbcdd57c44ab22881 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 9 Dec 2024 14:20:28 +0100 Subject: [PATCH 043/110] Rename file --- ...d-lines-count-labeler.yml => changed-lines-count-labeler.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{changed-lines-count-labeler.yml => changed-lines-count-labeler.yml} (100%) diff --git a/.github/changed-lines-count-labeler.yml b/.github/changed-lines-count-labeler.yml similarity index 100% rename from .github/changed-lines-count-labeler.yml rename to .github/changed-lines-count-labeler.yml From a4785adb3df9cf7162b21814c4e4204a67ce7ad6 Mon Sep 17 00:00:00 2001 From: tnegre Date: Thu, 12 Dec 2024 15:28:19 +0100 Subject: [PATCH 044/110] FIX : display error when loan can't be deleted --- htdocs/loan/card.php | 4 ++-- htdocs/loan/class/loan.class.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 8c4cc3810b8..45e8fe0fd8a 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -82,7 +82,7 @@ if (empty($reshook)) { if ($result > 0) { setEventMessages($langs->trans('LoanPaid'), null, 'mesgs'); } else { - setEventMessages($loan->error, null, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -95,7 +95,7 @@ if (empty($reshook)) { header("Location: list.php"); exit; } else { - setEventMessages($loan->error, null, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 98051a0d2b6..0f077d0d9ed 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -308,6 +308,7 @@ class Loan extends CommonObject $accountline->fetch($line_url['fk_bank']); $result = $accountline->delete_urls($user); if ($result < 0) { + $this->errors = array_merge($this->errors, [$accountline->error], $accountline->errors); $error++; } } From d9be3efa90a081f6b5c3c64c1e3a36d3432cb2f4 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 13 Dec 2024 06:18:45 +0100 Subject: [PATCH 045/110] FIX #32339 Delete a loan settlement is partial --- htdocs/loan/class/paymentloan.class.php | 44 +++++++++---------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index bd02374a24c..77c8b183b87 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2015-2018 Frederic France - * Copyright (C) 2020 Maxime DEMAREST +/* Copyright (C) 2014-2024 Alexandre Spangaro + * Copyright (C) 2015-2018 Frederic France + * Copyright (C) 2020 Maxime DEMAREST * * 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 @@ -99,6 +99,11 @@ class PaymentLoan extends CommonObject public $type_code; public $type_label; + /** + * @var int + */ + public $bank_line; + /** * Constructor @@ -364,6 +369,7 @@ class PaymentLoan extends CommonObject } $this->db->rollback(); return -1 * $error; + } else { $this->db->commit(); return 1; @@ -380,19 +386,17 @@ class PaymentLoan extends CommonObject */ public function delete($user, $notrigger = 0) { - global $conf, $langs; $error = 0; $this->db->begin(); - if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; - $sql .= " WHERE type='payment_loan' AND url_id=".((int) $this->id); - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + if ($this->bank_line > 0) { + $accline = new AccountLine($this->db); + $accline->fetch($this->bank_line); + $result = $accline->delete($user); + if ($result < 0) { + $this->errors[] = $accline->error; + $error++; } } @@ -422,22 +426,6 @@ class PaymentLoan extends CommonObject } } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { From ef090aa895dc7d33482f4bd6d4b1ef9bb8d1d395 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 13 Dec 2024 06:22:44 +0100 Subject: [PATCH 046/110] CI --- htdocs/loan/class/paymentloan.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 77c8b183b87..1604383b700 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -369,7 +369,6 @@ class PaymentLoan extends CommonObject } $this->db->rollback(); return -1 * $error; - } else { $this->db->commit(); return 1; From 62c1d500e8db181ba99312c4eaa349be9c317f85 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Fri, 13 Dec 2024 14:05:04 +0100 Subject: [PATCH 047/110] Avoid errors --- .github/workflows/pr-18-autolabel.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-18-autolabel.yaml b/.github/workflows/pr-18-autolabel.yaml index 4524d02815b..4f7b08ea725 100644 --- a/.github/workflows/pr-18-autolabel.yaml +++ b/.github/workflows/pr-18-autolabel.yaml @@ -18,3 +18,4 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} configuration-path: .github/changed-lines-count-labeler.yml + continue-on-error: true \ No newline at end of file From a6da3b189aed15e86e642eadbbff9cd1ae079e0e Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 16 Dec 2024 12:59:16 +0100 Subject: [PATCH 048/110] Not required, but for better code consistency --- htdocs/core/get_menudiv.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index 4dfe4cc5c75..7d8879e3b32 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -252,7 +252,7 @@ if (!class_exists('MenuManager')) { $menufound = 0; $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); foreach ($dirmenus as $dirmenu) { - $menufound = dol_include_once($dirmenu."standard/".$file_menu); + $menufound = dol_include_once($dirmenu."standard/".dol_sanitizeFileName($file_menu)); if ($menufound) { break; } @@ -260,7 +260,7 @@ if (!class_exists('MenuManager')) { if (!$menufound) { // If failed to include, we try with standard dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING); $file_menu = 'eldy_menu.php'; - include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu; + include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".dol_sanitizeFileName($file_menu); } } $menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1); From 6aee2db1d4d344f7e498964c44dfbd44650e0a5e Mon Sep 17 00:00:00 2001 From: Etienne BENDER Date: Tue, 17 Dec 2024 09:01:04 +0100 Subject: [PATCH 049/110] Remove use of getDolGlobalInt() --- 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 19839800a7a..b876186836b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1661,7 +1661,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = if (!array_key_exists($level, $logLevels)) { dol_syslog($langs->trans('ErrorBadLogLevel', $level), LOG_ERR); - $level = getDolGlobalInt('DEFAULT_SYSLOG_LEVEL', $logLevels[LOG_ERR]); + $level = $logLevels[LOG_ERR]; } if ($level > $conf->global->SYSLOG_LEVEL) { return; From b73bcd68a94b75300cb78a7f4610a60acbc0f43e Mon Sep 17 00:00:00 2001 From: tnegre Date: Wed, 18 Dec 2024 10:36:39 +0100 Subject: [PATCH 050/110] pre-commit : change regex for hook no-commit-to-branch in order to allow branches BEGINNING by 18.0, such as `18.0_fix_foo` --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47ffeb5e28f..3296110422c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: rev: v4.5.0 hooks: - id: no-commit-to-branch - args: [--branch, develop, --pattern, \d+.0] + args: [--branch, develop, --pattern, \d+.0$] - id: check-yaml args: [--unsafe] - id: check-json From ce06c12da61d778e8004c98748cb6be0e137f51b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina=20JOUM?= Date: Wed, 18 Dec 2024 11:19:56 +0100 Subject: [PATCH 051/110] FIX: GETPOST('private_message') --- htdocs/ticket/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 265a661448d..3ae08149626 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -458,7 +458,7 @@ if (empty($reshook)) { // Action to add a message (private or not, with email or not). // This may also send an email (concatenated with email_intro and email footer if checkbox was selected) if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $permissiontoread) { - $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0), 0); + $ret = $object->newMessage($user, $action, GETPOSTINT('private_message'), 0); if ($ret > 0) { if (!empty($backtopage)) { From 425c23d28cafc1ada9c2090eac219f3a604320f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20PASCAL?= Date: Thu, 19 Dec 2024 15:38:19 +0100 Subject: [PATCH 052/110] fix: fetch action linked object --- htdocs/core/class/commonobject.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 59d71a5bf36..232a3b6893b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3832,7 +3832,7 @@ abstract class CommonObject $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); if ($justsource || $justtarget) { if ($justsource) { $this->linkedObjectsIds[$obj->targettype][$obj->rowid] = $obj->fk_target; @@ -3892,8 +3892,12 @@ abstract class CommonObject $classpath = 'adherents/class'; $module = 'adherent'; } elseif ($objecttype == 'contact') { - $module = 'societe'; - } + $module = 'societe'; + } elseif ($objecttype == 'action') { + $module = 'agenda'; + $subelement = 'actionComm'; + } + // Set classfile $classfile = strtolower($subelement); $classname = ucfirst($subelement); From be95c92c45814ac0e73dad46b70ac0ef5f8cd294 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Dec 2024 18:07:02 +0100 Subject: [PATCH 053/110] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b876186836b..7fe94ff83c4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1627,7 +1627,7 @@ function dol_ucwords($string, $encoding = "UTF-8") */ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = '', $restricttologhandler = '', $logcontext = null) { - global $conf, $user, $debugbar, $langs; + global $conf, $user, $debugbar; // If syslog module enabled if (empty($conf->syslog->enabled)) { @@ -1660,7 +1660,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = $logLevels = array(LOG_EMERG=>'EMERG', LOG_ALERT=>'ALERT', LOG_CRIT=>'CRITICAL', LOG_ERR=>'ERR', LOG_WARNING=>'WARN', LOG_NOTICE=>'NOTICE', LOG_INFO=>'INFO', LOG_DEBUG=>'DEBUG'); if (!array_key_exists($level, $logLevels)) { - dol_syslog($langs->trans('ErrorBadLogLevel', $level), LOG_ERR); + dol_syslog('Error Bad Log Level '.$level, LOG_ERR); $level = $logLevels[LOG_ERR]; } if ($level > $conf->global->SYSLOG_LEVEL) { From fedcec58a67614ba6619ededae1916a9b5572a0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Dec 2024 18:09:50 +0100 Subject: [PATCH 054/110] Update errors.lang --- htdocs/langs/en_US/errors.lang | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index ccc5bc87eea..046809b9405 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -155,7 +155,6 @@ ErrorPHPNeedModule=Error, your PHP must have module %s installed to use t ErrorOpenIDSetupNotComplete=You setup Dolibarr config file to allow OpenID authentication, but URL of OpenID service is not defined into constant %s ErrorWarehouseMustDiffers=Source and target warehouses must differs ErrorBadFormat=Bad format! -ErrorBadLogLevel=The given log level does not correspond to any of the available levels: %s ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst=Error, this member is not yet linked to any third party. Link member to an existing third party or create a new third party before creating subscription with invoice. ErrorThereIsSomeDeliveries=Error, there is some deliveries linked to this shipment. Deletion refused. ErrorCantDeletePaymentReconciliated=Can't delete a payment that had generated a bank entry that was reconciled From e3c44568a026271e3c5c28a0dee01b405618ba2e Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 19 Dec 2024 18:31:15 +0100 Subject: [PATCH 055/110] Test github action --- .github/workflows/pr-18.yaml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index 692faf4ad2d..5523dc1a55c 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -20,12 +20,21 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Install GitHub CLI - run: | - sudo apt update - sudo apt install gh -y + #- name: Install GitHub CLI + # run: | + # sudo apt update + # sudo apt install gh -y - - name: Assign reviewer + - name: Assign reviewer method 1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + url: ${{ github.event.pull_request.html_url }} + run: | + gh pr edit "$url" --add-assignee rycks --add-reviewer rycks + gh pr merge "$url" --merge --auto + + + - name: Assign reviewer method 2 env: #REVIEWER: "eldy,lvessiller-opendsi,rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer REVIEWER: "rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer From 04b7fdd4c442cc99edef6d04153e66ab1a631f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 19 Dec 2024 18:32:16 +0100 Subject: [PATCH 056/110] fix CI --- htdocs/core/class/commonobject.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c340cbd5d20..39009d1301e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3834,7 +3834,7 @@ abstract class CommonObject $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); if ($justsource || $justtarget) { if ($justsource) { $this->linkedObjectsIds[$obj->targettype][$obj->rowid] = $obj->fk_target; @@ -3894,11 +3894,11 @@ abstract class CommonObject $classpath = 'adherents/class'; $module = 'adherent'; } elseif ($objecttype == 'contact') { - $module = 'societe'; - } elseif ($objecttype == 'action') { - $module = 'agenda'; - $subelement = 'actionComm'; - } + $module = 'societe'; + } elseif ($objecttype == 'action') { + $module = 'agenda'; + $subelement = 'actionComm'; + } // Set classfile $classfile = strtolower($subelement); From 0300209b3d205acfed8dbd8c8afda159c9c02d79 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 24 Dec 2024 02:00:37 +0100 Subject: [PATCH 057/110] Missing new line --- .github/workflows/pr-18-autolabel.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-18-autolabel.yaml b/.github/workflows/pr-18-autolabel.yaml index 4f7b08ea725..feb9ee17c97 100644 --- a/.github/workflows/pr-18-autolabel.yaml +++ b/.github/workflows/pr-18-autolabel.yaml @@ -18,4 +18,4 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} configuration-path: .github/changed-lines-count-labeler.yml - continue-on-error: true \ No newline at end of file + continue-on-error: true From 8ccdbf374bdd43721202c0fc456385b5a6d2821d Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 29 Dec 2024 15:57:17 +0100 Subject: [PATCH 058/110] Update test --- .github/workflows/test.yaml | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 30ccca5b0e9..5a41c986098 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,10 +9,9 @@ on: env: ENVGHT: ${{ secrets.GITHUB_TOKEN }} ENVGHU: ${{ github.token }} - VARAAA: ${{ vars.AAA }} - SECBBB: ${{ secrets.BBB }} - VARREPORGCCC: ${{ vars.CCC }} - ENVFIX: "abc" + TEST_ACCESS_KEY: ${{ secrets.TEST_ACCESS_KEY }} + TEST_VAR_REPO: ${{ vars.TEST_VAR_REPO }} + ENVLOCAL: "varenvlocal" jobs: testjob: @@ -25,14 +24,6 @@ jobs: echo "secrets.GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" echo "GITHUB_EVENT_PATH=$GITHUB_EVENT_PATH" echo "repo-token: ${{secrets.GITHUB_TOKEN}}" - echo "variable org: ${{vars.AAA}}" - echo "env prg: ${{env.AAA}}" - echo "env prg: ${{env.VARAAA}}" - echo "secret org: ${{secrets.BBB}}" - echo "variable repository of orga: ${{vars.CCC}}" - echo "ENVGHT: ${{env.ENVGHT}}" - echo "ENVGHU: ${{env.ENVGHU}}" - echo "VARAAA: ${{vars.AAA}}" - echo "ENVAAA: ${{env.VARAAA}}" - echo "VARREPORGCCC: ${{env.VARREPORGCCC}}" - echo "ENVFIX: ${{env.ENVFIX}}" + echo "secret repository TEST_ACCESS_KEY: ${{secrets.TEST_ACCESS_KEY}}" + echo "variable repository : ${{vars.TEST_VAR_REPO}}" + echo "ENVLOCAL: ${{env.ENVLOCAL}}" From 92963af09f8c0f8c1aafff2934824e9f6b155f58 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 29 Dec 2024 17:04:54 +0100 Subject: [PATCH 059/110] Fix yml syntax --- .github/workflows/pr-18.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index 5523dc1a55c..f3ffa3a2e24 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -26,14 +26,14 @@ jobs: # sudo apt install gh -y - name: Assign reviewer method 1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - url: ${{ github.event.pull_request.html_url }} - run: | - gh pr edit "$url" --add-assignee rycks --add-reviewer rycks - gh pr merge "$url" --merge --auto + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + url: ${{ github.event.pull_request.html_url }} + run: | + gh pr edit "$url" --add-assignee rycks --add-reviewer rycks + gh pr merge "$url" --merge --auto + - - name: Assign reviewer method 2 env: #REVIEWER: "eldy,lvessiller-opendsi,rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer From 220090813d03e51aa6986791a5315e48f5cbef06 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Mon, 30 Dec 2024 10:28:23 +0100 Subject: [PATCH 060/110] there is no "name" field into llx_socpeople table --- htdocs/comm/contact.php | 12 ++++++------ htdocs/fourn/contact.php | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 19be738a50e..11ba439f86b 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -37,7 +37,7 @@ if (!$sortorder) { $sortorder = "ASC"; } if (!$sortfield) { - $sortfield = "p.name"; + $sortfield = "p.lastname"; } if ($page < 0) { $page = 0; @@ -81,7 +81,7 @@ if ($type == "f") { */ $sql = "SELECT s.rowid, s.nom as name, st.libelle as stcomm"; -$sql .= ", p.rowid as cidp, p.name, p.firstname, p.email, p.phone"; +$sql .= ", p.rowid as cidp, p.lastname, p.firstname, p.email, p.phone"; $sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st,"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; @@ -106,7 +106,7 @@ if ($socid) { $sql .= " AND s.rowid = ".((int) $socid); } if (!empty($search_lastname)) { - $sql .= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; + $sql .= " AND p.lastname LIKE '%".$db->escape($search_lastname)."%'"; } if (!empty($search_firstname)) { $sql .= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; @@ -115,8 +115,8 @@ if (!empty($search_company)) { $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; } if (!empty($contactname)) { // acces a partir du module de recherche - $sql .= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; - $sortfield = "p.name"; + $sql .= " AND (p.lastname LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; + $sortfield = "p.lastname"; $sortorder = "ASC"; } @@ -136,7 +136,7 @@ if ($resql) { print ''; print ''; - print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "p.name", $begin, $param, "", $sortfield, $sortorder); + print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "p.lastname", $begin, $param, "", $sortfield, $sortorder); print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "p.firstname", $begin, $param, "", $sortfield, $sortorder); print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", $begin, $param, "", $sortfield, $sortorder); print_liste_field_titre("Email"); diff --git a/htdocs/fourn/contact.php b/htdocs/fourn/contact.php index a4504e8f83e..4b96b6b7659 100644 --- a/htdocs/fourn/contact.php +++ b/htdocs/fourn/contact.php @@ -55,7 +55,7 @@ if (!$sortorder) { $sortorder = "ASC"; } if (!$sortfield) { - $sortfield = "p.name"; + $sortfield = "p.lastname"; } $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -85,12 +85,12 @@ if (dol_strlen($stcomm)) { } if (dol_strlen($begin)) { - $sql .= " AND p.name LIKE '$begin%'"; + $sql .= " AND p.lastname LIKE '$begin%'"; } if ($contactname) { - $sql .= " AND p.name LIKE '%".strtolower($contactname)."%'"; - $sortfield = "p.name"; + $sql .= " AND p.lastname LIKE '%".strtolower($contactname)."%'"; + $sortfield = "p.lastname"; $sortorder = "ASC"; } @@ -110,7 +110,7 @@ if ($result) { print '
'; print ''; - print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "p.name", $begin, "", "", $sortfield, $sortorder); + print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "p.lastname", $begin, "", "", $sortfield, $sortorder); print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "p.firstname", $begin, "", "", $sortfield, $sortorder); print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", $begin, "", "", $sortfield, $sortorder); print_liste_field_titre("Email"); From c273495261f30d995c876533789eb64fa0493688 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 31 Dec 2024 17:12:37 +0100 Subject: [PATCH 061/110] Fix ci --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d6bd08b6223..83c36349416 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3998,7 +3998,7 @@ abstract class CommonObject $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); if ($justsource || $justtarget) { if ($justsource) { $this->linkedObjectsIds[$obj->targettype][$obj->rowid] = $obj->fk_target; From a0b6aa28a73b1cdd4cbd2db82a6c227b073ee8ce Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 31 Dec 2024 17:13:43 +0100 Subject: [PATCH 062/110] Fix phpcs --- htdocs/core/class/commonobject.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 83c36349416..cf013497aec 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3998,7 +3998,7 @@ abstract class CommonObject $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); if ($justsource || $justtarget) { if ($justsource) { $this->linkedObjectsIds[$obj->targettype][$obj->rowid] = $obj->fk_target; @@ -4058,11 +4058,11 @@ abstract class CommonObject $classpath = 'adherents/class'; $module = 'adherent'; } elseif ($objecttype == 'contact') { - $module = 'societe'; - } elseif ($objecttype == 'action') { - $module = 'agenda'; - $subelement = 'actionComm'; - } + $module = 'societe'; + } elseif ($objecttype == 'action') { + $module = 'agenda'; + $subelement = 'actionComm'; + } // Set classfile $classfile = strtolower($subelement); From e41dfcbbb3e7ade96799d0d45ccb43de03f92572 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 31 Dec 2024 17:17:00 +0100 Subject: [PATCH 063/110] Fix phpcs --- htdocs/core/class/commonobject.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a5edaaf2280..2463e47ca90 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4011,7 +4011,7 @@ abstract class CommonObject $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); if ($justsource || $justtarget) { if ($justsource) { $this->linkedObjectsIds[$obj->targettype][$obj->rowid] = $obj->fk_target; @@ -4071,11 +4071,11 @@ abstract class CommonObject $classpath = 'adherents/class'; $module = 'adherent'; } elseif ($objecttype == 'contact') { - $module = 'societe'; - } elseif ($objecttype == 'action') { - $module = 'agenda'; - $subelement = 'actionComm'; - } + $module = 'societe'; + } elseif ($objecttype == 'action') { + $module = 'agenda'; + $subelement = 'actionComm'; + } // Set classfile $classfile = strtolower($subelement); From f60f34cdf8cd3c5f67afb7facd8391e389cfde09 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 2 Jan 2025 14:07:46 +0100 Subject: [PATCH 064/110] Backport fix for send email to assigned user on ticket create --- ...terface_50_modTicket_TicketEmail.class.php | 170 ++++++++++++++---- 1 file changed, 137 insertions(+), 33 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 58eeaf18dc3..bead2d3faf6 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -77,45 +77,48 @@ class InterfaceTicketEmail extends DolibarrTriggers if ($res > 0) { // Send email to notification email if (empty($conf->global->TICKET_DISABLE_ALL_MAILS)) { - // Init to avoid errors - $filepath = array(); - $filename = array(); - $mimetype = array(); +// Init to avoid errors +// $filepath = array(); +// $filename = array(); +// $mimetype = array(); // Send email to assigned user - $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketAssignedToYou'); - $message = '

'.$langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."

"; - $message .= '
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; - $message .= '
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; - $message .= '
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; - $message .= '
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; - // Extrafields - if (is_array($object->array_options) && count($object->array_options) > 0) { - foreach ($object->array_options as $key => $value) { - $message .= '
  • '.$langs->trans($key).' : '.$value.'
  • '; - } - } - - $message .= '
'; - $message .= '

'.$langs->trans('Message').' :
'.$object->message.'

'; - $message .= '

'.$langs->trans('SeeThisTicketIntomanagementInterface').'

'; +// $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketAssignedToYou'); +// $message = '

'.$langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."

"; +// $message .= '
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; +// $message .= '
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; +// $message .= '
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; +// $message .= '
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; +// // Extrafields +// if (is_array($object->array_options) && count($object->array_options) > 0) { +// foreach ($object->array_options as $key => $value) { +// $message .= '
  • '.$langs->trans($key).' : '.$value.'
  • '; +// } +// } +// +// $message .= '
'; +// $message .= '

'.$langs->trans('Message').' :
'.$object->message.'

'; +// $message .= '

'.$langs->trans('SeeThisTicketIntomanagementInterface').'

'; $sendto = $userstat->email; - $from = dolGetFirstLastname($user->firstname, $user->lastname).'<'.$user->email.'>'; - - $message = dol_nl2br($message); + $subject_assignee = 'TicketAssignedToYou'; + $body_assignee = 'TicketAssignedEmailBody'; + $see_ticket_assignee = 'SeeThisTicketIntomanagementInterface'; +// $from = dolGetFirstLastname($user->firstname, $user->lastname).'<'.$user->email.'>'; +// +// $message = dol_nl2br($message); if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1); - if ($mailfile->error) { - setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - } else { - $result = $mailfile->sendfile(); - } +// include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; +// $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1); +// if ($mailfile->error) { +// setEventMessages($mailfile->error, $mailfile->errors, 'errors'); +// } else { +// $result = $mailfile->sendfile(); +// } if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; } @@ -173,10 +176,15 @@ class InterfaceTicketEmail extends DolibarrTriggers $subject_admin = 'TicketNewEmailSubjectAdmin'; $body_admin = 'TicketNewEmailBodyAdmin'; + $subject_customer = 'TicketNewEmailSubjectCustomer'; $body_customer = 'TicketNewEmailBodyCustomer'; $see_ticket_customer = 'TicketNewEmailBodyInfosTrackUrlCustomer'; + $subject_assignee = 'TicketAssignedToYou'; + $body_assignee = 'TicketAssignedEmailBody'; + $see_ticket_assignee = 'SeeThisTicketIntomanagementInterface'; + // Send email to notification email if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail'])) { $sendto = empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) ? '' : $conf->global->TICKET_NOTIFICATION_EMAIL_TO; @@ -185,6 +193,34 @@ class InterfaceTicketEmail extends DolibarrTriggers } } + // Send email to assignee if an assignee was set at creation + if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id && empty($object->context['disableticketemail'])) { + $userstat = new User($this->db); + $res = $userstat->fetch($object->fk_user_assign); + if ($res > 0) { + // Send email to notification email + if (!getDolGlobalString('TICKET_DISABLE_ALL_MAILS')) { + // Send email to assigned user + $sendto = $userstat->email; + if (!getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { + $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; + $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; + } + + if (!empty($sendto)) { + $this->composeAndSendAssigneeMessage($sendto, $subject_assignee, $body_assignee, $see_ticket_assignee, $object, $langs); + } + + if (!getDolUserString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { + $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; + } + } + } else { + $this->error = $userstat->error; + $this->errors = $userstat->errors; + } + } + // Send email to customer if (empty($conf->global->TICKET_DISABLE_CUSTOMER_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) { $sendto = ''; @@ -428,9 +464,9 @@ class InterfaceTicketEmail extends DolibarrTriggers $trackid = 'tic'.$object->id; - $old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO'); - - if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { + $old_MAIN_MAIL_AUTOCOPY_TO = null; + if (getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { + $old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO'); $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } @@ -451,4 +487,72 @@ class InterfaceTicketEmail extends DolibarrTriggers $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; } } + + /** + * Composes and sends a message concerning a ticket, to be sent to user assigned to the ticket + * + * @param string $sendto Addresses to send the mail, format "first@address.net, second@address.net, " etc. + * @param string $base_subject email subject. Non-translated string. + * @param string $body email body (first line). Non-translated string. + * @param string $see_ticket string indicating the ticket public address + * @param Ticket $object the ticket thet the email refers to + * @param Translate $langs the translation object + * @return void + */ + private function composeAndSendAssigneeMessage($sendto, $base_subject, $body, $see_ticket, Ticket $object, Translate $langs) + { + global $conf, $user, $mysoc; + + // Init to avoid errors + $filepath = array(); + $filename = array(); + $mimetype = array(); + + // Send email to assigned user + $appli = $mysoc->name; + + $subject = '['.$appli.'] '.$langs->transnoentities($base_subject); + $message = '

'.$langs->transnoentities($body, $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."

"; + $message .= '
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; + $message .= '
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; + $message .= '
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; + $message .= '
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; + // Extrafields + if (is_array($object->array_options) && count($object->array_options) > 0) { + foreach ($object->array_options as $key => $value) { + $message .= '
  • '.$langs->trans($key).' : '.$value.'
  • '; + } + } + + $message .= '
'; + $message .= '

'.$langs->trans('Message').' :
'.$object->message.'

'; + $message .= '

'.$langs->trans($see_ticket).'

'; + + $from = dolGetFirstLastname($user->firstname, $user->lastname).'<'.$user->email.'>'; + + $message = dol_nl2br($message); + + $old_MAIN_MAIL_AUTOCOPY_TO = null; + if (getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { + $old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO'); + $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; + } + + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1); + if ($mailfile->error) { + setEventMessages($mailfile->error, $mailfile->errors, 'errors'); + } else { + $result = $mailfile->sendfile(); + if ($result) { + // update last_msg_sent date + $object->fetch($object->id); + $object->date_last_msg_sent = dol_now(); + $object->update($user); + } + } + if (!getDolUserString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { + $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; + } + } } From 37a815af535a485b9865bbedd483eee99c7827a6 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 2 Jan 2025 14:50:14 +0100 Subject: [PATCH 065/110] Cleaned code --- ...terface_50_modTicket_TicketEmail.class.php | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index bead2d3faf6..55f04a9d43e 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -77,48 +77,17 @@ class InterfaceTicketEmail extends DolibarrTriggers if ($res > 0) { // Send email to notification email if (empty($conf->global->TICKET_DISABLE_ALL_MAILS)) { -// Init to avoid errors -// $filepath = array(); -// $filename = array(); -// $mimetype = array(); - // Send email to assigned user -// $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketAssignedToYou'); -// $message = '

'.$langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."

"; -// $message .= '
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; -// $message .= '
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; -// $message .= '
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; -// $message .= '
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; -// // Extrafields -// if (is_array($object->array_options) && count($object->array_options) > 0) { -// foreach ($object->array_options as $key => $value) { -// $message .= '
  • '.$langs->trans($key).' : '.$value.'
  • '; -// } -// } -// -// $message .= '
'; -// $message .= '

'.$langs->trans('Message').' :
'.$object->message.'

'; -// $message .= '

'.$langs->trans('SeeThisTicketIntomanagementInterface').'

'; - $sendto = $userstat->email; $subject_assignee = 'TicketAssignedToYou'; $body_assignee = 'TicketAssignedEmailBody'; $see_ticket_assignee = 'SeeThisTicketIntomanagementInterface'; -// $from = dolGetFirstLastname($user->firstname, $user->lastname).'<'.$user->email.'>'; -// -// $message = dol_nl2br($message); if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } -// include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; -// $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1); -// if ($mailfile->error) { -// setEventMessages($mailfile->error, $mailfile->errors, 'errors'); -// } else { -// $result = $mailfile->sendfile(); -// } + if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; } From 4c4b773de5797e69e435dbbe89409cf2ca6220d9 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 2 Jan 2025 14:59:44 +0100 Subject: [PATCH 066/110] Fix send on assign --- .../triggers/interface_50_modTicket_TicketEmail.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 55f04a9d43e..00fce02d2c8 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -87,7 +87,9 @@ class InterfaceTicketEmail extends DolibarrTriggers $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } - + if (!empty($sendto)) { + $this->composeAndSendAssigneeMessage($sendto, $subject_assignee, $body_assignee, $see_ticket_assignee, $object, $langs); + } if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; } From 9ecc88230f20985bf8de2c5175e42d12e22683c8 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 5 Jan 2025 17:08:02 +0100 Subject: [PATCH 067/110] Test pr action --- .github/workflows/test.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5a41c986098..97f218fce4d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -3,8 +3,7 @@ on: workflow_dispatch: pull_request: types: [opened, reopened, synchronize] - branches: - - "18.0" + push: env: ENVGHT: ${{ secrets.GITHUB_TOKEN }} From 1866713082e5014be36e0c2be5fc4239f0e41143 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 5 Jan 2025 17:10:00 +0100 Subject: [PATCH 068/110] Avoid error --- .github/workflows/pr-18.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index f3ffa3a2e24..04b4b0ff35e 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -32,7 +32,7 @@ jobs: run: | gh pr edit "$url" --add-assignee rycks --add-reviewer rycks gh pr merge "$url" --merge --auto - + continue-on-error: true - name: Assign reviewer method 2 env: From 8805b8cac42be762a16478705e59c1600d173a4d Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 5 Jan 2025 17:22:30 +0100 Subject: [PATCH 069/110] Exclude test files --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3296110422c..82eb45c1d0b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -81,6 +81,8 @@ repos: ] pass_filenames: false # Run on all files - id: php-lint + exclude: + (?x)^(htdocs/includes/symfony/var-dumper/Tests/.*)$ - id: php-stan stages: [manual] files: \.(php)$ From eb4e05968360383d98b993e7ec5a7a4016110132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 4 Jan 2025 16:24:17 +0100 Subject: [PATCH 070/110] fix --- .../includes/tecnickcom/tcpdf/include/barcodes/pdf417.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/includes/tecnickcom/tcpdf/include/barcodes/pdf417.php b/htdocs/includes/tecnickcom/tcpdf/include/barcodes/pdf417.php index 3b1774eaae4..9a58a21f673 100644 --- a/htdocs/includes/tecnickcom/tcpdf/include/barcodes/pdf417.php +++ b/htdocs/includes/tecnickcom/tcpdf/include/barcodes/pdf417.php @@ -878,7 +878,7 @@ class PDF417 { $txtarr = array(); // array of characters and sub-mode switching characters $codelen = strlen($code); for ($i = 0; $i < $codelen; ++$i) { - $chval = ord($code{$i}); + $chval = ord($code[$i]); if (($k = array_search($chval, $this->textsubmodes[$submode])) !== false) { // we are on the same sub-mode $txtarr[] = $k; @@ -888,7 +888,7 @@ class PDF417 { // search new sub-mode if (($s != $submode) AND (($k = array_search($chval, $this->textsubmodes[$s])) !== false)) { // $s is the new submode - if (((($i + 1) == $codelen) OR ((($i + 1) < $codelen) AND (array_search(ord($code{($i + 1)}), $this->textsubmodes[$submode]) !== false))) AND (($s == 3) OR (($s == 0) AND ($submode == 1)))) { + if (((($i + 1) == $codelen) OR ((($i + 1) < $codelen) AND (array_search(ord($code[($i + 1)]), $this->textsubmodes[$submode]) !== false))) AND (($s == 3) OR (($s == 0) AND ($submode == 1)))) { // shift (temporary change only for this char) if ($s == 3) { // shift to puntuaction @@ -952,7 +952,7 @@ class PDF417 { $cw = array_merge($cw, $cw6); } else { for ($i = 0; $i < $sublen; ++$i) { - $cw[] = ord($code{$i}); + $cw[] = ord($code[$i]); } } $code = $rest; From 112220da86222ba4cf9054ac53685c735cc4502d Mon Sep 17 00:00:00 2001 From: tnegre Date: Fri, 3 Jan 2025 10:08:56 +0100 Subject: [PATCH 071/110] BUG: when there are two identical HTML tags in a substitution string, everything is taken between first opening tag and last closing tag. Write test to reproduce. --- test/phpunit/ODFTest.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/test/phpunit/ODFTest.php b/test/phpunit/ODFTest.php index a7d972bf345..a019d5754e2 100644 --- a/test/phpunit/ODFTest.php +++ b/test/phpunit/ODFTest.php @@ -296,33 +296,39 @@ class ODFTest extends PHPUnit\Framework\TestCase 'charset' => null, 'expected' => utf8_encode('text with intricatedtags'), ], + 24 => [ + 'to_convert' => "text with two (strong) tags", + 'encode' => true, + 'charset' => null, + 'expected' => utf8_encode('text with two (strong) tags'), + ], // One can also pass html-encoded string to the method - 24 => [ + 25 => [ 'to_convert' => 'One&two', 'encode' => true, 'charset' => null, 'expected' => 'One&two', ], - 25 => [ + 26 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => false, 'charset' => 'UTF-8', 'expected' => 'text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l\'', ], - 26 => [ + 27 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => true, 'charset' => 'UTF-8', 'expected' => 'text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l'', ], - 27 => [ + 28 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => false, 'charset' => null, 'expected' => utf8_encode('text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l\''), ], - 28 => [ + 29 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => true, 'charset' => null, @@ -341,20 +347,20 @@ class ODFTest extends PHPUnit\Framework\TestCase // Following tests reflect the current behavior. They may evolve if the method behavior changes. // The method removes hyperlinks and tags that are not dealt with. - 29 => [ + 30 => [ 'to_convert' => '123 trucmachin > truc < troc > tracbla bla', 'encode' => true, 'charset' => null, 'expected' => "123 trucmachin > truc < troc > tracbla bla", ], - 30 => [ + 31 => [ 'to_convert' => '123

Title

bla', 'encode' => true, 'charset' => null, 'expected' => "123 Title bla", ], // HTML should not take \n into account, but only
. - 31 => [ + 32 => [ 'to_convert' => "text with strong text , a line\nbreak and underlined words with it@lic sp&ciàlchärs éè l'", 'encode' => false, 'charset' => 'UTF-8', From b31962f7e2835a294d3079985ba2fe3426152e59 Mon Sep 17 00:00:00 2001 From: tnegre Date: Fri, 3 Jan 2025 10:41:35 +0100 Subject: [PATCH 072/110] fix --- htdocs/includes/odtphp/odf.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 5a832234686..17dc178b6a2 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -46,8 +46,8 @@ class Odf public $userdefined=array(); const PIXEL_TO_CM = 0.026458333; - const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/s'; - const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/'; + const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>([^(<\1>)]*)<\/\1>))/s'; + const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>([^(<\1>)]*)<\/\1>))/'; /** @@ -1017,4 +1017,4 @@ IMG; $this->contentXml = preg_replace($searchreg, "", $this->contentXml); return $matches[1]; } -} \ No newline at end of file +} From 61b03b0c0575456e098c2e7a2628ba385c1d179d Mon Sep 17 00:00:00 2001 From: tnegre Date: Fri, 3 Jan 2025 10:50:30 +0100 Subject: [PATCH 073/110] Testing ODF : revert parameters order for assertEquals() --- test/phpunit/ODFTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/ODFTest.php b/test/phpunit/ODFTest.php index a019d5754e2..ab1a2c74d48 100644 --- a/test/phpunit/ODFTest.php +++ b/test/phpunit/ODFTest.php @@ -377,7 +377,7 @@ class ODFTest extends PHPUnit\Framework\TestCase } else { $res = $odf->convertVarToOdf($case['to_convert'], $case['encode']); } - $this->assertEquals($res, $case['expected']); + $this->assertEquals($case['expected'], $res); } print __METHOD__." result=".$result."\n"; From 78bf506790c18a227c8b9936919f92e4a0b46df4 Mon Sep 17 00:00:00 2001 From: tnegre Date: Fri, 3 Jan 2025 11:14:17 +0100 Subject: [PATCH 074/110] fix tests in error --- htdocs/includes/odtphp/odf.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 17dc178b6a2..f5678d838a3 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -46,8 +46,8 @@ class Odf public $userdefined=array(); const PIXEL_TO_CM = 0.026458333; - const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>([^(<\1>)]*)<\/\1>))/s'; - const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>([^(<\1>)]*)<\/\1>))/'; + const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1>).)*)<\/\1>))/s'; + const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1>).)*)<\/\1>))/'; /** From b7cb799af0245ae3c5737a6bdd9589f9fc5eea7f Mon Sep 17 00:00:00 2001 From: Alexis Thietard Date: Mon, 6 Jan 2025 14:23:13 +0100 Subject: [PATCH 075/110] FIX #21294 Stock import sql query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To respect the PostgreSQL update statement syntax, cf. https://www.postgresql.org/docs/17/sql-update.html ``` column_name The name of a column in the table named by table_name. The column name can be qualified with a subfield name or array subscript, if needed. Do not include the table's name in the specification of a target column — for example, UPDATE table_name SET table_name.col = 1 is invalid. ``` Signed-off-by: Alexis Thietard --- htdocs/core/modules/modStock.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index e9e9ccc79a6..f7def03808c 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -429,7 +429,7 @@ class modStock extends DolibarrModules ); $this->import_updatekeys_array[$r] = array('ps.fk_product'=>'Product', 'ps.fk_entrepot'=>"Warehouse"); $this->import_run_sql_after_array[$r] = array( // Because we may change data that are denormalized, we must update dernormalized data after. - 'UPDATE '.MAIN_DB_PREFIX.'product as p SET p.stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' + 'UPDATE '.MAIN_DB_PREFIX.'product as p SET stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' ); } From c218eaa6ed6ca5e97ddbdaa6c68a8934bede5831 Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Tue, 7 Jan 2025 12:10:40 +0100 Subject: [PATCH 076/110] fix join societe_commerciaux in societe list --- htdocs/societe/list.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 21e811c25c8..59c79e2ec95 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -516,7 +516,7 @@ if ($search_sale == -2) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } elseif (!empty($search_sale) && $search_sale != '-1' || (empty($user->rights->societe->client->voir) && !$socid)) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux AS sc ON s.rowid = sc.fk_soc"; } // Add table from hooks $parameters = array(); @@ -527,9 +527,6 @@ $sql .= " WHERE s.entity IN (".getEntity('societe').")"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } -if ($search_sale && $search_sale != '-1' && $search_sale != '-2') { - $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale -} if (empty($user->rights->fournisseur->lire)) { $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible } From 74881ae25125a53396a5ce363e4aa19d67c6e6b9 Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Tue, 7 Jan 2025 12:10:40 +0100 Subject: [PATCH 077/110] fix join societe_commerciaux in societe list --- htdocs/societe/list.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 7f978829b91..512b7878a10 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -507,7 +507,7 @@ if ($search_sale == -2) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } elseif (!empty($search_sale) && $search_sale != '-1' || (empty($user->rights->societe->client->voir) && !$socid)) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux AS sc ON s.rowid = sc.fk_soc"; } // Add table from hooks $parameters = array(); @@ -518,9 +518,6 @@ $sql .= " WHERE s.entity IN (".getEntity('societe').")"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } -if ($search_sale && $search_sale != '-1' && $search_sale != '-2') { - $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale -} if (!$user->rights->fournisseur->lire) { $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible } From ec58ee940a8de664875d826f2c9ac3eca4b612d5 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:09:48 +0100 Subject: [PATCH 078/110] FIX: product variants copy: also copy multiprice variations --- .../class/ProductCombination.class.php | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 42e3bdc1530..fa642dc2765 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -702,16 +702,16 @@ class ProductCombination * [...] * ) * - * @param User $user Object user - * @param Product $product Parent product - * @param array $combinations Attribute and value combinations. - * @param array $variations Price and weight variations - * @param bool|array $price_var_percent Is the price variation a relative variation? - * @param bool|float $forced_pricevar If the price variation is forced - * @param bool|float $forced_weightvar If the weight variation is forced - * @param bool|string $forced_refvar If the reference is forced - * @param string $ref_ext External reference - * @return int <0 KO, >0 OK + * @param User $user Object user + * @param Product $product Parent product + * @param array $combinations Attribute and value combinations. + * @param array $variations Price and weight variations + * @param bool|array $price_var_percent Is the price variation a relative variation? + * @param bool|float|array $forced_pricevar If the price variation is forced + * @param bool|float $forced_weightvar If the weight variation is forced + * @param bool|string $forced_refvar If the reference is forced + * @param string $ref_ext External reference + * @return int <0 KO, >0 OK */ public function createProductCombination(User $user, Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false, $forced_refvar = false, $ref_ext = '') { @@ -752,8 +752,8 @@ class ProductCombination $price_impact = $forced_pricevar; } - if (!array($price_var_percent)) { - $price_var_percent[1] = (float) $price_var_percent; + if (!is_array($price_var_percent)) { + $price_var_percent = array(1 => (float) $price_var_percent); } $newcomb = new ProductCombination($this->db); @@ -840,12 +840,7 @@ class ProductCombination $productCombinationLevel->fk_product_attribute_combination = $newcomb->id; $productCombinationLevel->fk_price_level = $i; $productCombinationLevel->variation_price = $price_impact[$i]; - - if (is_array($price_var_percent)) { - $productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]); - } else { - $productCombinationLevel->variation_price_percentage = $price_var_percent; - } + $productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]); $newcomb->combination_price_levels[$i] = $productCombinationLevel; } @@ -955,13 +950,26 @@ class ProductCombination $variations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val; } + $variation_price_percentage = $combination->variation_price_percentage; + $variation_price = $combination->variation_price; + + if (getDolGlobalInt('PRODUIT_MULTIPRICES') && getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT') > 1) { + $variation_price_percentage = [ ]; + $variation_price = [ ]; + + foreach ($combination->combination_price_levels as $productCombinationLevel) { + $variation_price_percentage[$productCombinationLevel->fk_price_level] = $productCombinationLevel->variation_price_percentage; + $variation_price[$productCombinationLevel->fk_price_level] = $productCombinationLevel->variation_price; + } + } + if ($this->createProductCombination( $user, $destProduct, $variations, array(), - $combination->variation_price_percentage, - $combination->variation_price, + $variation_price_percentage, + $variation_price, $combination->variation_weight ) < 0) { return -1; From 3ef6299c839aa0e1ae473e65942a6ace54dc6644 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:20:57 +0100 Subject: [PATCH 079/110] FIX: phpcs --- htdocs/variants/class/ProductCombination.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index fa642dc2765..e41325f6efb 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -950,8 +950,8 @@ class ProductCombination $variations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val; } - $variation_price_percentage = $combination->variation_price_percentage; - $variation_price = $combination->variation_price; + $variation_price_percentage = $combination->variation_price_percentage; + $variation_price = $combination->variation_price; if (getDolGlobalInt('PRODUIT_MULTIPRICES') && getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT') > 1) { $variation_price_percentage = [ ]; From ef564caf28bafb827aec71697e58f2a0e4302fca Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:37:30 +0100 Subject: [PATCH 080/110] FIX: qual --- htdocs/variants/class/ProductCombination.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index e41325f6efb..163ea7be5bd 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -753,7 +753,7 @@ class ProductCombination } if (!is_array($price_var_percent)) { - $price_var_percent = array(1 => (float) $price_var_percent); + $price_var_percent = array(1 => (bool) $price_var_percent); } $newcomb = new ProductCombination($this->db); @@ -840,7 +840,7 @@ class ProductCombination $productCombinationLevel->fk_product_attribute_combination = $newcomb->id; $productCombinationLevel->fk_price_level = $i; $productCombinationLevel->variation_price = $price_impact[$i]; - $productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]); + $productCombinationLevel->variation_price_percentage = $price_var_percent[$i]; $newcomb->combination_price_levels[$i] = $productCombinationLevel; } From 273ec857a3b0dd60b8ff49dc50ada418ef69d0fd Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 7 Jan 2025 18:35:58 +0100 Subject: [PATCH 081/110] Fix : cron job user rights force reload --- scripts/cron/cron_run_jobs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index ec8abcdea80..3174b0eae7f 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -210,7 +210,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) { exit(-1); } } - $user->getrights(); + $user->getrights('', 1); // We force rights reload to have the correct permissions for user in the entity we just switched in } // Reload langs From 7e82f70c77aa42718cb6009d72cb5d806ca7175e Mon Sep 17 00:00:00 2001 From: tnegre Date: Thu, 9 Jan 2025 11:05:45 +0100 Subject: [PATCH 082/110] add case when HTML tags contain attributes --- htdocs/includes/odtphp/odf.php | 4 ++-- test/phpunit/ODFTest.php | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index f5678d838a3..39f595f4934 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -46,8 +46,8 @@ class Odf public $userdefined=array(); const PIXEL_TO_CM = 0.026458333; - const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1>).)*)<\/\1>))/s'; - const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1>).)*)<\/\1>))/'; + const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1(\s.*)?>).)*)<\/\1>))/s'; + const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1(\s.*)?>).)*)<\/\1>))/'; /** diff --git a/test/phpunit/ODFTest.php b/test/phpunit/ODFTest.php index ab1a2c74d48..2badd77baf6 100644 --- a/test/phpunit/ODFTest.php +++ b/test/phpunit/ODFTest.php @@ -302,33 +302,39 @@ class ODFTest extends PHPUnit\Framework\TestCase 'charset' => null, 'expected' => utf8_encode('text with two (strong) tags'), ], + 25 => [ + 'to_convert' => "text with two (strong) tags and intricated underline ", + 'encode' => true, + 'charset' => null, + 'expected' => utf8_encode('text with two (strong) tags and intricated underline '), + ], // One can also pass html-encoded string to the method - 25 => [ + 26 => [ 'to_convert' => 'One&two', 'encode' => true, 'charset' => null, 'expected' => 'One&two', ], - 26 => [ + 27 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => false, 'charset' => 'UTF-8', 'expected' => 'text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l\'', ], - 27 => [ + 28 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => true, 'charset' => 'UTF-8', 'expected' => 'text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l'', ], - 28 => [ + 29 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => false, 'charset' => null, 'expected' => utf8_encode('text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l\''), ], - 29 => [ + 30 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => true, 'charset' => null, @@ -347,20 +353,20 @@ class ODFTest extends PHPUnit\Framework\TestCase // Following tests reflect the current behavior. They may evolve if the method behavior changes. // The method removes hyperlinks and tags that are not dealt with. - 30 => [ + 31 => [ 'to_convert' => '123 trucmachin > truc < troc > tracbla bla', 'encode' => true, 'charset' => null, 'expected' => "123 trucmachin > truc < troc > tracbla bla", ], - 31 => [ + 32 => [ 'to_convert' => '123

Title

bla', 'encode' => true, 'charset' => null, 'expected' => "123 Title bla", ], // HTML should not take \n into account, but only
. - 32 => [ + 33 => [ 'to_convert' => "text with strong text , a line\nbreak and underlined words with it@lic sp&ciàlchärs éè l'", 'encode' => false, 'charset' => 'UTF-8', From 0912b3b04f026f668a527cc99cbbc9ccf341752e Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Thu, 9 Jan 2025 15:04:37 +0100 Subject: [PATCH 083/110] fix selectcontacts param --- htdocs/comm/action/card.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 99d330b745a..0310ac0b225 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1181,8 +1181,14 @@ if ($action == 'create') { $preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int'); } if ($origin=='contact') $preselectedids[GETPOST('originid', 'int')] = GETPOST('originid', 'int'); + // select "all" or "none" contact by default + 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"'); - print $form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); + print $form->selectcontacts(GETPOSTISSET('socid') ? GETPOSTINT('socid') : $select_contact_default, $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); print '
'; } From 77f982d1a8c3fa490c40c95e06d39f51731da055 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 10 Jan 2025 16:25:27 +0100 Subject: [PATCH 084/110] 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 085/110] 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 ac1077bfe32712d293527f9b22dc4c8f2d934041 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 14 Jan 2025 09:48:13 +0100 Subject: [PATCH 086/110] FIX : There were many status indicator in the invoice linked object block (propal card) --- htdocs/compta/facture/tpl/linkedobjectblock.tpl.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index c002e5a7e5f..071403509dd 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -89,11 +89,8 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $totalallpayments = 0; $totalcalculated = false; if (method_exists($objectlink, 'getSommePaiement')) { - print $objectlink->getLibStatut(3, $objectlink->getSommePaiement()); $totalcalculated = true; $totalallpayments += $objectlink->getSommePaiement(); - } else { - print $objectlink->getLibStatut(3); } if (method_exists($objectlink, 'getSumDepositsUsed')) { $totalcalculated = true; 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 087/110] 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 088/110] 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 79ed9c7e370cec7000434bcc7c6fdfccc4d55d40 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 14 Jan 2025 16:08:40 +0100 Subject: [PATCH 089/110] fix: add entity in where for fetch when fetch by ref --- htdocs/expensereport/class/expensereport.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 8af62d14736..32dc9b9a25b 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -619,6 +619,7 @@ class ExpenseReport extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d"; if ($ref) { $sql .= " WHERE d.ref = '".$this->db->escape($ref)."'"; + $sql .= " WHERE d.entity IN (".getEntity('expensereport').")"; } else { $sql .= " WHERE d.rowid = ".((int) $id); } From 9af7eaf08ccae30b58c010754db5f5b89e9ea3f0 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 14 Jan 2025 15:32:08 +0100 Subject: [PATCH 090/110] Use PHP version from check.php --- .github/workflows/pre-commit.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 1ae4d3387f8..973b2ddbc13 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -62,6 +62,12 @@ jobs: # files: | # **.php + - name: Extract PHP version + id: extract-php-version + run: | + PHP_VERSION=$(sed -n 's/.*\$arrayphpmaxversionwarning\s*=\s*array\s*(\s*\([0-9]\+\)\s*,\s*\([0-9]\+\).*/\1.\2/p' htdocs/install/check.php) + echo "PHP_VERSION=$PHP_VERSION" >> $GITHUB_ENV + - name: Setup PHPCS uses: shivammathur/setup-php@v2 # Install when we're going to run phpcs @@ -76,7 +82,7 @@ jobs: ) ) with: - php-version: 8.1 + php-version: ${{ env.PHP_VERSION }} # Version from check.php coverage: none # disable xdebug, pcov tools: phpcs From 7869e45954684977b0104d3ac6ade8293c52e919 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 14 Jan 2025 15:39:05 +0100 Subject: [PATCH 091/110] Move installation of php before pre-commit run --- .github/workflows/pre-commit.yml | 39 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 973b2ddbc13..d83f237e09c 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -42,25 +42,6 @@ jobs: with: path: ~/.cache/pre-commit/ key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} - # Run all the precommit tools (defined into pre-commit-config.yaml). - # We can force exclusion of some of them here. - - name: Run pre-commit hooks - env: - # SKIP is used by pre-commit to not execute certain hooks - SKIP: no-commit-to-branch,php-cs,php-cbf,trailing-whitespace,end-of-file-fixer,check-json,check-executables-have-shebangs,check-shebang-scripts-are-executable,beautysh,yamllint,shellcheck - run: | - set -o pipefail - pre-commit gc - pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG} - - # The next uses git, which is slow for a bit repo. - # - name: Get all changed php files (if PR) - # id: changed-php - # uses: tj-actions/changed-files@v42 - # if: github.event_name == 'pull_request' - # with: - # files: | - # **.php - name: Extract PHP version id: extract-php-version @@ -86,6 +67,26 @@ jobs: coverage: none # disable xdebug, pcov tools: phpcs + # Run all the precommit tools (defined into pre-commit-config.yaml). + # We can force exclusion of some of them here. + - name: Run pre-commit hooks + env: + # SKIP is used by pre-commit to not execute certain hooks + SKIP: no-commit-to-branch,php-cs,php-cbf,trailing-whitespace,end-of-file-fixer,check-json,check-executables-have-shebangs,check-shebang-scripts-are-executable,beautysh,yamllint,shellcheck + run: | + set -o pipefail + pre-commit gc + pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG} + + # The next uses git, which is slow for a bit repo. + # - name: Get all changed php files (if PR) + # id: changed-php + # uses: tj-actions/changed-files@v42 + # if: github.event_name == 'pull_request' + # with: + # files: | + # **.php + - name: Run some pre-commit hooks on selected changed files only if: steps.changed-php.outputs.any_changed == 'true' env: From 20f2293c013f27c29f557364148135e9ad0528ab Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 14 Jan 2025 15:43:55 +0100 Subject: [PATCH 092/110] Always install expected php version --- .github/workflows/pre-commit.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index d83f237e09c..ddf13c8a070 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -51,17 +51,7 @@ jobs: - name: Setup PHPCS uses: shivammathur/setup-php@v2 - # Install when we're going to run phpcs - if: | - steps.changed-php.outputs.any_changed == 'true' - || - ( - github.event_name == 'push' - && ( - github.event.ref == 'refs/heads/develop' - || endsWith(github.event.ref, '.0') - ) - ) + # Install proper php version, and also install phpcs which may be needed with: php-version: ${{ env.PHP_VERSION }} # Version from check.php coverage: none # disable xdebug, pcov From a34eaa07ed7a7491c82ddb92246c429487ccdf85 Mon Sep 17 00:00:00 2001 From: Irvine Fleith Date: Tue, 14 Jan 2025 16:19:52 +0100 Subject: [PATCH 093/110] 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 2d1d6f13c9b4fe4c0fe3fb705fd9e17a071b3f26 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 15 Jan 2025 09:10:11 +0100 Subject: [PATCH 094/110] chore: review --- htdocs/expensereport/class/expensereport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 32dc9b9a25b..0a4e590ca79 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -619,7 +619,7 @@ class ExpenseReport extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d"; if ($ref) { $sql .= " WHERE d.ref = '".$this->db->escape($ref)."'"; - $sql .= " WHERE d.entity IN (".getEntity('expensereport').")"; + $sql .= " AND d.entity IN (".getEntity('expensereport').")"; } else { $sql .= " WHERE d.rowid = ".((int) $id); } From 748dcd088136882906f855de955e1d4a882721d5 Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Wed, 15 Jan 2025 10:12:16 +0100 Subject: [PATCH 095/110] 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 ''; print ''; From 628189f57f6ecdd89d27d29df65ee35d5a9fd627 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 00:49:59 +0200 Subject: [PATCH 096/110] 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 351a7bd6bb81b07b058585e852cbce1bc386c5f2 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Wed, 15 Jan 2025 19:01:18 +0100 Subject: [PATCH 097/110] FIX: #26250 fatal error on kit --- htdocs/product/class/product.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e289762d2a5..ea9c7f6b830 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5016,7 +5016,8 @@ class Product extends CommonObject //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); if (empty($firstlevelonly)) { - $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1, array_push($parents, $rec['rowid'])); + array_push($parents, $rec['rowid']); + $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1, $parents); foreach ($listofchilds as $keyChild => $valueChild) { $prods[$rec['rowid']]['childs'][$keyChild] = $valueChild; } 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 098/110] 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 099/110] 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 100/110] 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 101/110] 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 102/110] 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 a52a218ae42f0e8114ec44591780026855391f02 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Thu, 16 Jan 2025 19:17:47 +0100 Subject: [PATCH 103/110] Use same patch like in #26454 --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ea9c7f6b830..4860fe9c34a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5016,7 +5016,7 @@ class Product extends CommonObject //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); if (empty($firstlevelonly)) { - array_push($parents, $rec['rowid']); + $parents[] = $rec['rowid']; $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1, $parents); foreach ($listofchilds as $keyChild => $valueChild) { $prods[$rec['rowid']]['childs'][$keyChild] = $valueChild; 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 104/110] 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) { From 426f4305b05c6696994a8ebce17b4c4b7d6b6ac2 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Mon, 20 Jan 2025 11:48:37 +0100 Subject: [PATCH 105/110] FIX delete supplier order when at least one line linked to customer order line --- htdocs/fourn/class/fournisseur.commande.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b98f14aa074..60b6f98f0cf 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2312,6 +2312,16 @@ class CommandeFournisseur extends CommonOrder $error++; } + if (!$error) { + $sql1 = 'UPDATE '.$this->db->prefix()."commandedet SET fk_commandefourndet = NULL WHERE fk_commandefourndet IN (SELECT rowid FROM ".$main." WHERE fk_commande = ".((int) $this->id).")"; + dol_syslog(__METHOD__." linked order lines", LOG_DEBUG); + if (!$this->db->query($sql1)) { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); + } + } + $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande =".((int) $this->id); dol_syslog(get_class($this)."::delete", LOG_DEBUG); if (!$this->db->query($sql)) { From 7f2a253625148d02dc94a2513e2a8251020e8c3f Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Mon, 20 Jan 2025 12:17:12 +0100 Subject: [PATCH 106/110] Uniformize SQL concat char --- htdocs/fourn/class/fournisseur.commande.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 60b6f98f0cf..6ad989bceb5 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2313,7 +2313,7 @@ class CommandeFournisseur extends CommonOrder } if (!$error) { - $sql1 = 'UPDATE '.$this->db->prefix()."commandedet SET fk_commandefourndet = NULL WHERE fk_commandefourndet IN (SELECT rowid FROM ".$main." WHERE fk_commande = ".((int) $this->id).")"; + $sql1 = "UPDATE ".$this->db->prefix()."commandedet SET fk_commandefourndet = NULL WHERE fk_commandefourndet IN (SELECT rowid FROM ".$main." WHERE fk_commande = ".((int) $this->id).")"; dol_syslog(__METHOD__." linked order lines", LOG_DEBUG); if (!$this->db->query($sql1)) { $error++; @@ -4147,7 +4147,7 @@ class CommandeFournisseurLigne extends CommonOrderLine return -1; } - $sql1 = 'UPDATE '.MAIN_DB_PREFIX."commandedet SET fk_commandefourndet = NULL WHERE fk_commandefourndet=".((int) $this->id); + $sql1 = "UPDATE ".MAIN_DB_PREFIX."commandedet SET fk_commandefourndet = NULL WHERE fk_commandefourndet=".((int) $this->id); $resql = $this->db->query($sql1); if (!$resql) { $this->db->rollback(); From 576e70c3ce95da7511ce3c13f6b501c7a56d3d4c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 20 Jan 2025 22:32:30 +0100 Subject: [PATCH 107/110] FIX wrong update function parameter --- htdocs/fourn/class/api_supplier_invoices.class.php | 2 +- htdocs/ticket/class/api_tickets.class.php | 2 +- htdocs/zapier/class/api_zapier.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 13dc0e8b094..1614552ee5c 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -272,7 +272,7 @@ class SupplierInvoices extends DolibarrApi $this->invoice->$field = $value; } - if ($this->invoice->update($id, DolibarrApiAccess::$user)) { + if ($this->invoice->update(DolibarrApiAccess::$user)) { return $this->get($id); } diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 62f94b2491b..a40e54934a1 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -389,7 +389,7 @@ class Tickets extends DolibarrApi $this->ticket->$field = $value; } - if ($this->ticket->update($id, DolibarrApiAccess::$user)) { + if ($this->ticket->update(DolibarrApiAccess::$user)) { return $this->get($id); } diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index 5ff155aebf0..2ed4e984126 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -300,7 +300,7 @@ class Zapier extends DolibarrApi $this->hook->$field = $value; } - if ($this->hook->update($id, DolibarrApiAccess::$user) > 0) { + if ($this->hook->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); } else { throw new RestException(500, $this->hook->error); From cbe15c7c71059ad25315533d60d52dc973e93bba Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Wed, 22 Jan 2025 23:53:16 +0100 Subject: [PATCH 108/110] missing hookmanager like others doc_generic*odt modules --- .../project/task/doc/doc_generic_task_odt.modules.php | 8 ++++++++ .../core/modules/societe/doc/doc_generic_odt.modules.php | 1 + .../mymodule/doc/doc_generic_myobject_odt.modules.php | 5 +++++ .../doc_generic_recruitmentjobposition_odt.modules.php | 5 +++++ 4 files changed, 19 insertions(+) diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 51e53e21d3f..f2cb1eddb78 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -469,6 +469,14 @@ class doc_generic_task_odt extends ModelePDFTask return -1; } + // Add odtgeneration hook + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } + $hookmanager->initHooks(array('odtgeneration')); + global $action; + if (!is_object($outputlangs)) { $outputlangs = $langs; } diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 374c44c7a25..49ce657fce7 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -216,6 +216,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); + global $action; if (!is_object($outputlangs)) { $outputlangs = $langs; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index e35fb604cec..680cf49de6b 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -233,7 +233,12 @@ class doc_generic_myobject_odt extends ModelePDFMyObject } // Add odtgeneration hook + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } $hookmanager->initHooks(array('odtgeneration')); + global $action; if (!is_object($outputlangs)) { $outputlangs = $langs; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index da7640d708a..128293c9d85 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -221,7 +221,12 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi } // Add odtgeneration hook + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } $hookmanager->initHooks(array('odtgeneration')); + global $action; if (!is_object($outputlangs)) { $outputlangs = $langs; From c7ee83b3b9164e33288ee0c925c054c5496c7adc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 27 Jan 2025 10:33:38 +0100 Subject: [PATCH 109/110] FIX can not delete files in task card --- htdocs/core/lib/files.lib.php | 1 + htdocs/projet/tasks/task.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 2ed990205ad..ee9b55b21c3 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1448,6 +1448,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, } } } else { + $ok = false; // to avoid false positive dol_syslog("No files to delete found", LOG_DEBUG); } } else { diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index b8ff5a6f9bc..4f1ca11848b 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -65,7 +65,10 @@ if ($reshook < 0) { } if ($id > 0 || $ref) { - $object->fetch($id, $ref); + $ret = $object->fetch($id, $ref); + if ($ret > 0) { + $projectstatic->fetch($object->fk_project); + } } // Security check @@ -204,14 +207,14 @@ if ($action == 'remove_file' && $user->rights->projet->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load("other"); - $upload_dir = $conf->project->dir_output; + $upload_dir = $conf->project->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file')); $ret = dol_delete_file($file); if ($ret) { - setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); } else { - setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); } } @@ -222,7 +225,6 @@ if ($action == 'remove_file' && $user->rights->projet->creer) { $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); -$result = $projectstatic->fetch($object->fk_project); $title = $object->ref; if (!empty($withproject)) { @@ -692,7 +694,7 @@ if ($id > 0 || !empty($ref)) { /* * Generated documents */ - $filename = dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); + $filename = ''; $filedir = $conf->project->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = ($user->rights->projet->lire); From 837b2ff06079da158c049a72d583e0879e858a02 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 27 Jan 2025 13:59:12 +0100 Subject: [PATCH 110/110] FIX wrong left margin (v18 to develop ?) --- htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 555079ad3bc..a56088b5a40 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -317,7 +317,7 @@ class pdf_soleil extends ModelePDFFicheinter $desc = dol_htmlentitiesbr($text, 1); //print $outputlangs->convToOutputCharset($desc); exit; - $pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1); + $pdf->writeHTMLCell(180, 3, $this->posxdesc - 1, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1); $nexY = $pdf->GetY(); $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
'.$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 '