From 8e427353e08c5ec6f18ce7a7adc948af2cf80f9c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Jan 2025 07:39:24 +0100 Subject: [PATCH 01/11] FIX avoid to show html entities --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 7c6ad95a23856..1b0b28bbb8334 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2063,7 +2063,7 @@ print ''; if (!empty($object->api_key)) { print ''; - print showValueWithClipboardCPButton($object->api_key, 1, $langs->trans("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste + print showValueWithClipboardCPButton($object->api_key, 1, $langs->transnoentities("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste print ''; } print ''; From 4934a335b0bed1d8a36c1808c606d119b277a42d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Jan 2025 10:09:23 +0100 Subject: [PATCH 02/11] FIX use transnoentities to avoid html entities --- htdocs/user/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 1b0b28bbb8334..b1f82031b6b75 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1211,7 +1211,7 @@ // We do not use a field password but a field text to show new password to use. $valuetoshow .= ($valuetoshow ? ' + '.$langs->trans("DolibarrPassword") : '').''; if (!empty($conf->use_javascript_ajax)) { - $valuetoshow .= img_picto($langs->trans('Generate'), 'refresh', 'id="generate_password" class="linkobject paddingleft"'); + $valuetoshow .= img_picto($langs->transnoentities('Generate'), 'refresh', 'id="generate_password" class="linkobject paddingleft"'); } } } @@ -1235,7 +1235,7 @@ print ''; print ''; if (!empty($conf->use_javascript_ajax)) { - print img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"'); + print img_picto($langs->transnoentities('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"'); } print ''; } else { @@ -2626,7 +2626,7 @@ if ($permissiontoeditpasswordandsee) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''; if (!empty($conf->use_javascript_ajax)) { - $valuetoshow .= img_picto((getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? $langs->trans('NoPasswordGenerationRuleConfigured') : $langs->trans('Generate')), 'refresh', 'id="generate_password" class="paddingleft'.(getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? ' opacitymedium' : ' linkobject').'"'); + $valuetoshow .= img_picto((getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? $langs->transnoentities('NoPasswordGenerationRuleConfigured') : $langs->transnoentities('Generate')), 'refresh', 'id="generate_password" class="paddingleft'.(getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? ' opacitymedium' : ' linkobject').'"'); } } else { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass); From 41b07d1630a9707f0cc201f70ef2b06cd98ee40a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Jan 2025 10:36:48 +0100 Subject: [PATCH 03/11] FIX compatibility with externals modules --- htdocs/user/card.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index b1f82031b6b75..9ee8f3d2b91ba 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1980,7 +1980,7 @@ print ''; // Date login validity - print ''.$langs->trans("RangeOfLoginValidity").''; + print ''.$langs->trans("RangeOfLoginValidity").''; print ''; if ($object->datestartvalidity) { print ''.$langs->trans("FromDate").' '; @@ -2043,9 +2043,9 @@ // Other form for user password $parameters = array('valuetoshow' => $valuetoshow, 'caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) { + if ($reshook === 1) { $valuetoshow = $hookmanager->resPrint; // to replace - } else { + } elseif (empty($reshook)) { $valuetoshow .= $hookmanager->resPrint; // to add } @@ -2057,6 +2057,11 @@ print ''."\n"; } + // for compatibility with externals modules + if ($reshook > 1) { + print $hookmanager->resPrint; + } + // API key if (isModEnabled('api') && ($user->id == $id || $user->admin || $user->hasRight("api", "apikey", "generate"))) { print ''.$langs->trans("ApiKey").''; From 7618df8726d9564d60b1f70cf28263e9fe1d2f05 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Jan 2025 11:04:32 +0100 Subject: [PATCH 04/11] FIX remove html entities --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 9ee8f3d2b91ba..816cd95db31b2 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2656,7 +2656,7 @@ if ($permissiontoeditpasswordandsee || $user->hasRight("api", "apikey", "generate")) { print ''; if (!empty($conf->use_javascript_ajax)) { - print img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"'); + print img_picto($langs->transnoentities('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"'); } } print ''; From 3f7d5cf790b9f5d074e02f71bd0301b3d0cff4c1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 00:33:51 +0100 Subject: [PATCH 05/11] NEW add hook 'addMoreInformationsBlock' --- htdocs/user/card.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 816cd95db31b2..84da02499553a 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2088,6 +2088,13 @@ print ''; print ''; + // Other informations block + $parameters = array('caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); + $reshook = $hookmanager->executeHooks('addMoreInformationsBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) { + print $hookmanager->resPrint; + } + print ''; print ''; From 8d11c1625f366601d5708631e2096c6494440c94 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 03:04:55 +0100 Subject: [PATCH 06/11] FIX wrong hook name --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 84da02499553a..3a5987bf59f6b 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2088,9 +2088,9 @@ print ''; print ''; - // Other informations block + // Other informations bloc $parameters = array('caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); - $reshook = $hookmanager->executeHooks('addMoreInformationsBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('addMoreInformationBloc', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook > 0) { print $hookmanager->resPrint; } From f8b957fd0d68a7366e44da455d2f7f5a1f5f5862 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 03:10:01 +0100 Subject: [PATCH 07/11] FIX tu veux ou tu veux pas ? --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 3a5987bf59f6b..7db5b6ba45406 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2090,7 +2090,7 @@ // Other informations bloc $parameters = array('caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); - $reshook = $hookmanager->executeHooks('addMoreInformationBloc', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('addMoreInformationBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook > 0) { print $hookmanager->resPrint; } From 5ab7e9ec3fdaa634de7e92d72cec94ed423bcbe6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 03:21:20 +0100 Subject: [PATCH 08/11] FIX use the right hook name --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 7db5b6ba45406..e2992a25f463b 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2088,9 +2088,9 @@ print ''; print ''; - // Other informations bloc + // Add more object block $parameters = array('caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); - $reshook = $hookmanager->executeHooks('addMoreInformationBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('addMoreObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook > 0) { print $hookmanager->resPrint; } From 3854719ee9fa46aff19ef75e5345f98ec0fd2290 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 06:58:51 +0100 Subject: [PATCH 09/11] FIX phpstan --- htdocs/public/payment/paymentko.php | 1 + htdocs/public/payment/paymentok.php | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index f8460f8a7990f..6c63bc291aba0 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -145,6 +145,7 @@ */ // Check if we have redirtodomain to do. +$doactionsthenredirect = 0; if ($ws) { $doactionsthenredirect = 1; } diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index b70871bdf2d0c..907d6fc050553 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -174,6 +174,7 @@ // Check if we have redirtodomain to do. $ws_virtuelhost = null; +$doactionsthenredirect = 0; if ($ws) { $doactionsthenredirect = 1; include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; From ef4697cba31b703933eb8ac640edd14534fe7369 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 16:54:21 +0100 Subject: [PATCH 10/11] FIX phpstan: wrong case --- htdocs/public/payment/newpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index fcff7afc7d61c..78f321ba80233 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -232,7 +232,7 @@ if ($ws && !defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { // So defined('USEEXTERNALSERVER') should be set but is not always include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; - $tmpwebsite = new WebSite($db); + $tmpwebsite = new Website($db); $tmpwebsite->fetch(0, $ws); $urlok = $tmpwebsite->virtualhost.'/public/payment/paymentok.php?'; $urlko = $tmpwebsite->virtualhost.'/public/payment/paymentko.php?'; From 62c543ef1782c7d26ae91785ddea1e3f75c54eda Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 23:34:45 +0100 Subject: [PATCH 11/11] FIX remove specific hook return --- htdocs/user/card.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index e2992a25f463b..d535cc0ddc6e3 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2043,9 +2043,9 @@ // Other form for user password $parameters = array('valuetoshow' => $valuetoshow, 'caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook === 1) { + if ($reshook > 0) { $valuetoshow = $hookmanager->resPrint; // to replace - } elseif (empty($reshook)) { + } else { $valuetoshow .= $hookmanager->resPrint; // to add } @@ -2057,11 +2057,6 @@ print ''."\n"; } - // for compatibility with externals modules - if ($reshook > 1) { - print $hookmanager->resPrint; - } - // API key if (isModEnabled('api') && ($user->id == $id || $user->admin || $user->hasRight("api", "apikey", "generate"))) { print ''.$langs->trans("ApiKey").'';