From d8c51e712dc1783432ec3b2bb80adb4783385214 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 12 Apr 2023 10:17:13 +0200 Subject: [PATCH 01/16] FIX reassortlot search categorie + add inihook --- htdocs/product/reassortlot.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 65e69b91384..437b698435e 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -88,6 +88,8 @@ if ($user->socid) { } $result = restrictedArea($user, 'produit|service', 0, 'product&product'); +$hookmanager->initHooks(array('reassortlotlist')); + /* * Actions @@ -135,11 +137,11 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e on ps.fk_entrepot = e.rowid' $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_batch as pb on pb.fk_product_stock = ps.rowid'; // Detail for each lot on each warehouse $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch'; // Link on unique key // We'll need this table joined to the select in order to filter by categ -if ($search_categ) { +if ($search_categ > 0) { $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; } $sql .= " WHERE p.entity IN (".getEntity('product').")"; -if ($search_categ) { +if ($search_categ > 0) { $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ } if ($sall) { @@ -178,7 +180,7 @@ if ($fourn_id > 0) { $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".((int) $fourn_id); } // Insert categ filter -if ($search_categ) { +if ($search_categ > 0) { $sql .= " AND cp.fk_categorie = ".((int) $search_categ); } if ($search_warehouse) { @@ -277,7 +279,7 @@ if ($resql) { if ($search_sale) { $param .= "&search_sale=".urlencode($search_sale); } - if ($search_categ) { + if ($search_categ > 0) { $param .= "&search_categ=".urlencode($search_categ); } /*if ($eatby) $param.="&eatby=".$eatby; From 7c996e97fdb20194c41c0e78d8449510f9a698c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Fali=C3=A8re?= Date: Tue, 9 May 2023 15:45:52 +0200 Subject: [PATCH 02/16] FIX broken feature : send private message by email --- htdocs/core/class/html.formticket.class.php | 73 +++++++++++---------- htdocs/theme/eldy/timeline.inc.php | 3 +- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 08ccfc10190..cb5a1aacc0f 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1345,44 +1345,51 @@ class FormTicket $send_email = GETPOST('send_email', 'int') ? GETPOST('send_email', 'int') : 0; - // Example 1 : Adding jquery code - print ''; + }'; + + // If constant set, allow to send private messages as email + if (empty($conf->global->TICKET_SEND_PRIVATE_EMAIL)) { + print 'jQuery("#send_msg_email").click(function() { + if(jQuery(this).is(":checked")) { + if (jQuery("#private_message").is(":checked")) { + jQuery("#private_message").prop("checked", false).trigger("change"); + } + jQuery(".email_line").show(); + } + else { + jQuery(".email_line").hide(); + } + }); + + jQuery("#private_message").click(function() { + if (jQuery(this).is(":checked")) { + if (jQuery("#send_msg_email").is(":checked")) { + jQuery("#send_msg_email").prop("checked", false).trigger("change"); + } + jQuery(".email_line").hide(); + } + });'; + } + + print '}); + '; + + print '
'; print ''; diff --git a/htdocs/theme/eldy/timeline.inc.php b/htdocs/theme/eldy/timeline.inc.php index 84d486817b1..a4fa4ee29b3 100644 --- a/htdocs/theme/eldy/timeline.inc.php +++ b/htdocs/theme/eldy/timeline.inc.php @@ -62,7 +62,8 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { position: relative; } -.timeline > li.timeline-code-ticket_msg_private > .timeline-item { +.timeline > li.timeline-code-ticket_msg_private > .timeline-item, +.timeline > li.timeline-code-ticket_msg_private_sentbymail > .timeline-item { background: #fffbe5; border-color: #d0cfc0; } From 7ae43d7872ce7143e2c51b235fcccfc7ffd1900d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 9 May 2023 14:18:54 +0000 Subject: [PATCH 03/16] Fixing style errors. --- htdocs/core/class/html.formticket.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index cb5a1aacc0f..c83becab676 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1363,8 +1363,8 @@ class FormTicket }'; // If constant set, allow to send private messages as email - if (empty($conf->global->TICKET_SEND_PRIVATE_EMAIL)) { - print 'jQuery("#send_msg_email").click(function() { + if (empty($conf->global->TICKET_SEND_PRIVATE_EMAIL)) { + print 'jQuery("#send_msg_email").click(function() { if(jQuery(this).is(":checked")) { if (jQuery("#private_message").is(":checked")) { jQuery("#private_message").prop("checked", false).trigger("change"); @@ -1384,12 +1384,12 @@ class FormTicket jQuery(".email_line").hide(); } });'; - } + } print '}); '; - - + + print ''; print ''; From bfe7cd76c273efaa5d3320fa306ae72b0c4b1784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Tue, 9 May 2023 17:12:09 +0200 Subject: [PATCH 04/16] FIX: No error message because $price_ht_devise is equal to 0 if not fill because of price2num --- htdocs/supplier_proposal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 8d100370a00..072e1bfdf5b 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -586,7 +586,7 @@ if (empty($reshook)) { $error++; } - if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal. + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && GETPOST('multicurrency_price_ht') === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPrice")), null, 'errors'); $error++; } From 07bec30c32b9a758ed01fd7d55ff47e4961ed504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Thu, 11 May 2023 11:10:33 +0200 Subject: [PATCH 05/16] FIX: Task events not displayed --- htdocs/projet/tasks/task.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index f163af75cae..6fb8f07d0a6 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -644,8 +644,7 @@ if ($id > 0 || !empty($ref)) { // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $defaultthirdpartyid = $socid > 0 ? $socid : $object->project->socid; - $formactions->showactions($object, 'task', $defaultthirdpartyid, 1, '', 10, 'withproject='.$withproject); + $formactions->showactions($object, 'project_task', 0, 1, '', 10, 'withproject='.$withproject); print ''; } From 0531f9a8535e5488f3f66369edfbde9f3fae3e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Wed, 17 May 2023 10:56:15 +0200 Subject: [PATCH 06/16] FIX: Missing error message display on insertExtrafields() --- htdocs/fichinter/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index ab08d5c04f8..7d8e1583c2d 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -721,6 +721,7 @@ if (empty($reshook)) { // Actions on extra fields $result = $object->insertExtraFields('INTERVENTION_MODIFY'); if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); $error++; } } From 76de309cd92a73df24bb4895ff95a1c904df7c40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 17 May 2023 14:23:14 +0200 Subject: [PATCH 07/16] FIX error management on emoji and utf8 validity by emailcollector --- htdocs/core/lib/functions.lib.php | 16 ++++++++ .../class/emailcollector.class.php | 38 +++++++++++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 03783e37561..eb72e2ed8c8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8794,6 +8794,22 @@ function utf8_check($str) return true; } +/** + * Check if a string is in UTF8 + * + * @param string $str String to check + * @return boolean True if string is valid UTF8 string, false if corrupted + */ +function utf8_valid($str) +{ + /* 2 other methods to test if string is utf8 + $validUTF8 = mb_check_encoding($messagetext, 'UTF-8'); + $validUTF8b = ! (false === mb_detect_encoding($messagetext, 'UTF-8', true)); + */ + return preg_match('//u', $str) ? true : false; +} + + /** * Check if a string is in ASCII * diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 85a0d6e4332..e3c96752691 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -996,8 +996,10 @@ class EmailCollector extends CommonObject } else { // Nothing can be done for this param $errorforthisaction++; - $this->error = 'The extract rule to use has on an unknown source (must be HEADER, SUBJECT or BODY)'; + $this->error = 'The extract rule to use to overwrite properties has on an unknown source (must be HEADER, SUBJECT or BODY)'; $this->errors[] = $this->error; + + $operationslog .= '
'.$this->error; } } elseif (preg_match('/^(SET|SETIFEMPTY):(.*)$/', $valueforproperty, $regforregex)) { $valuecurrent = ''; @@ -1750,7 +1752,15 @@ class EmailCollector extends CommonObject //$htmlmsg,$plainmsg,$charset,$attachments $messagetext = $plainmsg ? $plainmsg : dol_string_nohtmltag($htmlmsg, 0); // Removed emojis - $messagetext = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $messagetext); + + if (utf8_valid($messagetext)) { + //$messagetext = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $messagetext); + $messagetext = $this->removeEmoji($messagetext); + } else { + $operationslog .= '
Discarded - Email body is not valid utf8'; + dol_syslog(" Discarded - Email body is not valid utf8"); + continue; // Exclude email + } if ($searchfilterexcludebody) { if (preg_match('/'.preg_quote($searchfilterexcludebody, '/').'/ms', $messagetext)) { @@ -2264,8 +2274,10 @@ class EmailCollector extends CommonObject } else { // Nothing can be done for this param $errorforactions++; - $this->error = 'The extract rule to use to load thirdparty has an unknown source (must be HEADER, SUBJECT or BODY)'; + $this->error = 'The extract rule to use to load thirdparty for email '.$msgid.' has an unknown source (must be HEADER, SUBJECT or BODY)'; $this->errors[] = $this->error; + + $operationslog .= '
'.$this->error; } } elseif (preg_match('/^(SET|SETIFEMPTY):(.*)$/', $valueforproperty, $reg)) { //if (preg_match('/^options_/', $tmpproperty)) $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $reg[1]; @@ -3378,4 +3390,24 @@ class EmailCollector extends CommonObject return $subject; } + + /** + * Remove EMoji from email content + * + * @param string $text String to sanitize + * @return string Sanitized string + */ + protected function removeEmoji($text) + { + // Supprimer les caractères emoji en utilisant une expression régulière + $text = preg_replace('/[\x{1F600}-\x{1F64F}]/u', '', $text); + $text = preg_replace('/[\x{1F300}-\x{1F5FF}]/u', '', $text); + $text = preg_replace('/[\x{1F680}-\x{1F6FF}]/u', '', $text); + $text = preg_replace('/[\x{2600}-\x{26FF}]/u', '', $text); + $text = preg_replace('/[\x{2700}-\x{27BF}]/u', '', $text); + $text = preg_replace('/[\x{1F900}-\x{1F9FF}]/u', '', $text); + $text = preg_replace('/[\x{1F1E0}-\x{1F1FF}]/u', '', $text); + + return $text; + } } From 2ac7cb6a832578b48881acf48ae5945b904bd451 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Wed, 17 May 2023 17:07:18 +0200 Subject: [PATCH 08/16] fix : Warning: Undefined property: stdClass:: in /home/httpd/vhosts/aflac.fr/domains/dev.aflac.fr/httpdocs/core/lib/files.lib.php on line 3138 --- htdocs/core/lib/files.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 4240cd0ec45..3bafcedb645 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -3135,8 +3135,8 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $partsofdirinoriginalfile = explode('/', $original_file); if (!empty($partsofdirinoriginalfile[1])) { // If original_file is xxx/filename (xxx is a part we will use) $partofdirinoriginalfile = $partsofdirinoriginalfile[0]; - if ($partofdirinoriginalfile && !empty($fuser->rights->$modulepart->$partofdirinoriginalfile) && ($fuser->rights->$modulepart->$partofdirinoriginalfile->{$lire} || $fuser->rights->$modulepart->$partofdirinoriginalfile->{$read})) { - $accessallowed = 1; + if ($partofdirinoriginalfile && ($fuser->hasRight($modulepart, $partofdirinoriginalfile, 'lire') || $fuser->hasRight($modulepart, $partofdirinoriginalfile, 'read'))) { + $accessallowed = 1; } } if (!empty($fuser->rights->$modulepart->{$lire}) || !empty($fuser->rights->$modulepart->{$read})) { From a0953a53b304a4c6cf8bbbde47c84ab405b67b6d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 17 May 2023 15:11:36 +0000 Subject: [PATCH 09/16] Fixing style errors. --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 3bafcedb645..84b867bdb3e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -3136,7 +3136,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (!empty($partsofdirinoriginalfile[1])) { // If original_file is xxx/filename (xxx is a part we will use) $partofdirinoriginalfile = $partsofdirinoriginalfile[0]; if ($partofdirinoriginalfile && ($fuser->hasRight($modulepart, $partofdirinoriginalfile, 'lire') || $fuser->hasRight($modulepart, $partofdirinoriginalfile, 'read'))) { - $accessallowed = 1; + $accessallowed = 1; } } if (!empty($fuser->rights->$modulepart->{$lire}) || !empty($fuser->rights->$modulepart->{$read})) { From 4c7f54fc4136cba8bc1f9b6831343c15c626e167 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 17 May 2023 20:04:05 +0200 Subject: [PATCH 10/16] FIX Transfer between accounts with different currencies was broken --- htdocs/compta/bank/transfer.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 56a703d60f3..257b1282dfb 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -97,7 +97,7 @@ if ($action == 'add') { } else { if (!$amountto) { $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountToOthercurrency")), null, 'errors'); } } if ($amountto < 0) { @@ -183,7 +183,7 @@ llxHeader('', $title, $help_url); print '