From 89ba133c61429071b2c64ab007f7d888fb659f92 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 26 Oct 2021 14:11:51 +0200 Subject: [PATCH 1/7] fix: categorie display if none --- htdocs/modulebuilder/template/admin/setup.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 9007eab60cc..6cae58ecf2e 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -354,13 +354,14 @@ if ($action == 'edit') { $result = $c->fetch($conf->global->{$constname}); if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); + } elseif ($result > 0 ) { + $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text + $toprint = array(); + foreach ($ways as $way) { + $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; + } + print '
    '; } - $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text - $toprint = array(); - foreach ($ways as $way) { - $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; - } - print '
    '; } elseif (preg_match('/thirdparty_type/', $val['type'])) { if ($conf->global->{$constname}==2) { print $langs->trans("Prospect"); From 406089ef0c19a4849b20be460df485f42e41e5e6 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 26 Oct 2021 16:47:16 +0200 Subject: [PATCH 2/7] FIX restrictedArea for payment delete --- htdocs/core/lib/security.lib.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index da5d9388bd8..03f49188a07 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -493,7 +493,11 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f if (!$user->rights->fournisseur->facture->creer) { $deleteok = 0; } - } elseif ($feature == 'banque') { + } elseif ($feature == 'payment') { + if (!$user->rights->facture->supprimer) { + $deleteok = 0; + } + }elseif ($feature == 'banque') { if (!$user->rights->banque->modifier) { $deleteok = 0; } From 6fd08bc5efb1f12209a49abf24dcd35e0779bbed Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 26 Oct 2021 14:56:56 +0000 Subject: [PATCH 3/7] Fixing style errors. --- htdocs/core/lib/security.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 03f49188a07..852a87baa0b 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -494,10 +494,10 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f $deleteok = 0; } } elseif ($feature == 'payment') { - if (!$user->rights->facture->supprimer) { - $deleteok = 0; - } - }elseif ($feature == 'banque') { + if (!$user->rights->facture->supprimer) { + $deleteok = 0; + } + } elseif ($feature == 'banque') { if (!$user->rights->banque->modifier) { $deleteok = 0; } From fb6a1d1f5119b73e227c17c825202e1a5e135244 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 16:56:38 +0100 Subject: [PATCH 4/7] FIX #19210 --- htdocs/core/lib/functions.lib.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d659c2b1916..eae8546a338 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2266,6 +2266,11 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = { global $conf, $langs; + // If date undefined or "", we return "" + if (dol_strlen($time) == 0) { + return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) + } + if ($tzoutput === 'auto') { $tzoutput = (empty($conf) ? 'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey : 'tzserver')); } @@ -2289,7 +2294,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = $user_date_tz = new DateTimeZone($offsettzstring); $user_dt = new DateTime(); $user_dt->setTimezone($user_date_tz); - $user_dt->setTimestamp(($tzoutput == 'tzuser' || empty($time)) ? dol_now() : $time); + $user_dt->setTimestamp($tzoutput == 'tzuser' ? dol_now() : (int) $time); $offsettz = $user_dt->getOffset(); } else { // old method (The 'tzuser' was processed like the 'tzuserrel') $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore @@ -2357,11 +2362,6 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = $format = str_replace('yyyy', 'yy', $format); } - // If date undefined or "", we return "" - if (dol_strlen($time) == 0) { - return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) - } - // Clean format if (preg_match('/%b/i', $format)) { // There is some text to translate // We inhibate translation to text made by strftime functions. We will use trans instead later. From 682ad989186f864ca2c0c3a2c51acefcb382e629 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 17:06:37 +0100 Subject: [PATCH 5/7] Update security.lib.php --- htdocs/core/lib/security.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 852a87baa0b..475649701ae 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -489,12 +489,12 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f if (!$user->rights->fournisseur->commande->supprimer) { $deleteok = 0; } - } elseif ($feature == 'payment_supplier') { + } elseif ($feature == 'payment_supplier') { // Permission to delete a payment of an invoice is permission to edit an invoice. if (!$user->rights->fournisseur->facture->creer) { $deleteok = 0; } - } elseif ($feature == 'payment') { - if (!$user->rights->facture->supprimer) { + } elseif ($feature == 'payment') { // Permission to delete a payment of an invoice is permission to edit an invoice. + if (!$user->rights->facture->creer) { $deleteok = 0; } } elseif ($feature == 'banque') { From 0e4c113e7fcc167f9e7e60e51c316e35b7459595 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 17:11:23 +0100 Subject: [PATCH 6/7] Fix phpcs --- htdocs/core/class/html.formticket.class.php | 2 +- htdocs/ticket/card.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 46df923704d..ebfd3802cc2 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -406,7 +406,7 @@ class FormTicket } } - if($subelement != 'project') { + if ($subelement != 'project') { if (!empty($conf->projet->enabled) && !$this->ispublic) { $formproject = new FormProjets($this->db); print ''; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index d59369a07ff..380d85be94c 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -200,7 +200,7 @@ if (empty($reshook)) { } // Link ticket to project - if(GETPOST('origin', 'alpha') == 'projet') { + if (GETPOST('origin', 'alpha') == 'projet') { $projectid = GETPOST('originid', 'int'); } else { $projectid = GETPOST('projectid', 'int'); From dbf330b49c252b4f57805b04ecf76daeacd2c340 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 17:17:21 +0100 Subject: [PATCH 7/7] Comment on test --- test/phpunit/DateLibTzFranceTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/phpunit/DateLibTzFranceTest.php b/test/phpunit/DateLibTzFranceTest.php index 4b63450c332..0db809be2f7 100644 --- a/test/phpunit/DateLibTzFranceTest.php +++ b/test/phpunit/DateLibTzFranceTest.php @@ -83,7 +83,10 @@ class DateLibTzFranceTest extends PHPUnit\Framework\TestCase global $conf,$user,$langs,$db; if (getServerTimeZoneString() != 'Europe/Paris' && getServerTimeZoneString() != 'Europe/Berlin') { - print "\n".__METHOD__." This PHPUnit test can be launched manually only onto a server with PHP timezone set to TZ=Europe/Paris, not a TZ=".getServerTimeZoneString().".\n"; die(1); + print "\n".__METHOD__." This PHPUnit test can be launched manually only onto a server with PHP timezone set to TZ=Europe/Paris, not a TZ=".getServerTimeZoneString().".\n"; + print "You can launch the test from command line with:\n"; + print "php -d date.timezone='Europe/Paris' phpunit DateLibTzFranceTest.php\n"; + die(1); } $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.