From 9735ace7aa4823bbc7b5a93922452bb5b53e0ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 5 Dec 2024 17:58:27 +0100 Subject: [PATCH 1/9] fix phpstan --- build/phpstan/phpstan-baseline.neon | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index 3999e4d96da..4e617e847eb 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -3078,18 +3078,6 @@ parameters: count: 8 path: ../../htdocs/bom/tpl/objectline_view.tpl.php - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 1 - path: ../../htdocs/bookcal/availabilities_agenda.php - - - - message: '#^Negated boolean expression is always false\.$#' - identifier: booleanNot.alwaysFalse - count: 1 - path: ../../htdocs/bookcal/availabilities_agenda.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse From 4bf144a80cfb131ac208d140969f5613c69fb130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 5 Dec 2024 18:03:34 +0100 Subject: [PATCH 2/9] fix phpstan --- htdocs/bookcal/availabilities_agenda.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/htdocs/bookcal/availabilities_agenda.php b/htdocs/bookcal/availabilities_agenda.php index ddaa5d99b74..630bbb4f08f 100644 --- a/htdocs/bookcal/availabilities_agenda.php +++ b/htdocs/bookcal/availabilities_agenda.php @@ -93,16 +93,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->bookcal->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; } -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read'); - $permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write'); -} else { - $permissiontoread = 1; - $permissiontoadd = 1; -} +$permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read'); +$permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write'); // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); From 58d581682a7935c7f1d660d3161539cc0b40a49e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 5 Dec 2024 18:05:22 +0100 Subject: [PATCH 3/9] fix phpstan --- htdocs/bookcal/availabilities_contact.php | 12 ++---------- htdocs/bookcal/availabilities_document.php | 12 ++---------- htdocs/bookcal/availabilities_note.php | 16 +++------------- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/htdocs/bookcal/availabilities_contact.php b/htdocs/bookcal/availabilities_contact.php index 96f32655b77..69b4fb451b2 100644 --- a/htdocs/bookcal/availabilities_contact.php +++ b/htdocs/bookcal/availabilities_contact.php @@ -58,16 +58,8 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read'); - $permission = $user->hasRight('bookcal', 'availabilities', 'write'); -} else { - $permissiontoread = 1; - $permission = 1; -} +$permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read'); +$permission = $user->hasRight('bookcal', 'availabilities', 'write'); // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/bookcal/availabilities_document.php b/htdocs/bookcal/availabilities_document.php index d0741f9b154..cf8897ff4c7 100644 --- a/htdocs/bookcal/availabilities_document.php +++ b/htdocs/bookcal/availabilities_document.php @@ -85,16 +85,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->bookcal->multidir_output[$object->entity ? $object->entity : $conf->entity]."/availabilities/".get_exdir(0, 0, 0, 1, $object); } -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read'); - $permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php -} else { - $permissiontoread = 1; - $permissiontoadd = 1; -} +$permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read'); +$permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/bookcal/availabilities_note.php b/htdocs/bookcal/availabilities_note.php index fdf3a402e74..2031ab5838f 100644 --- a/htdocs/bookcal/availabilities_note.php +++ b/htdocs/bookcal/availabilities_note.php @@ -60,19 +60,9 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->bookcal->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; } - -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read'); - $permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write'); - $permissionnote = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_setnotes.inc.php -} else { - $permissiontoread = 1; - $permissiontoadd = 1; - $permissionnote = 1; -} +$permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read'); +$permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write'); +$permissionnote = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_setnotes.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); From e26595b0d8e7769241d70c12df6ed97fee8d034c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 5 Dec 2024 18:08:29 +0100 Subject: [PATCH 4/9] fix phpstan --- htdocs/bookcal/availabilities_agenda.php | 3 +-- htdocs/bookcal/availabilities_contact.php | 3 +-- htdocs/bookcal/availabilities_document.php | 5 ++--- htdocs/bookcal/availabilities_note.php | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/htdocs/bookcal/availabilities_agenda.php b/htdocs/bookcal/availabilities_agenda.php index 630bbb4f08f..6cccf182dad 100644 --- a/htdocs/bookcal/availabilities_agenda.php +++ b/htdocs/bookcal/availabilities_agenda.php @@ -1,6 +1,5 @@ - * Copyright (C) 2022 Alice Adminson +/* Copyright (C) 2017-2024 Laurent Destailleur * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/bookcal/availabilities_contact.php b/htdocs/bookcal/availabilities_contact.php index 69b4fb451b2..bcd852ee5e6 100644 --- a/htdocs/bookcal/availabilities_contact.php +++ b/htdocs/bookcal/availabilities_contact.php @@ -1,6 +1,5 @@ - * Copyright (C) 2022 Alice Adminson +/* Copyright (C) 2007-2024 Laurent Destailleur * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/bookcal/availabilities_document.php b/htdocs/bookcal/availabilities_document.php index cf8897ff4c7..1abdde9a496 100644 --- a/htdocs/bookcal/availabilities_document.php +++ b/htdocs/bookcal/availabilities_document.php @@ -1,7 +1,6 @@ - * Copyright (C) 2022 Alice Adminson - * Copyright (C) 2024 MDW +/* Copyright (C) 2007-2024 Laurent Destailleur + * Copyright (C) 2024 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/bookcal/availabilities_note.php b/htdocs/bookcal/availabilities_note.php index 2031ab5838f..b11f001251b 100644 --- a/htdocs/bookcal/availabilities_note.php +++ b/htdocs/bookcal/availabilities_note.php @@ -1,6 +1,5 @@ - * Copyright (C) 2022 Alice Adminson +/* Copyright (C) 2007-2024 Laurent Destailleur * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify From 8037dc3b9679aad9db3f1eaea13715f4d8e429f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 5 Dec 2024 21:46:31 +0100 Subject: [PATCH 5/9] fix --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index d7e687c590b..ecb4ada7f88 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1500,9 +1500,9 @@ class ExtraFields $sqlwhere .= ' AND entity = '.((int) $conf->entity); } $sql .= $sqlwhere; - //print $sql; $sql .= $this->db->order(implode(',', $fields_label)); + //print $sql; dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG); $resql = $this->db->query($sql); From b2135c0b50f77d2c3f5ff15c68cc8bda90180a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 6 Dec 2024 13:33:05 +0100 Subject: [PATCH 6/9] Update payments.php --- htdocs/compta/tva/payments.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index 9384a292aff..48fa39fce67 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -204,8 +204,8 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) { $sql .= " AND tva.entity = " . $conf->entity; if ($year > 0) { $sql .= " AND ("; - // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, - // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + // We'll use the specified period as the date filter, unless it's missing, in which case we'll use the due date. + // This is to handle situations where the period was optional. $sql .= " (tva.datev IS NOT NULL AND tva.datev between '" . $db->idate(dol_get_first_day($year)) . "' AND '" . $db->idate(dol_get_last_day($year)) . "')"; $sql .= " OR (tva.datev IS NULL AND tva.datev between '" . $db->idate(dol_get_first_day($year)) . "' AND '" . $db->idate(dol_get_last_day($year)) . "')"; $sql .= ")"; From 629f94be71e9c81004fcf5cf0926917147b26590 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Fri, 6 Dec 2024 15:33:29 +0100 Subject: [PATCH 7/9] Better error message --- htdocs/core/class/CMailFile.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 268de88d57f..d3f124a39a1 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1960,11 +1960,14 @@ class CMailFile // Check response from Server if ($_retVal = $this->server_parse($socket, "220")) { $_retVal = $socket; + } else { + $this->error = ($this->error ? $this->error." - " : "")."Succeed in opening socket but answer 220 not received"; } } else { $this->error = utf8_check('Error '.$errno.' - '.$errstr) ? 'Error '.$errno.' - '.$errstr : mb_convert_encoding('Error '.$errno.' - '.$errstr, 'UTF-8', 'ISO-8859-1'); } } + return $_retVal; } From c4abeb441846ad8f3be396be8d4e8e5a7673e788 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Fri, 6 Dec 2024 16:08:43 +0100 Subject: [PATCH 8/9] Debug v21 --- htdocs/comm/mailing/cibles.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index d5d99d1c8da..753ee43f2c6 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -915,7 +915,7 @@ if ($object->fetch($id) >= 0) { // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + print ''; print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; @@ -926,7 +926,7 @@ if ($object->fetch($id) >= 0) { } if ($obj->status == $object::STATUS_DRAFT) { // Not sent yet if ($user->hasRight('mailing', 'creer')) { - print ''.img_delete($langs->trans("RemoveRecipient")).''; + print ''.img_delete($langs->trans("RemoveRecipient")).''; } } /*if ($obj->status == -1) // Sent with error @@ -999,11 +999,11 @@ if ($object->fetch($id) >= 0) { // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + print ''; print ''; if ($obj->status == $object::STATUS_DRAFT) { // If status of target line is not sent yet if ($user->hasRight('mailing', 'creer')) { - print ''.img_delete($langs->trans("RemoveRecipient")).''; + print ''.img_delete($langs->trans("RemoveRecipient")).''; } } /*if ($obj->status == -1) // Sent with error From 3153c92b8e497649cccf81ff066500a06a3ec179 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Fri, 6 Dec 2024 16:12:13 +0100 Subject: [PATCH 9/9] Debug v21 --- htdocs/comm/mailing/cibles.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 753ee43f2c6..ce1ef8fbcce 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -977,14 +977,14 @@ if ($object->fetch($id) >= 0) { // Date last update print ''; - print dol_print_date(dol_stringtotime($obj->tms), 'dayhour'); + print dol_print_date($db->jdate($obj->tms), 'dayhour', 'tzuserrel'); print ''; // Date sent print ''; if ($obj->status != $object::STATUS_DRAFT) { // If status of target line is not draft // Date sent - print $obj->date_envoi; // @TODO Must store date in date format + print dol_print_date($db->jdate($obj->date_envoi), 'dayhour', 'tzuserrel'); // @TODO Must store date in date format } print '';