From 04a55a3df34a0e05a06315faeb851057e9138743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Wed, 7 Apr 2021 09:08:34 +0200 Subject: [PATCH 1/8] Fix #17146 --- htdocs/core/class/commondocgenerator.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index ec05ad5d98d..dfc324c1c00 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -465,7 +465,7 @@ abstract class CommonDocGenerator $array_key.'_total_localtax2'=>price2num($object->total_localtax2), $array_key.'_total_ttc'=>price2num($object->total_ttc), - $array_key.'_multicurrency_code' => price2num($object->multicurrency_code), + $array_key.'_multicurrency_code' => $object->multicurrency_code, $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), From 17fa9559a3037ce8cfd5e23143977705eec66db5 Mon Sep 17 00:00:00 2001 From: Indelog Date: Wed, 7 Apr 2021 09:29:40 +0200 Subject: [PATCH 2/8] Fix empty string WEBSITE_OTHERLANG If post WEBSITE_OTHERLANG with empty value or with value like this 'en,,sv' or 'en,sv,' we can get an otherlang with empty value. This can lead unexpected behaviour when we use an element of otherlang to set the subdirectory name to store pages for a sub lang. --- htdocs/core/lib/website2.lib.php | 4 +++- htdocs/website/class/website.class.php | 4 ++++ htdocs/website/index.php | 13 +++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 0258d3d2c05..e922087d0a9 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -104,10 +104,12 @@ function dolSavePageAlias($filealias, $object, $objectpage) } // Save also alias into all language subdirectories if it is a main language elseif (empty($objectpage->lang) || !in_array($objectpage->lang, explode(',', $object->otherlang))) { - if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR) && !empty($object->otherlang)) { + if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR)) { $dirname = dirname($filealias); $filename = basename($filealias); foreach (explode(',', $object->otherlang) as $sublang) { + // Avoid to erase main alias file if $sublang is empty string + if (empty(trim($sublang))) continue; $filealiassub = $dirname.'/'.$sublang.'/'.$filename; $aliascontent = 'otherlang); if (is_array($tmparray)) { foreach ($tmparray as $key => $val) { + // It possible we have empty val here if postparam WEBSITE_OTHERLANG is empty or set like this : 'en,,sv' or 'en,sv,' + if (empty(trim($sublang))) continue; $tmparray[$key] = preg_replace('/[_-].*$/', '', trim($val)); // en_US or en-US -> en } $this->otherlang = join(',', $tmparray); @@ -494,6 +496,8 @@ class Website extends CommonObject $tmparray = explode(',', $this->otherlang); if (is_array($tmparray)) { foreach ($tmparray as $key => $val) { + // It possible we have empty val here if postparam WEBSITE_OTHERLANG is empty or set like this : 'en,,sv' or 'en,sv,' + if (empty(trim($val))) continue; $tmparray[$key] = preg_replace('/[_-].*$/', '', trim($val)); // en_US or en-US -> en } $this->otherlang = join(',', $tmparray); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index ebcf31ad2c5..03ce856c2a1 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -551,6 +551,8 @@ if ($action == 'addsite') { $arrayotherlang = explode(',', GETPOST('WEBSITE_OTHERLANG', 'alphanohtml')); foreach ($arrayotherlang as $key => $val) { + // It possible we have empty val here if postparam WEBSITE_OTHERLANG is empty or set like this : 'en,,sv' or 'en,sv,' + if (empty(trim($val))) continue; $arrayotherlang[$key] = substr(trim($val), 0, 2); // Kept short language code only } @@ -1327,6 +1329,8 @@ if ($action == 'updatecss') { $arrayotherlang = explode(',', GETPOST('WEBSITE_OTHERLANG', 'alphanohtml')); foreach ($arrayotherlang as $key => $val) { + // It possible we have empty val here if postparam WEBSITE_OTHERLANG is empty or set like this : 'en,,sv' or 'en,sv,' + if (empty(trim($val))) continue; $arrayotherlang[$key] = substr(trim($val), 0, 2); // Kept short language code only } @@ -1768,6 +1772,10 @@ if ($action == 'updatemeta') $filename = basename($fileoldalias); $sublangs = explode(',', $object->otherlang); foreach ($sublangs as $sublang) { + // Under certain conditions $sublang can be an empty string + // ($object->otherlang with empty string or with string like this 'en,,sv') + // if is the case we try to re-delete the main alias file. Avoid it. + if (empty(trim($sublang))) continue; $fileoldaliassub = $dirname.'/'.$sublang.'/'.$filename; dol_delete_file($fileoldaliassub); } @@ -1790,6 +1798,10 @@ if ($action == 'updatemeta') $filename = basename($pathofwebsite.'/'.trim($tmpaliasalt).'.php'); $sublangs = explode(',', $object->otherlang); foreach ($sublangs as $sublang) { + // Under certain conditions $ sublang can be an empty string + // ($object->otherlang with empty string or with string like this 'en,,sv') + // if is the case we try to re-delete the main alias file. Avoid it. + if (empty(trim($sublang))) continue; $fileoldaliassub = $dirname.'/'.$sublang.'/'.$filename; dol_delete_file($fileoldaliassub); } @@ -2710,6 +2722,7 @@ if (!GETPOST('hide_websitemenu')) $onlylang[$website->lang] = $website->lang.' ('.$langs->trans("Default").')'; } foreach (explode(',', $website->otherlang) as $langkey) { + if (empty(trim($langkey))) continue; $onlylang[$langkey] = $langkey; } $textifempty = $langs->trans("Default"); From 426e846f5874240eedfb1c6460472cf750a5c851 Mon Sep 17 00:00:00 2001 From: Indelog Date: Wed, 7 Apr 2021 10:01:05 +0200 Subject: [PATCH 3/8] Fix website create/update empty otherlang Empty otherlang value was not correctly ignored. --- htdocs/website/class/website.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 1c402b82d34..966e0e8e4d8 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -185,7 +185,10 @@ class Website extends CommonObject if (is_array($tmparray)) { foreach ($tmparray as $key => $val) { // It possible we have empty val here if postparam WEBSITE_OTHERLANG is empty or set like this : 'en,,sv' or 'en,sv,' - if (empty(trim($sublang))) continue; + if (empty(trim($val))) { + unset($tmparray[$key]); + continue; + } $tmparray[$key] = preg_replace('/[_-].*$/', '', trim($val)); // en_US or en-US -> en } $this->otherlang = join(',', $tmparray); @@ -497,7 +500,10 @@ class Website extends CommonObject if (is_array($tmparray)) { foreach ($tmparray as $key => $val) { // It possible we have empty val here if postparam WEBSITE_OTHERLANG is empty or set like this : 'en,,sv' or 'en,sv,' - if (empty(trim($val))) continue; + if (empty(trim($val))) { + unset($tmparray[$key]); + continue; + } $tmparray[$key] = preg_replace('/[_-].*$/', '', trim($val)); // en_US or en-US -> en } $this->otherlang = join(',', $tmparray); From 113db33a24b3aea9dd4276dfae98bf220bae6a89 Mon Sep 17 00:00:00 2001 From: Pierre Payet Date: Wed, 7 Apr 2021 10:24:02 +0200 Subject: [PATCH 4/8] fix paiementfourn ref is now different from id --- htdocs/fourn/class/paiementfourn.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index bb0ecbcfa7c..78bfa6ebff2 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -83,7 +83,7 @@ class PaiementFourn extends Paiement * Load payment object * * @param int $id Id if payment to get - * @param string $ref Ref of payment to get (currently ref = id but this may change in future) + * @param string $ref Ref of payment to get * @param int $fk_bank Id of bank line associated to payment * @return int <0 if KO, -2 if not found, >0 if OK */ @@ -101,7 +101,7 @@ class PaiementFourn extends Paiement if ($id > 0) $sql .= ' AND p.rowid = '.$id; elseif ($ref) - $sql .= ' AND p.rowid = '.$ref; + $sql .= ' AND p.ref = '.$ref; elseif ($fk_bank) $sql .= ' AND p.fk_bank = '.$fk_bank; //print $sql; From d209dbe43ecbbe4982111e3ad4ea0e5598d954d2 Mon Sep 17 00:00:00 2001 From: Pierre Payet Date: Wed, 7 Apr 2021 11:01:51 +0200 Subject: [PATCH 5/8] add missing hooks in fourn invoice list --- htdocs/fourn/facture/list.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 317def67098..792fb91f980 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -419,6 +419,10 @@ if ($search_user > 0) $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= ' WHERE f.fk_soc = s.rowid'; $sql .= ' AND f.entity IN ('.getEntity('facture_fourn').')'; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -512,10 +516,19 @@ if (!$search_all) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : ''); } } + // Add GroupBy from hooks + $parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall); + $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; } else { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } +// Add HAVING from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; + $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; @@ -594,6 +607,10 @@ if ($resql) // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + // Add $param from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook + $param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array( From 11700f2162135b178b0587131957f7e2a4d3d9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Thu, 8 Apr 2021 13:52:29 +0200 Subject: [PATCH 6/8] Fix Ticket-Module public interface: uppercase/lowercaser in e-mail should be ignored #17186 --- htdocs/public/ticket/list.php | 12 ++++++------ htdocs/public/ticket/view.php | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 0f9542c986a..18bc0e83468 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -51,7 +51,7 @@ $langs->loadLangs(array("companies", "other", "ticket")); // Get parameters $track_id = GETPOST('track_id', 'alpha'); $action = GETPOST('action', 'aZ09'); -$email = GETPOST('email', 'alpha'); +$email = strtolower (GETPOST('email', 'alpha')); if (GETPOST('btn_view_ticket_list')) { unset($_SESSION['track_id_customer']); @@ -61,7 +61,7 @@ if (isset($_SESSION['track_id_customer'])) { $track_id = $_SESSION['track_id_customer']; } if (isset($_SESSION['email_customer'])) { - $email = $_SESSION['email_customer']; + $email = strtolower ($_SESSION['email_customer']); } $object = new Ticket($db); @@ -101,7 +101,7 @@ if ($action == "view_ticketlist") { // vérifie si l'adresse email est bien dans les contacts du ticket $contacts = $object->liste_contact(-1, 'external'); foreach ($contacts as $contact) { - if ($contact['email'] == $email) { + if (strtolower($contact['email']) == $email) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; $_SESSION['track_id_customer'] = $track_id; @@ -112,7 +112,7 @@ if ($action == "view_ticketlist") { } if ($object->fk_soc > 0) { $object->fetch_thirdparty(); - if ($email == $object->thirdparty->email) { + if ($email == strtolower($object->thirdparty->email)) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; $_SESSION['track_id_customer'] = $track_id; @@ -121,14 +121,14 @@ if ($action == "view_ticketlist") { if ($object->fk_user_create > 0) { $tmpuser = new User($db); $tmpuser->fetch($object->fk_user_create); - if ($email == $tmpuser->email) { + if ($email == strtolower($tmpuser->email)) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; $_SESSION['track_id_customer'] = $track_id; } } - $emailorigin = CMailFile::getValidAddress($object->origin_email, 2); + $emailorigin = strtolower(CMailFile::getValidAddress($object->origin_email, 2)); if ($email == $emailorigin) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index 02c7c9e51d8..cde872c56db 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -53,13 +53,13 @@ $langs->loadLangs(array("companies", "other", "ticket")); $track_id = GETPOST('track_id', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $action = GETPOST('action', 'aZ09'); -$email = GETPOST('email', 'alpha'); +$email = strtolower(GETPOST('email', 'alpha')); if (GETPOST('btn_view_ticket')) { unset($_SESSION['email_customer']); } if (isset($_SESSION['email_customer'])) { - $email = $_SESSION['email_customer']; + $email = strtolower($_SESSION['email_customer']); } $object = new ActionsTicket($db); @@ -103,7 +103,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a $ret = $object->fetch('', '', $track_id); if ($ret && $object->dao->id > 0) { // Check if emails provided is the one of author - $emailofticket = CMailFile::getValidAddress($object->dao->origin_email, 2); + $emailofticket = strtolower(CMailFile::getValidAddress($object->dao->origin_email, 2)); if ($emailofticket == $email) { $display_ticket = true; @@ -113,7 +113,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a else { $contacts = $object->dao->liste_contact(-1, 'external'); foreach ($contacts as $contact) { - if ($contact['email'] == $email) { + if (strtolower($contact['email']) == $email) { $display_ticket = true; $_SESSION['email_customer'] = $email; break; @@ -135,7 +135,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a { $tmpuser = new User($db); $tmpuser->fetch($object->dao->fk_user_create); - if ($email == $tmpuser->email) { + if ($email == strtolower($tmpuser->email)) { $display_ticket = true; $_SESSION['email_customer'] = $email; } @@ -145,7 +145,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a { $tmpuser = new User($db); $tmpuser->fetch($object->dao->fk_user_assign); - if ($email == $tmpuser->email) { + if ($email == strtolower($tmpuser->email)) { $display_ticket = true; $_SESSION['email_customer'] = $email; } From 0b1e3ce7e484f8c15ef77793d508b6b908443cf2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 8 Apr 2021 12:15:35 +0000 Subject: [PATCH 7/8] Fixing style errors. --- htdocs/public/ticket/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 18bc0e83468..4c426869239 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -51,7 +51,7 @@ $langs->loadLangs(array("companies", "other", "ticket")); // Get parameters $track_id = GETPOST('track_id', 'alpha'); $action = GETPOST('action', 'aZ09'); -$email = strtolower (GETPOST('email', 'alpha')); +$email = strtolower(GETPOST('email', 'alpha')); if (GETPOST('btn_view_ticket_list')) { unset($_SESSION['track_id_customer']); @@ -61,7 +61,7 @@ if (isset($_SESSION['track_id_customer'])) { $track_id = $_SESSION['track_id_customer']; } if (isset($_SESSION['email_customer'])) { - $email = strtolower ($_SESSION['email_customer']); + $email = strtolower($_SESSION['email_customer']); } $object = new Ticket($db); From 95d3dabdf693f406364f8b38b6d4a9eb1d72334b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 12:48:06 +0200 Subject: [PATCH 8/8] Update website2.lib.php --- htdocs/core/lib/website2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index e922087d0a9..cb96ed9ca43 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -104,7 +104,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) } // Save also alias into all language subdirectories if it is a main language elseif (empty($objectpage->lang) || !in_array($objectpage->lang, explode(',', $object->otherlang))) { - if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR)) { + if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR) && !empty($object->otherlang)) { $dirname = dirname($filealias); $filename = basename($filealias); foreach (explode(',', $object->otherlang) as $sublang) {