From 32aaab75b57e3d976e93452b1c532e4e29d0a1ff Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Wed, 10 Jul 2024 18:53:57 +0200 Subject: [PATCH 01/11] =?UTF-8?q?fix:=20hidden=20option=20MAIN=5FKEEP=5FRE?= =?UTF-8?q?F=5FCUSTOMER=5FON=5FCLONING=20always=20win=20on=20pr=E2=80=A6?= =?UTF-8?q?=20(#30340)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: hidden option MAIN_KEEP_REF_CUSTOMER_ON_CLONING always win on propal clone even if it's for enother customer * Update propal.class.php --------- Co-authored-by: Laurent Destailleur --- htdocs/comm/propal/class/propal.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6daca0f1c99..699ade8172a 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1415,7 +1415,9 @@ class Propal extends CommonObject } // reset ref_client - $object->ref_client = ''; + if (!getDolGlobalString('MAIN_KEEP_REF_CUSTOMER_ON_CLONING')) { + $object->ref_client = ''; + } // TODO Change product price if multi-prices } else { From 2335ea3067ba3ea8996731639369b26d9e000fb9 Mon Sep 17 00:00:00 2001 From: iouston <4319513+iouston@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:26:46 +0200 Subject: [PATCH 02/11] FIX public project form return an error if SOCIETE_EMAIL_UNIQUE (#29942) * FIX Bug - public project form return an error if SOCIETE_EMAIL_UNIQUE if SOCIETE_EMAIL_UNIQUE is 1, this form returns an error because the third party already exists. * after comment from eldy --- htdocs/public/project/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index bd8ccd07901..76b4333010b 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -211,7 +211,7 @@ if (empty($reshook) && $action == 'add') { if (!$error) { // Search thirdparty and set it if found to the new created project - $result = $thirdparty->fetch(0, '', '', '', '', '', '', '', '', '', $object->email); + $result = $thirdparty->fetch(0, '', '', '', '', '', '', '', '', '', GETPOST('email')); if ($result > 0) { $proj->socid = $thirdparty->id; } else { From f05c1b4aec4c9acd871a1b993684aadbc4418dad Mon Sep 17 00:00:00 2001 From: atm-lucas <121817516+atm-lucasmantegari@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:36:50 +0200 Subject: [PATCH 03/11] FIX - Unknown Character on HTML (#30257) * Unknown Character * Add replace on dol_htmlwithnojs --- htdocs/core/lib/functions.lib.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 37fcc3c1f14..fa69487be7e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7717,6 +7717,9 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = ' } } + //Clear ZERO WIDTH NO-BREAK SPACE, ZERO WIDTH SPACE, ZERO WIDTH JOINER + $out = preg_replace('/[\x{200B}-\x{200D}\x{FEFF}]/u', ' ', $out); + // Clean some html entities that are useless so text is cleaner $out = preg_replace('/&(tab|newline);/i', ' ', $out); @@ -7821,6 +7824,7 @@ function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom = 'UT if ($removelasteolbr) { $newstring = preg_replace('/
$/i', '', $newstring); // Remove last
(remove only last one) } + $newstring = preg_replace('/[\x{200B}-\x{200D}\x{FEFF}]/u', ' ', $newstring); $newstring = strtr($newstring, array('&'=>'__and__', '<'=>'__lt__', '>'=>'__gt__', '"'=>'__dquot__')); $newstring = dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom); // Make entity encoding $newstring = strtr($newstring, array('__and__'=>'&', '__lt__'=>'<', '__gt__'=>'>', '__dquot__'=>'"')); From 73562b8734d5aef6de28935845126566749617f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 Jul 2024 01:32:21 +0200 Subject: [PATCH 04/11] FIX Missing trunc to $max --- htdocs/compta/facture/class/facture-rec.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 16c9326ec9b..5f7273fd6ef 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1494,7 +1494,7 @@ class FactureRec extends CommonInvoice $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { - $result .= $this->ref; + $result .= dol_trunc($this->ref, $max); } $result .= $linkend; global $action; From d90ae09a5239c596aad733d6815b8155e8217e21 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 Jul 2024 01:19:39 +0200 Subject: [PATCH 05/11] FIX Bad format of amount in invoice create page --- htdocs/core/tpl/object_discounts.tpl.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/object_discounts.tpl.php b/htdocs/core/tpl/object_discounts.tpl.php index 2826cef6c6f..282a92be9e2 100644 --- a/htdocs/core/tpl/object_discounts.tpl.php +++ b/htdocs/core/tpl/object_discounts.tpl.php @@ -67,9 +67,10 @@ print ' '.$addrelativediscount; // Is there is commercial discount or down payment available ? if ($absolute_discount > 0) { + print ''; if (!empty($cannotApplyDiscount) || !$isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) { $translationKey = empty($discount_type) ? 'CompanyHasDownPaymentOrCommercialDiscount' : 'HasDownPaymentOrCommercialDiscountFromSupplier'; - $text = $langs->trans($translationKey, price($absolute_discount, 1, $langs, 1, -1, -1, $conf->currency)).'.'; + $text = $langs->trans($translationKey, price($absolute_discount, 0, $langs, 1, -1, -1, $conf->currency)).'.'; if ($isInvoice && !$isNewObject && $object->statut > $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) { $text = $form->textwithpicto($text, $langs->trans('AbsoluteDiscountUse')); @@ -94,10 +95,11 @@ if ($absolute_discount > 0) { // Is there credit notes availables ? if ($absolute_creditnote > 0) { + print ''; // If validated, we show link "add credit note to payment" if (!empty($cannotApplyDiscount) || !$isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) { $translationKey = empty($discount_type) ? 'CompanyHasCreditNote' : 'HasCreditNoteFromSupplier'; - $text = $langs->trans($translationKey, price($absolute_creditnote, 1, $langs, 1, -1, -1, $conf->currency)); + $text = $langs->trans($translationKey, price($absolute_creditnote, 0, $langs, 1, -1, -1, $conf->currency)); if ($isInvoice && !$isNewObject && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_DEPOSIT) { $text = $form->textwithpicto($text, $langs->trans('CreditNoteDepositUse')); From 0fe143d7101ea1e2093c523f3e1b466dc4acac5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 Jul 2024 02:10:44 +0200 Subject: [PATCH 06/11] Fix doc --- htdocs/main.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 559a652288e..cb083946521 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1565,8 +1565,8 @@ if (!function_exists("llxHeader")) { * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage|DE:GermanPage * For other external page: http://server/url * @param string $target Target to use on links - * @param int $disablejs More content into html header - * @param int $disablehead More content into html header + * @param int<0,1> $disablejs More content into html header + * @param int<0,1> $disablehead More content into html header * @param array|string $arrayofjs Array of complementary js files * @param array|string $arrayofcss Array of complementary css files * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) From 7879e12bd24dcfc8fa26091c822b67c613c65817 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 Jul 2024 02:22:26 +0200 Subject: [PATCH 07/11] Fix phpunit --- test/phpunit/AllTests.php | 5 +++++ test/phpunit/JsonLibTest.php | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index c96380bdcc5..9eb4e51e7fa 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -24,6 +24,7 @@ * \brief This file is a test suite to run all unit tests * \remarks To run this script as CLI: phpunit filename.php */ + print "PHP Version: ".phpversion()."\n"; print "Memory limit: ". ini_get('memory_limit')."\n"; @@ -32,6 +33,10 @@ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $_SERVER['PHP_SELF'] = "phpunit"; } +if (! defined('NOREQUIREUSER')) { + define('PHPUNIT_MODE', 1); +} + global $conf,$user,$langs,$db; //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver //require_once 'PHPUnit/Autoload.php'; diff --git a/test/phpunit/JsonLibTest.php b/test/phpunit/JsonLibTest.php index 177093e190c..44ca302323d 100644 --- a/test/phpunit/JsonLibTest.php +++ b/test/phpunit/JsonLibTest.php @@ -24,7 +24,9 @@ * \remarks To run this script as CLI: phpunit filename.php */ -define('PHPUNIT_MODE', 1); +if (! defined('NOREQUIREUSER')) { + define('PHPUNIT_MODE', 1); +} global $conf,$user,$langs,$db; //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver From d48b9769666b3fa6b54df56302b761ebc057475c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 Jul 2024 02:32:31 +0200 Subject: [PATCH 08/11] Fix phpunit --- htdocs/core/lib/json.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index f02586d39fe..9a4ee2aa45e 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -429,4 +429,4 @@ if (!function_exists('json_decode')) { { return dol_json_decode($json, $assoc); } -} \ No newline at end of file +} From f91c96842fa1dd3de9a1b4419a470dbb00e3485f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 13 Jul 2024 17:11:20 +0200 Subject: [PATCH 09/11] fix typo (#30368) --- htdocs/comm/action/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index fa3b146865d..b11fe37c76d 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -294,9 +294,9 @@ $nav .= ' Date: Sat, 13 Jul 2024 17:18:05 +0200 Subject: [PATCH 10/11] FIX expedition PDF models using units labels (#30358) --- .../core/modules/expedition/doc/pdf_espadon.modules.php | 8 ++++---- htdocs/core/modules/expedition/doc/pdf_rouget.modules.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 297013ed8ac..a7481c0be4b 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -847,11 +847,11 @@ class pdf_espadon extends ModelePdfExpedition $object->volume_units = $object->size_units * 3; } - if ($totalWeight != '') { - $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); + if (!empty($totalWeight)) { + $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1); } - if ($totalVolume != '') { - $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); + if (!empty($totalVolume)) { + $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); } if ($object->trueWeight) { $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 11635c6511b..2b10608ab93 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -734,11 +734,11 @@ class pdf_rouget extends ModelePdfExpedition $object->volume_units = $object->size_units * 3; } - if ($totalWeight != '') { - $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); + if (!empty($totalWeight)) { + $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1); } - if ($totalVolume != '') { - $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); + if (!empty($totalVolume)) { + $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); } if (!empty($object->trueWeight)) { $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); From 23eeabe4768b3d8d08dac59448e6689d852076df Mon Sep 17 00:00:00 2001 From: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> Date: Sat, 13 Jul 2024 17:28:25 +0200 Subject: [PATCH 11/11] FIX #30362 Fix an user with user->rights->projet->lire can see task time from other user on all project (#30363) Conflicts: htdocs/projet/tasks/time.php --- htdocs/projet/class/project.class.php | 2 +- htdocs/projet/tasks/time.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 6ac789ff314..9201fdd4ddc 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1595,7 +1595,7 @@ class Project extends CommonObject * @param int $mode 0=All project I have permission on (assigned to me or public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts * @param int $list 0=Return array, 1=Return string list * @param int $socid 0=No filter on third party, id of third party - * @param string $filter additional filter on project (statut, ref, ...) + * @param string $filter additional filter on project (statut, ref, ...). TODO Use USF syntax here. * @return array|string Array of projects id, or string with projects id separated with "," if list is 1 */ public function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid = 0, $filter = '') diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index ff04c97ef49..3a2309d26b2 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -7,7 +7,9 @@ * Copyright (C) 2018 Frédéric France * Copyright (C) 2019-2021 Christophe Battarel * Copyright (C) 2023 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Vincent de Grandpré + * Copyright (C) 2024 Solution Libre SAS * * 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 @@ -1597,6 +1599,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $sql .= $hookmanager->resPrint; $sql .= " WHERE elementtype = 'task'"; $sql .= " AND p.entity IN (".getEntity('project').")"; + if (!$user->hasRight('projet', 'all', 'lire')) { + // Get list of project id allowed to user (in a string list separated by comma) + // TODO This may generate performance trouble when list of project is very large. Solution can be to complete $filterproj with filters on project. + $filterproj = ''; + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj); + $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users + } if (empty($projectidforalltimes) && empty($allprojectforuser)) { // Limit on one task $sql .= " AND t.fk_element =".((int) $object->id);