From ce06c12da61d778e8004c98748cb6be0e137f51b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina=20JOUM?= Date: Wed, 18 Dec 2024 11:19:56 +0100 Subject: [PATCH 01/55] FIX: GETPOST('private_message') --- htdocs/ticket/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 265a661448d2a..3ae0814962639 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -458,7 +458,7 @@ // Action to add a message (private or not, with email or not). // This may also send an email (concatenated with email_intro and email footer if checkbox was selected) if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $permissiontoread) { - $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0), 0); + $ret = $object->newMessage($user, $action, GETPOSTINT('private_message'), 0); if ($ret > 0) { if (!empty($backtopage)) { From 83abe6aa345a484a7c4c1e4c64cb5d33d2d0d3ff Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Thu, 2 Jan 2025 20:42:43 +0100 Subject: [PATCH 02/55] Fix #29624 Wrong property of commande fournisseur used for substitution. --- htdocs/core/lib/functions.lib.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6896113399d5a..a7cd3d0253bbe 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -20,7 +20,7 @@ * Copyright (C) 2022 Anthony Berton * Copyright (C) 2022 Ferran Marcet * Copyright (C) 2022 Charlene Benke - * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2023-2024 Joachim Kueter * * 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 @@ -8307,15 +8307,15 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); - $substitutionarray['__DATE_DELIVERY__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, 'day', 0, $outputlangs) : ''); - $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%d") : ''); - $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%A") : ''); - $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%m") : ''); - $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%b") : ''); - $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%Y") : ''); - $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%H") : ''); - $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%M") : ''); - $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%S") : ''); + $substitutionarray['__DATE_DELIVERY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, 'day', 0, $outputlangs) : ''); + $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%d") : ''); + $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%A") : ''); + $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%m") : ''); + $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%b") : ''); + $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%Y") : ''); + $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%H") : ''); + $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%M") : ''); + $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%S") : ''); // For backward compatibility (deprecated) $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); From b7cb799af0245ae3c5737a6bdd9589f9fc5eea7f Mon Sep 17 00:00:00 2001 From: Alexis Thietard Date: Mon, 6 Jan 2025 14:23:13 +0100 Subject: [PATCH 03/55] FIX #21294 Stock import sql query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To respect the PostgreSQL update statement syntax, cf. https://www.postgresql.org/docs/17/sql-update.html ``` column_name The name of a column in the table named by table_name. The column name can be qualified with a subfield name or array subscript, if needed. Do not include the table's name in the specification of a target column — for example, UPDATE table_name SET table_name.col = 1 is invalid. ``` Signed-off-by: Alexis Thietard --- htdocs/core/modules/modStock.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index e9e9ccc79a6f0..f7def03808ce6 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -429,7 +429,7 @@ public function __construct($db) ); $this->import_updatekeys_array[$r] = array('ps.fk_product'=>'Product', 'ps.fk_entrepot'=>"Warehouse"); $this->import_run_sql_after_array[$r] = array( // Because we may change data that are denormalized, we must update dernormalized data after. - 'UPDATE '.MAIN_DB_PREFIX.'product as p SET p.stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' + 'UPDATE '.MAIN_DB_PREFIX.'product as p SET stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' ); } From 886abc96d16510e48b3bb6eed3cdca1ccf4dcde3 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:03:17 +0100 Subject: [PATCH 04/55] handle property for delivery date (named differently in different objects)) --- htdocs/core/lib/functions.lib.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a7cd3d0253bbe..b587cba9fe105 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8307,20 +8307,27 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); - $substitutionarray['__DATE_DELIVERY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, 'day', 0, $outputlangs) : ''); - $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%d") : ''); - $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%A") : ''); - $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%m") : ''); - $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%b") : ''); - $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%Y") : ''); - $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%H") : ''); - $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%M") : ''); - $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%S") : ''); + // handle date_delivery: in customer oder/supplier order, the property name is delivery_date, in shipment/reception it is date_delivery + $date_delivery = null; + if (property_exists($object, 'date_delivery')) { + $date_delivery = $object->date_delivery; + } elseif (property_exists($object, delivery_date')) { + $date_delivery = $object->delivery_date; + } + $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); + $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%d") : ''); + $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%A") : ''); + $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%m") : ''); + $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%b") : ''); + $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%Y") : ''); + $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%H") : ''); + $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%M") : ''); + $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%S") : ''); // For backward compatibility (deprecated) $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); - $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, 'day', 0, $outputlangs) : ''); + $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); $substitutionarray['__SUPPLIER_ORDER_DELAY_DELIVERY__'] = (isset($object->availability_code) ? ($outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '')) : ''); $substitutionarray['__EXPIRATION_DATE__'] = (isset($object->fin_validite) ? dol_print_date($object->fin_validite, 'daytext') : ''); From 21607b4f28f20af36d9c03d56b52752b6d90f623 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:11:01 +0100 Subject: [PATCH 05/55] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b587cba9fe105..53c326c22fa18 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8307,12 +8307,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); - // handle date_delivery: in customer oder/supplier order, the property name is delivery_date, in shipment/reception it is date_delivery + // handle date_delivery: in customer order/supplier order, the property name is delivery_date, in shipment/reception it is date_delivery $date_delivery = null; if (property_exists($object, 'date_delivery')) { $date_delivery = $object->date_delivery; } elseif (property_exists($object, delivery_date')) { - $date_delivery = $object->delivery_date; + $date_delivery = $object->delivery_date; } $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%d") : ''); From 0158b2b8324ffb13299a61cab959f8bcb0c020fd Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:17:00 +0100 Subject: [PATCH 06/55] Update functions.lib.php trying to solve indentation issue --- htdocs/core/lib/functions.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 53c326c22fa18..b3f54ea2d54a0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8307,6 +8307,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); + // handle date_delivery: in customer order/supplier order, the property name is delivery_date, in shipment/reception it is date_delivery $date_delivery = null; if (property_exists($object, 'date_delivery')) { From 48a33932644f4377e775a3c9e53dbc1fe12a2e47 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:21:46 +0100 Subject: [PATCH 07/55] Update functions.lib.php trying to solve indentation --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b3f54ea2d54a0..82b983e10262e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8312,7 +8312,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $date_delivery = null; if (property_exists($object, 'date_delivery')) { $date_delivery = $object->date_delivery; - } elseif (property_exists($object, delivery_date')) { + } else if (property_exists($object, delivery_date')) { $date_delivery = $object->delivery_date; } $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); From dd41f3f47d5e391848cad4564309a20f1688a24e Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:25:00 +0100 Subject: [PATCH 08/55] Update functions.lib.php trying to solve whitespace/indentation issues --- htdocs/core/lib/functions.lib.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 82b983e10262e..47d7dccd6eb91 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8307,12 +8307,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); - // handle date_delivery: in customer order/supplier order, the property name is delivery_date, in shipment/reception it is date_delivery $date_delivery = null; - if (property_exists($object, 'date_delivery')) { + if (property_exists($object, 'date_delivery')) { $date_delivery = $object->date_delivery; - } else if (property_exists($object, delivery_date')) { + } elseif (property_exists($object, delivery_date')) { $date_delivery = $object->delivery_date; } $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); From 7689e0b210e0744b4258b21f6140625554f78a44 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:28:17 +0100 Subject: [PATCH 09/55] Update functions.lib.php solve indentation --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 47d7dccd6eb91..53c326c22fa18 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8309,7 +8309,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); // handle date_delivery: in customer order/supplier order, the property name is delivery_date, in shipment/reception it is date_delivery $date_delivery = null; - if (property_exists($object, 'date_delivery')) { + if (property_exists($object, 'date_delivery')) { $date_delivery = $object->date_delivery; } elseif (property_exists($object, delivery_date')) { $date_delivery = $object->delivery_date; From 259088c28056ce6c0d29064ce4696b5344e57553 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:35:37 +0100 Subject: [PATCH 10/55] Update functions.lib.php fixed typo... --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 53c326c22fa18..3ea1c942c5a63 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8311,7 +8311,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $date_delivery = null; if (property_exists($object, 'date_delivery')) { $date_delivery = $object->date_delivery; - } elseif (property_exists($object, delivery_date')) { + } elseif (property_exists($object, 'delivery_date')) { $date_delivery = $object->delivery_date; } $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); From 92d448cfe61b8eb3a51715a76411abf35fe6a9ac Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 14:02:47 +0100 Subject: [PATCH 11/55] Update functions.lib.php fixed spaces From 5c7fd531db29488801bb1b659a4d33ab4d6ba76e Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 15:01:50 +0100 Subject: [PATCH 12/55] Update functions.lib.php white space From 169b2ce4e81977278b96ee9976635cc340b2045f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Jan 2025 21:52:26 +0100 Subject: [PATCH 13/55] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3ea1c942c5a63..d2e1d11a6d867 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8312,7 +8312,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (property_exists($object, 'date_delivery')) { $date_delivery = $object->date_delivery; } elseif (property_exists($object, 'delivery_date')) { - $date_delivery = $object->delivery_date; + $date_delivery = $object->delivery_date; } $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%d") : ''); From 3737f3c0cd5f8cca1d2f73e506bcaa463971318e Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 8 Jan 2025 12:30:46 +0100 Subject: [PATCH 14/55] FIX select 2 no record found --- htdocs/core/class/html.form.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index aaf856152b70a..329017cc3b272 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8890,7 +8890,8 @@ public static function multiselectarray($htmlname, $array, $selected = array(), escapeMarkup: function (markup) { return markup; }, // let our custom formatter work // Specify format function for selected item formatSelection: formatSelection, - templateSelection: formatSelection /* For 4.0 */ + templateSelection: formatSelection, /* For 4.0 */ + language: select2arrayoflanguage }); /* Add also morecss to the css .select2 that is after the #htmlname, for component that are show dynamically after load, because select2 set From 0c05b8110f3d8f3c3054bb76be3464fbffa6f001 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Wed, 8 Jan 2025 16:19:06 +0100 Subject: [PATCH 15/55] Fix fatal error on sprintf with translate --- htdocs/core/class/translate.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 92b32d2f25720..3916ef277d610 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -699,6 +699,10 @@ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = $str ); + if (preg_match('/%\)/', $str)) { + $str = preg_replace('/%\)/', '__percent__)', $str); + } + if (strpos($key, 'Format') !== 0) { try { // @phan-suppress-next-line PhanPluginPrintfVariableFormatString @@ -708,6 +712,8 @@ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = } } + $str = str_replace('__percent__', '%', $str); + // Encode string into HTML $str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are embraced by "). Use dol_escape_htmltag around text in HTML content From 3fcdba2bc3e1fd5db1d2aa0110c473ee62c0ffde Mon Sep 17 00:00:00 2001 From: Hystepik Date: Thu, 9 Jan 2025 09:21:45 +0100 Subject: [PATCH 16/55] better fix for performance --- htdocs/core/class/translate.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 3916ef277d610..905ccf9349b66 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -699,9 +699,7 @@ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = $str ); - if (preg_match('/%\)/', $str)) { - $str = preg_replace('/%\)/', '__percent__)', $str); - } + $str = preg_replace('/%\)/', '__percent__)', $str); if (strpos($key, 'Format') !== 0) { try { From f0449e349f0adb37cdea60f1268b93232386f93a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 9 Jan 2025 09:59:23 +0100 Subject: [PATCH 17/55] fix: php warning --- htdocs/core/modules/commande/mod_commande_marbre.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index e5e2e52534244..e229e17f89eb2 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -57,7 +57,7 @@ public function __construct() { global $conf, $mysoc; - if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 16.0 && $mysoc->country_code != 'FR') { + if ((float) getDolGlobalString('MAIN_VERSION_LAST_INSTALL') >= 16.0 && $mysoc->country_code != 'FR') { $this->prefix = 'SO'; // We use correct standard code "SO = Sale Order" } } From 029569954358539998885ce37cbd1288f3eaf7f4 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 9 Jan 2025 10:21:20 +0100 Subject: [PATCH 18/55] fix: avoid php8 warning/error on failed notification --- .../interface_50_modNotification_Notification.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 8fceee8e47a05..d1095b14745ac 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -96,6 +96,9 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $notify = new Notify($this->db); $resultSend = $notify->send($action, $object); if ($resultSend < 0) { + if (!isset($this->errors)) { + $this->errors = []; + } $this->errors = array_merge($this->errors, $notify->errors); return $resultSend; } From e612bb05599deaf712b5158d980251c1bd223273 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Thu, 9 Jan 2025 10:50:47 +0100 Subject: [PATCH 19/55] FIX 20.0 - PHP8 fatal when creating a reception if no corresponding PDF model enabled --- htdocs/reception/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 488fef75ffe1e..b1791d3da0492 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -947,7 +947,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; $list = ModelePdfReception::liste_modeles($db); - if (count($list) > 1) { + if (is_array($list) && count($list) > 1) { print "".$langs->trans("DefaultModel").""; print ''; print $form->selectarray('model', $list, $conf->global->RECEPTION_ADDON_PDF); From 90713d7773ed8cf46592f26c2e6c757a5fbf865a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Jan 2025 12:07:03 +0100 Subject: [PATCH 20/55] FIX wrong alias table --- htdocs/compta/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index e5119d46c569d..9968411c62ed4 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -444,7 +444,7 @@ print ''; print ''; print ''; print ''; print ''; From 0912b3b04f026f668a527cc99cbbc9ccf341752e Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Thu, 9 Jan 2025 15:04:37 +0100 Subject: [PATCH 21/55] fix selectcontacts param --- htdocs/comm/action/card.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 99d330b745aaf..0310ac0b22559 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1181,8 +1181,14 @@ function init_repeat() $preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int'); } if ($origin=='contact') $preselectedids[GETPOST('originid', 'int')] = GETPOST('originid', 'int'); + // select "all" or "none" contact by default + if (getDolGlobalInt('MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT')) { + $select_contact_default = 0; // select "all" contacts by default : avoid to use it if there is a lot of contacts + } else { + $select_contact_default = -1; // select "none" by default + } print img_picto('', 'contact', 'class="paddingrightonly"'); - print $form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); + print $form->selectcontacts(GETPOSTISSET('socid') ? GETPOSTINT('socid') : $select_contact_default, $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); print ''; } From e37b6fac4d54cd73f509ee889c1bc5335f6ec135 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 9 Jan 2025 20:26:22 +0100 Subject: [PATCH 22/55] Fix pb in output of label of email --- htdocs/core/lib/company.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 39b3037aea5bb..30a8242a7ec38 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -2119,11 +2119,13 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= dol_trunc($libelle, 120); } if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { - $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; $transcode = $langs->trans("Action".$histo[$key]['acode']); $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); + $out .= ''; + $out .= img_object($langs->trans("ShowEMailing"), "email").' '; $out .= dol_trunc($libelle, 120); + $out .= ''; } $out .= ''; From bbcb43e27d1570d89012ec3a2b1df3c69e6714b7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 10 Jan 2025 06:25:47 +0100 Subject: [PATCH 23/55] FIX Loan - Insurance amount need decimals --- htdocs/loan/card.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 61f0823560d79..02e44ce2e7300 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -1,8 +1,8 @@ - * Copyright (C) 2015 Frederic France - * Copyright (C) 2017 Laurent Destailleur - * Copyright (C) 2020 Maxime DEMAREST +/* Copyright (C) 2014-2025 Alexandre Spangaro + * Copyright (C) 2015 Frederic France + * Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2020 Maxime DEMAREST * * 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 @@ -106,7 +106,7 @@ if (!$cancel) { $datestart = dol_mktime(12, 0, 0, GETPOSTINT('startmonth'), GETPOSTINT('startday'), GETPOSTINT('startyear')); $dateend = dol_mktime(12, 0, 0, GETPOSTINT('endmonth'), GETPOSTINT('endday'), GETPOSTINT('endyear')); - $capital = price2num(GETPOST('capital')); + $capital = price2num(GETPOSTFLOAT('capital')); $rate = price2num(GETPOST('rate')); if (!$capital) { @@ -141,7 +141,7 @@ $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); $object->fk_project = GETPOSTINT('projectid'); - $object->insurance_amount = GETPOSTINT('insurance_amount'); + $object->insurance_amount = GETPOSTFLOAT('insurance_amount'); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); @@ -181,7 +181,7 @@ $datestart = dol_mktime(12, 0, 0, GETPOSTINT('startmonth'), GETPOSTINT('startday'), GETPOSTINT('startyear')); $dateend = dol_mktime(12, 0, 0, GETPOSTINT('endmonth'), GETPOSTINT('endday'), GETPOSTINT('endyear')); - $capital = price2num(GETPOST('capital')); + $capital = price2num(GETPOSTFLOAT('capital')); if (!$capital) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); @@ -192,7 +192,7 @@ $object->capital = $capital; $object->nbterm = GETPOSTINT("nbterm"); $object->rate = price2num(GETPOST("rate", 'alpha')); - $object->insurance_amount = price2num(GETPOSTINT('insurance_amount')); + $object->insurance_amount = price2num(GETPOSTFLOAT('insurance_amount')); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); From aa438e29be1e4cd58ea5224b6f758c3729f3b524 Mon Sep 17 00:00:00 2001 From: tnegre Date: Thu, 9 Jan 2025 17:30:07 +0100 Subject: [PATCH 24/55] fix: avoid duplicate lines in inventory --- htdocs/product/inventory/class/inventory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 890bce9870ca8..559ac2cd859ec 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -274,7 +274,7 @@ public function validate(User $user, $notrigger = 0, $include_sub_warehouse = 0) // Scan existing stock to prefill the inventory $sql = "SELECT ps.rowid, ps.fk_entrepot as fk_warehouse, ps.fk_product, ps.reel,"; if (isModEnabled('productbatch')) { - $sql .= " pb.batch as batch, pb.qty as qty,"; + $sql .= " COALESCE(pb.batch, '') as batch, pb.qty as qty,"; } else { $sql .= " '' as batch, 0 as qty,"; } From 0fe484ecd6ceec5eb3a284f4d2f875b31522f62d Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 10 Jan 2025 13:00:11 +0100 Subject: [PATCH 25/55] better fix --- htdocs/core/class/translate.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 905ccf9349b66..2e7db582b5f3b 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -699,7 +699,7 @@ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = $str ); - $str = preg_replace('/%\)/', '__percent__)', $str); + $str = preg_replace('/%\)/', '__percent_parentesis__', $str); if (strpos($key, 'Format') !== 0) { try { @@ -710,7 +710,7 @@ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = } } - $str = str_replace('__percent__', '%', $str); + $str = str_replace('__percent_parentesis__', '%)', $str); // Encode string into HTML $str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are embraced by "). Use dol_escape_htmltag around text in HTML content From 49af0a49dd1bf71996bf468ff0a11088fd3a96f5 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 10 Jan 2025 14:14:00 +0100 Subject: [PATCH 26/55] Remove price2num on GETPOSTFLOAT --- htdocs/loan/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 02e44ce2e7300..f806f9d6f8407 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -106,7 +106,7 @@ if (!$cancel) { $datestart = dol_mktime(12, 0, 0, GETPOSTINT('startmonth'), GETPOSTINT('startday'), GETPOSTINT('startyear')); $dateend = dol_mktime(12, 0, 0, GETPOSTINT('endmonth'), GETPOSTINT('endday'), GETPOSTINT('endyear')); - $capital = price2num(GETPOSTFLOAT('capital')); + $capital = GETPOSTFLOAT('capital'); $rate = price2num(GETPOST('rate')); if (!$capital) { @@ -181,7 +181,7 @@ $datestart = dol_mktime(12, 0, 0, GETPOSTINT('startmonth'), GETPOSTINT('startday'), GETPOSTINT('startyear')); $dateend = dol_mktime(12, 0, 0, GETPOSTINT('endmonth'), GETPOSTINT('endday'), GETPOSTINT('endyear')); - $capital = price2num(GETPOSTFLOAT('capital')); + $capital = GETPOSTFLOAT('capital'); if (!$capital) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); @@ -192,7 +192,7 @@ $object->capital = $capital; $object->nbterm = GETPOSTINT("nbterm"); $object->rate = price2num(GETPOST("rate", 'alpha')); - $object->insurance_amount = price2num(GETPOSTFLOAT('insurance_amount')); + $object->insurance_amount = GETPOSTFLOAT('insurance_amount'); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); From 30168c5445c7af9be332c4ddb0622175ac9e0d28 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 10 Jan 2025 15:09:20 +0100 Subject: [PATCH 27/55] fix tipo --- htdocs/core/class/translate.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 2e7db582b5f3b..0560bd5be9467 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -699,7 +699,7 @@ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = $str ); - $str = preg_replace('/%\)/', '__percent_parentesis__', $str); + $str = preg_replace('/%\)/', '__percent_parenthesis__', $str); if (strpos($key, 'Format') !== 0) { try { @@ -710,7 +710,7 @@ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = } } - $str = str_replace('__percent_parentesis__', '%)', $str); + $str = str_replace('__percent_parenthesis__', '%)', $str); // Encode string into HTML $str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are embraced by "). Use dol_escape_htmltag around text in HTML content From 1cdcf9beb452430587e2570ccb92e0dfb719b09e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Jan 2025 15:17:06 +0100 Subject: [PATCH 28/55] FIX #32611 --- htdocs/user/bank.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index c7dcfc05cc3cd..8f534756aa49a 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -94,6 +94,8 @@ $permissiontowritehr = $user->hasRight('hrm', 'write_personal_information', 'write'); $permissiontosimpleedit = ($selfpermission || $canadduser); +$childids = $user->getAllChildIds(1); + // Ok if user->hasRight('salaries', 'readall') or user->hasRight('hrm', 'read') //$result = restrictedArea($user, 'salaries|hrm', $object->id, 'user&user', $feature2); $ok = false; @@ -106,9 +108,13 @@ if ($user->hasRight('hrm', 'read')) { $ok = true; } -if ($user->hasRight('expensereport', 'lire') && ($user->id == $object->id || $user->hasRight('expensereport', 'readall'))) { +if ($user->hasRight('expensereport', 'readall') || ($user->hasRight('expensereport', 'readall') && in_array($object->id, $childids))) { + $ok = true; +} +if ($user->hasRight('holiday', 'readall') || ($user->hasRight('holiday', 'read') && in_array($object->id, $childids))) { $ok = true; } +var_dump($ok); if (!$ok) { accessforbidden(); } @@ -277,8 +283,6 @@ $form = new Form($db); $formcompany = new FormCompany($db); -$childids = $user->getAllChildIds(1); - $person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; $title = $person_name." - ".$langs->trans('BankAccounts'); $help_url = ''; From 796b8552e3a713afdb064db128ea4846eb51d120 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Jan 2025 15:23:26 +0100 Subject: [PATCH 29/55] Fix var_dump --- htdocs/user/bank.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 8f534756aa49a..15117a5daecd7 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -114,7 +114,6 @@ if ($user->hasRight('holiday', 'readall') || ($user->hasRight('holiday', 'read') && in_array($object->id, $childids))) { $ok = true; } -var_dump($ok); if (!$ok) { accessforbidden(); } From 39fe6c20b61df23e14eba9664ad886cdc5aa95c1 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 11 Jan 2025 04:55:51 +0100 Subject: [PATCH 30/55] FIX #32339 Delete a loan settlement is partial --- htdocs/loan/class/paymentloan.class.php | 41 ++++++++----------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 08346ad502bc8..4ba09c30bd450 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2015-2023 Frederic France - * Copyright (C) 2020 Maxime DEMAREST +/* Copyright (C) 2014-2025 Alexandre Spangaro + * Copyright (C) 2015-2023 Frederic France + * Copyright (C) 2020 Maxime DEMAREST * * 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 @@ -102,6 +102,10 @@ class PaymentLoan extends CommonObject public $label; public $paymenttype; public $bank_account; + + /** + * @var int + */ public $bank_line; @@ -386,20 +390,17 @@ public function update($user = null, $notrigger = 0) */ public function delete($user, $notrigger = 0) { - global $conf, $langs; $error = 0; $this->db->begin(); - if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; - $sql .= " WHERE type='payment_loan' AND url_id=".((int) $this->id); - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { + if ($this->bank_line > 0) { + $accline = new AccountLine($this->db); + $accline->fetch($this->bank_line); + $result = $accline->delete($user); + if ($result < 0) { + $this->errors[] = $accline->error; $error++; - $this->errors[] = "Error ".$this->db->lasterror(); } } @@ -430,22 +431,6 @@ public function delete($user, $notrigger = 0) } } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { From eebea4ad80c698f3d9fd79820949ef781d4bc532 Mon Sep 17 00:00:00 2001 From: PsyCrow <93346975+PsyCrow-code@users.noreply.github.com> Date: Sat, 11 Jan 2025 00:22:47 -0600 Subject: [PATCH 31/55] Update modAdherent.class.php PHP Warning: Deprecated dynamic property $enabled --- htdocs/core/modules/modAdherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index fa4289e3174f3..0994133905a92 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -414,7 +414,7 @@ public function __construct($db) 'unitfrequency'=> 3600 * 24, 'priority'=>50, 'status'=>1, - 'test'=>'$conf->adherent->enabled', + 'test'=>'isModEnabled("adherent")', 'datestart'=>$datestart ), ); From 2b77879297be45bff7111c6043ef9914b5a3598d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 11 Jan 2025 10:34:01 +0100 Subject: [PATCH 32/55] FIX missing edit extrafields inline for member card --- htdocs/adherents/card.php | 21 +++++++++++++++++++++ htdocs/core/tpl/extrafields_view.tpl.php | 3 +++ 2 files changed, 24 insertions(+) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index ab5fe37bff3e1..53aa27fe06901 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -846,6 +846,27 @@ } } + if ($action == 'update_extras' && $user->hasRight('adherent', 'creer')) { + $object->oldcopy = dol_clone($object, 2); + $attribute_name = GETPOST('attribute', 'restricthtml'); + + // Fill array 'array_options' with data from update form + $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name); + if ($ret < 0) { + $error++; + } + if (!$error) { + $result = $object->updateExtraField($attribute_name, 'MEMBER_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } + if ($error) { + $action = 'edit_extras'; + } + } + // SPIP Management if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_del_spip' && $confirm == 'yes') { if (!count($object->errors)) { diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 0c9bac901b711..10481b4ad1059 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -197,6 +197,9 @@ if ($object->element == 'salary') { $permok = $user->hasRight('salaries', 'read'); } + if ($object->element == 'member') { + $permok = $user->hasRight('adherent', 'creer'); + } $isdraft = ((isset($object->statut) && $object->statut == 0) || (isset($object->status) && $object->status == 0)); if (($isdraft || !empty($extrafields->attributes[$object->table_element]['alwayseditable'][$tmpkeyextra])) From 56efa6743248743872739379e24b8adb4a650a7c Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Sun, 12 Jan 2025 03:31:01 +0200 Subject: [PATCH 33/55] Update box_graph_product_distribution.php --- htdocs/core/boxes/box_graph_product_distribution.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 8724b16b02a15..f6a8b850b9399 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -165,7 +165,7 @@ public function loadBox($max = 5) if (empty($data2)) { $showpointvalue = 0; $nocolor = 1; - $data2 = array(array(0=>$langs->trans("None"), 1=>1)); + $data2 = array(array(0=>$langs->transnoentitiesnoconv("None"), 1=>1)); } $filenamenb = $dir."/prodserforpropal-".$year.".png"; @@ -228,7 +228,7 @@ public function loadBox($max = 5) if (empty($data3)) { $showpointvalue = 0; $nocolor = 1; - $data3 = array(array(0=>$langs->trans("None"), 1=>1)); + $data3 = array(array(0=>$langs->transnoentitiesnoconv("None"), 1=>1)); } $filenamenb = $dir."/prodserfororder-".$year.".png"; @@ -293,7 +293,7 @@ public function loadBox($max = 5) if (empty($data1)) { $showpointvalue = 0; $nocolor = 1; - $data1 = array(array(0=>$langs->trans("None"), 1=>1)); + $data1 = array(array(0=>$langs->transnoentitiesnoconv("None"), 1=>1)); } $filenamenb = $dir."/prodserforinvoice-".$year.".png"; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png'; From a5fe19212581dcf41883b3e1d7786d9ba3fa0a10 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 13 Jan 2025 13:31:38 +0100 Subject: [PATCH 34/55] FIX country id is not saved when we provide country_code only --- htdocs/societe/class/societe.class.php | 3 +++ test/phpunit/SocieteTest.php | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index df3bfd91a5df5..1f6e6377ca094 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1356,6 +1356,9 @@ public function update($id, User $user, $call_trigger = 1, $allowmodcodeclient = if (empty($id)) { $id = $this->id; } + if (empty($this->country_id) && !empty($this->country_code)) { + $this->country_id = dol_getIdFromCode($this->db, $this->country_code, 'c_country', 'code', 'rowid'); + } $error = 0; diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index ec05bc365a059..cd82b4155d333 100644 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -94,7 +94,12 @@ public function testSocieteCreate() $localobject = new Societe($db); $localobject->initAsSpecimen(); + + $localobject->country_id = 0; + $localobject->country_code = 'ES'; + $result = $localobject->create($user); + var_dump($localobject);exit; print __METHOD__." result=".$result."\n"; $this->assertLessThanOrEqual($result, 0); From a25ea27c6b59c13795caaf78ddb074412fedd549 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 13 Jan 2025 21:25:36 +0100 Subject: [PATCH 35/55] Debug v21 --- .../class/conferenceorboothattendee.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 8512701a0bb6d..8a7fd4a3b91c9 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -489,9 +489,9 @@ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.rowid' || $key == 't.fk_soc' || $key == 't.fk_project' || $key == 't.fk_actioncomm') { - $sqlwhere[] = $key.'='.((int) $value); - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key." = '".$this->db->idate($value)."'"; + $sqlwhere[] = $this->db->sanitize($key).' = '.((int) $value); + } elseif (!empty($this->fields[$key]) && in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'"; } elseif ($key == 'customsql') { $sqlwhere[] = $value; } elseif (strpos($value, '%') === false) { From 11d4b973e04727848bfd6d914505f5c89ab9012d Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 14 Jan 2025 10:35:44 +0100 Subject: [PATCH 36/55] Add log --- .../modules/security/generate/modGeneratePassNone.class.php | 2 ++ .../modules/security/generate/modGeneratePassPerso.class.php | 2 ++ .../modules/security/generate/modGeneratePassStandard.class.php | 2 ++ 3 files changed, 6 insertions(+) diff --git a/htdocs/core/modules/security/generate/modGeneratePassNone.class.php b/htdocs/core/modules/security/generate/modGeneratePassNone.class.php index e5f1f77c00c8e..40817c5ca09a7 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassNone.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassNone.class.php @@ -98,6 +98,8 @@ public function getNewGeneratedPassword() */ public function validatePassword($password) { + dol_syslog("modGeneratePassNone::validatePassword"); + return 1; } } diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php index de7096bb1764e..a11f37e42377b 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php @@ -221,6 +221,8 @@ public function validatePassword($password) $this->initAll(); // For the case this method is called alone + dol_syslog("modGeneratePassPerso::validatePassword"); + $password_a = preg_split('//u', $password, 0, PREG_SPLIT_NO_EMPTY); $maj = preg_split('//u', $this->Maj, 0, PREG_SPLIT_NO_EMPTY); $num = preg_split('//u', $this->Nb, 0, PREG_SPLIT_NO_EMPTY); diff --git a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php index 53f40260dbc7d..c363f1c050b3e 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php @@ -125,6 +125,8 @@ public function validatePassword($password) { global $langs; + dol_syslog("modGeneratePassStandard::validatePassword"); + if (dol_strlen($password) < $this->length2) { $langs->load("other"); $this->error = $langs->trans("YourPasswordMustHaveAtLeastXChars", $this->length2); From ec639e13555d487d4b25432ba13eada1a9ad2593 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 14 Jan 2025 10:44:46 +0100 Subject: [PATCH 37/55] Fix trans --- htdocs/langs/en_US/website.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 63725bae5cc4e..b839978b0a9f5 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -307,7 +307,7 @@ yourCompanyInformation=Your company information emailAlreadyRegistered=This email is already registered. firstnameContainsLettersOnly=Firstname must contain letters and spaces only lastnameContainsLettersOnly=Lastname must contain letters and spaces only -passwordCriteria=Password must meet the following criteria:
- 12 characters
- 1 uppercase letter
- 1 digit
- No special characters
- Avoid repeating characters more than 3 times
+passwordCriteria=Password must meet the following criteria:
- At least 12 characters
- At lest 1 uppercase letter
- At least 1 digit
- At last 1 special characters
- Avoid repeating characters more than 3 times
errorOccurred=An error has occurred. accountCreation=Create an account errorsOccurred=There are %s error%s From 003424f6cccdae09e8eb7f162f75c663c3562f4d Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 13 Jan 2025 02:10:37 +0100 Subject: [PATCH 38/55] Fix: Correct $search_ref typo into $search_ref_ext --- htdocs/contact/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 48d54d40f5fcc..9661927d24018 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -12,7 +12,7 @@ * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2019 Josep Lluís Amador * Copyright (C) 2020 Open-Dsi - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Benjamin Falière * * This program is free software; you can redistribute it and/or modify @@ -368,7 +368,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_all = ""; $search_id = ''; - $search_ref = ''; + $search_ref_ext = ''; $search_firstlast_only = ""; $search_lastname = ""; $search_firstname = ""; @@ -866,8 +866,8 @@ if ($search_id > 0) { $param .= "&search_id=".((int) $search_id); } -if ($search_ref) { - $param .= "&search_ref=".urlencode($search_ref); +if ($search_ref_ext) { + $param .= "&search_ref_ext=".urlencode($search_ref_ext); } if ($search_lastname != '') { $param .= '&search_lastname='.urlencode($search_lastname); From 5701d5c6f67e130d60dd8274c9aeb7280eaf8418 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 14 Jan 2025 12:02:52 +0100 Subject: [PATCH 39/55] Debug v21 --- .../eventorganization/class/conferenceorbooth.class.php | 2 +- htdocs/public/eventorganization/attendee_new.php | 4 ++-- htdocs/public/eventorganization/subscriptionok.php | 2 +- htdocs/public/project/suggestbooth.php | 4 ++-- htdocs/public/project/suggestconference.php | 4 ++-- htdocs/public/project/viewandvote.php | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 2defceeee7256..12245ab9643ab 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -291,7 +291,7 @@ public function fetch($id, $ref = null, $ref_ext = '', $email_msgid = '', $loadr $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_new.php?id='.urlencode((string) ($id)).'&type=conf'; - $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.$id, '2'); + $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $id), 'md5'); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); /*$this->fields['pubregister'] = array('type'=>'url', 'label'=>$langs->trans("PublicAttendeeSubscriptionPage"), 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>1); diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index d3099bbc36bee..70a22f644e46f 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -362,7 +362,7 @@ function llxFooterVierge() // If the registration has already been paid for this attendee if (!empty($confattendee->date_subscription) && !empty($confattendee->amount)) { - $securekeyurl = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.$id, 'master'); + $securekeyurl = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.((int) $id), 'md5'); $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.((int) $id).'&securekey='.urlencode($securekeyurl); $mesg = $langs->trans("RegistrationAndPaymentWereAlreadyRecorded", $email); @@ -698,7 +698,7 @@ function llxFooterVierge() dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); } - $securekeyurl = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.$id, '2'); + $securekeyurl = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.((int) $id), 'md5'); $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.((int) $id).'&securekey='.urlencode($securekeyurl); header("Location: ".$redirection); diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php index a1fe0017a3aad..5b3be5058eb6f 100644 --- a/htdocs/public/eventorganization/subscriptionok.php +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -81,7 +81,7 @@ // Security check $id = GETPOSTINT("id"); $securekeyreceived = GETPOST("securekey"); -$securekeytocompare = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.$id, '2'); +$securekeytocompare = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.((int) $id), 'md5'); if ($securekeyreceived != $securekeytocompare) { print $langs->trans('MissingOrBadSecureKey'); diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php index 949bb286c48a8..9247e6d9159f8 100644 --- a/htdocs/public/project/suggestbooth.php +++ b/htdocs/public/project/suggestbooth.php @@ -94,7 +94,7 @@ // Security check $securekeyreceived = GETPOST('securekey', 'alpha'); -$securekeytocompare = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.$id, 'md5'); +$securekeytocompare = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.((int) $id), 'md5'); if ($securekeytocompare != $securekeyreceived) { print $langs->trans('MissingOrBadSecureKey'); @@ -550,7 +550,7 @@ function llxFooterVierge() dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); } - $securekeyurl = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.$id, '2'); + $securekeyurl = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.((int) $id), 'md5'); $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$id.'&securekey='.$securekeyurl; header("Location: ".$redirection); exit; diff --git a/htdocs/public/project/suggestconference.php b/htdocs/public/project/suggestconference.php index fcc9dfc6025d0..e3ddf9c426044 100644 --- a/htdocs/public/project/suggestconference.php +++ b/htdocs/public/project/suggestconference.php @@ -94,7 +94,7 @@ // Security check $securekeyreceived = GETPOST('securekey', 'alpha'); -$securekeytocompare = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.$id, 'md5'); +$securekeytocompare = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.((int) $id), 'md5'); if ($securekeytocompare != $securekeyreceived) { print $langs->trans('MissingOrBadSecureKey'); @@ -486,7 +486,7 @@ function llxFooterVierge() if (!$error) { $db->commit(); - $securekeyurl = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.$id, '2'); + $securekeyurl = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.((int) $id), 'md5'); $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.((int) $id).'&securekey='.urlencode($securekeyurl); header("Location: ".$redirection); exit; diff --git a/htdocs/public/project/viewandvote.php b/htdocs/public/project/viewandvote.php index 5b9404e2515e3..250a7b4c5df08 100644 --- a/htdocs/public/project/viewandvote.php +++ b/htdocs/public/project/viewandvote.php @@ -81,7 +81,7 @@ $action = GETPOST('action', 'aZ09'); $id = GETPOST('id'); $securekeyreceived = GETPOST("securekey"); -$securekeytocompare = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.$id, 'md5'); +$securekeytocompare = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'conferenceorbooth'.((int) $id), 'md5'); if ($securekeytocompare != $securekeyreceived) { print $langs->trans('MissingOrBadSecureKey'); @@ -173,10 +173,10 @@ */ // Get vote result -$idvote = GETPOST("vote"); -$hashedvote = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY') . 'vote'.$idvote); +$idvote = GETPOSTINT("vote"); +$hashedvote = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'vote'.$idvote); -if (strlen($idvote)) { +if ($idvote > 0) { if (in_array($hashedvote, $listofvotes)) { // Has already voted $votestatus = 'ko'; From 9af7eaf08ccae30b58c010754db5f5b89e9ea3f0 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 14 Jan 2025 15:32:08 +0100 Subject: [PATCH 40/55] Use PHP version from check.php --- .github/workflows/pre-commit.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 1ae4d3387f8fe..973b2ddbc1309 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -62,6 +62,12 @@ jobs: # files: | # **.php + - name: Extract PHP version + id: extract-php-version + run: | + PHP_VERSION=$(sed -n 's/.*\$arrayphpmaxversionwarning\s*=\s*array\s*(\s*\([0-9]\+\)\s*,\s*\([0-9]\+\).*/\1.\2/p' htdocs/install/check.php) + echo "PHP_VERSION=$PHP_VERSION" >> $GITHUB_ENV + - name: Setup PHPCS uses: shivammathur/setup-php@v2 # Install when we're going to run phpcs @@ -76,7 +82,7 @@ jobs: ) ) with: - php-version: 8.1 + php-version: ${{ env.PHP_VERSION }} # Version from check.php coverage: none # disable xdebug, pcov tools: phpcs From 7869e45954684977b0104d3ac6ade8293c52e919 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 14 Jan 2025 15:39:05 +0100 Subject: [PATCH 41/55] Move installation of php before pre-commit run --- .github/workflows/pre-commit.yml | 39 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 973b2ddbc1309..d83f237e09c9f 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -42,25 +42,6 @@ jobs: with: path: ~/.cache/pre-commit/ key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} - # Run all the precommit tools (defined into pre-commit-config.yaml). - # We can force exclusion of some of them here. - - name: Run pre-commit hooks - env: - # SKIP is used by pre-commit to not execute certain hooks - SKIP: no-commit-to-branch,php-cs,php-cbf,trailing-whitespace,end-of-file-fixer,check-json,check-executables-have-shebangs,check-shebang-scripts-are-executable,beautysh,yamllint,shellcheck - run: | - set -o pipefail - pre-commit gc - pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG} - - # The next uses git, which is slow for a bit repo. - # - name: Get all changed php files (if PR) - # id: changed-php - # uses: tj-actions/changed-files@v42 - # if: github.event_name == 'pull_request' - # with: - # files: | - # **.php - name: Extract PHP version id: extract-php-version @@ -86,6 +67,26 @@ jobs: coverage: none # disable xdebug, pcov tools: phpcs + # Run all the precommit tools (defined into pre-commit-config.yaml). + # We can force exclusion of some of them here. + - name: Run pre-commit hooks + env: + # SKIP is used by pre-commit to not execute certain hooks + SKIP: no-commit-to-branch,php-cs,php-cbf,trailing-whitespace,end-of-file-fixer,check-json,check-executables-have-shebangs,check-shebang-scripts-are-executable,beautysh,yamllint,shellcheck + run: | + set -o pipefail + pre-commit gc + pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG} + + # The next uses git, which is slow for a bit repo. + # - name: Get all changed php files (if PR) + # id: changed-php + # uses: tj-actions/changed-files@v42 + # if: github.event_name == 'pull_request' + # with: + # files: | + # **.php + - name: Run some pre-commit hooks on selected changed files only if: steps.changed-php.outputs.any_changed == 'true' env: From 20f2293c013f27c29f557364148135e9ad0528ab Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 14 Jan 2025 15:43:55 +0100 Subject: [PATCH 42/55] Always install expected php version --- .github/workflows/pre-commit.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index d83f237e09c9f..ddf13c8a0706c 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -51,17 +51,7 @@ jobs: - name: Setup PHPCS uses: shivammathur/setup-php@v2 - # Install when we're going to run phpcs - if: | - steps.changed-php.outputs.any_changed == 'true' - || - ( - github.event_name == 'push' - && ( - github.event.ref == 'refs/heads/develop' - || endsWith(github.event.ref, '.0') - ) - ) + # Install proper php version, and also install phpcs which may be needed with: php-version: ${{ env.PHP_VERSION }} # Version from check.php coverage: none # disable xdebug, pcov From 24c482b1505356b5a755eb604185b9dc9722e59e Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 14 Jan 2025 16:51:03 +0100 Subject: [PATCH 43/55] css --- htdocs/compta/facture/list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a17d7309b1559..238121bb53355 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1415,7 +1415,7 @@ } // Ref if (!empty($arrayfields['f.ref']['checked'])) { - print '
'; } @@ -1439,7 +1439,7 @@ } //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order. // @phan-suppress-next-line PhanPluginSuspiciousParamOrder - print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); + print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth75'); print ''; } // Invoice Subtype @@ -2505,7 +2505,7 @@ // Author if (!empty($arrayfields['u.login']['checked'])) { - print ''; +} // Date creation if (!empty($arrayfields['p.datec']['checked'])) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date creation if (!empty($arrayfields['p.datec']['checked'])) { print ''; +} // Creation date if (!empty($arrayfields['s.datec']['checked'])) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } // Date creation if (!empty($arrayfields['s.datec']['checked'])) { print '
'.$langs->trans("BoxTitleLastModifiedDonations", $max); - print '...'; + print '...'; print ''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").'
'; + print ''; print ''; print ''; + print ''; if ($userstatic->id) { print $userstatic->getNomUrl(-1); } else { From 800d16bc187715fde158bdab5cd7d71e9520417e Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 14 Jan 2025 16:57:14 +0100 Subject: [PATCH 44/55] Doc --- htdocs/core/class/doleditor.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 030713957a3eb..3129713147952 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -103,7 +103,7 @@ class DolEditor * @param string $toolbarname Name of the toolbar set to use ('dolibarr_details[_encoded]'=the less featured, 'dolibarr_notes[_encoded]' for notes content, 'dolibarr_mailings[_encoded]' for emailing content, 'dolibarr_readonly'). * @param string $toolbarlocation Deprecated. Not used * @param bool $toolbarstartexpanded Bar is visible or not at start - * @param bool|int $uselocalbrowser Enabled to add links to local object with a local media filemanager. If false, only external images URL can be added into content, or images saved inline with src="data:..." with a cut/paste. + * @param bool|int $uselocalbrowser Enabled to add links to local object with a local media filemanager. -1=auto, false=only external images URL can be added into content, or images saved inline with src="data:..." with a cut/paste. * @param bool|int|string $okforextendededitor 1 or True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. * Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave". * @param int $rows Size of rows for textarea tool From 258411e8707c29935e232b837a8babfe0523d5f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 14 Jan 2025 22:05:08 +0100 Subject: [PATCH 45/55] Debug v21 --- htdocs/commande/class/commande.class.php | 4 ++-- htdocs/core/customreports.php | 11 ++++++----- htdocs/core/lib/customreports.lib.php | 10 ++++++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index a7f395116b036..630e9fab8d7c5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -336,7 +336,7 @@ class Commande extends CommonOrder 'fk_mode_reglement' => array('type' => 'integer', 'label' => 'PaymentMode', 'enabled' => 1, 'visible' => -1, 'position' => 185), 'date_livraison' => array('type' => 'date', 'label' => 'DateDeliveryPlanned', 'enabled' => 1, 'visible' => -1, 'position' => 190, 'csslist' => 'nowraponall'), 'fk_shipping_method' => array('type' => 'integer', 'label' => 'ShippingMethod', 'enabled' => 1, 'visible' => -1, 'position' => 195), - 'fk_warehouse' => array('type' => 'integer:Entrepot:product/stock/class/entrepot.class.php', 'label' => 'Fk warehouse', 'enabled' => 'isModEnabled("stock")', 'visible' => -1, 'position' => 200), + 'fk_warehouse' => array('type' => 'integer:Entrepot:product/stock/class/entrepot.class.php', 'label' => 'DefaultWarehouse', 'enabled' => 'isModEnabled("stock")', 'visible' => -1, 'position' => 200, 'nodepth' => 1), 'fk_availability' => array('type' => 'integer', 'label' => 'Availability', 'enabled' => 1, 'visible' => -1, 'position' => 205), 'fk_input_reason' => array('type' => 'integer', 'label' => 'InputReason', 'enabled' => 1, 'visible' => -1, 'position' => 210), //'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>-1, 'position'=>215), @@ -856,7 +856,7 @@ public function cloture($user, $notrigger = 0) */ public function cancel($idwarehouse = -1) { - global $conf, $user, $langs; + global $user, $langs; $error = 0; diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 59a9f25598cc5..f0f1cd2271244 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -32,7 +32,7 @@ * include DOL_DOCUMENT_ROOT.'/core/customreports.php'; */ - /** +/** * @var Conf $conf * @var DoliDB $db * @var HookManager $hookmanager @@ -322,6 +322,7 @@ $MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1); $SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1); +$arrayoffilterfields = array(); $arrayofmesures = array(); $arrayofxaxis = array(); $arrayofgroupby = array(); @@ -375,6 +376,10 @@ } } +$count = 0; +$arrayoffilterfields = fillArrayOfFilterFields($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayoffilterfields, 0, $count); +$arrayoffilterfields = dol_sort_array($arrayoffilterfields, 'position', 'asc', 0, 0, 1); + $count = 0; $arrayofmesures = fillArrayOfMeasures($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofmesures, 0, $count); $arrayofmesures = dol_sort_array($arrayofmesures, 'position', 'asc', 0, 0, 1); @@ -387,10 +392,6 @@ $arrayofgroupby = fillArrayOfGroupBy($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofgroupby, 0, $count); $arrayofgroupby = dol_sort_array($arrayofgroupby, 'position', 'asc', 0, 0, 1); -$count = 0; -$arrayoffilterfields = fillArrayOfFilterFields($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayoffilterfields, 0, $count); -$arrayoffilterfields = dol_sort_array($arrayoffilterfields, 'position', 'asc', 0, 0, 1); - // Check parameters if ($action == 'viewgraph') { diff --git a/htdocs/core/lib/customreports.lib.php b/htdocs/core/lib/customreports.lib.php index 553e3f3681b5d..574faafeabb42 100644 --- a/htdocs/core/lib/customreports.lib.php +++ b/htdocs/core/lib/customreports.lib.php @@ -523,10 +523,12 @@ function fillArrayOfFilterFields($object, $tablealias, $labelofobject, &$arrayof { global $langs, $extrafields, $db; + $MAXLEVEL = 2; + if (empty($object)) { // Protection against bad use of method return array(); } - if ($level >= 3) { // Limit scan on 2 levels max + if ($level > $MAXLEVEL) { // Limit scan on 2 levels max return $arrayoffields; } @@ -612,7 +614,11 @@ function fillArrayOfFilterFields($object, $tablealias, $labelofobject, &$arrayof if (class_exists($newobject)) { $tmpobject = new $newobject($db); $count++; - $arrayoffields = fillArrayOfFilterFields($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayoffields, $level + 1, $count, $tablepath); + if (!empty($val['nodepth'])) { + $arrayoffields = fillArrayOfFilterFields($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayoffields, $MAXLEVEL, $count, $tablepath); + } else { + $arrayoffields = fillArrayOfFilterFields($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayoffields, $level + 1, $count, $tablepath); + } } else { print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."
\n"; } From 9587403e0abc8d78b5f605823489b73d1897573b Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 14 Jan 2025 22:16:34 +0100 Subject: [PATCH 46/55] add a hook on vat rate --- htdocs/core/class/html.form.class.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 29de7398bac4b..ede456909d5df 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6906,11 +6906,28 @@ public function load_cache_vatrates($country_code) public function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = null, $societe_acheteuse = null, $idprod = 0, $info_bits = 0, $type = '', $options_only = false, $mode = 0, $type_vat = 0) { // phpcs:enable - global $langs, $mysoc; + global $langs, $mysoc, $hookmanager; $langs->load('errors'); $return = ''; + // Bypass the default method + $hookmanager->initHooks(array('commonobject')); + $info_bits == 1 ? $is_npr = 1 : $is_npr = 0; + $parameters = array( + 'seller' => $societe_vendeuse, + 'buyer' => $societe_acheteuse, + 'idprod' => $idprod, + 'is_npr' => $is_npr, + 'type' => $type, + 'options_only' => $options_only, + 'mode' => $mode, + 'type_vat' => $type_vat + ); + $reshook = $hookmanager->executeHooks('load_tva', $parameters); + if ($reshook > 0) { + return $hookmanager->resPrint; + } // Define defaultnpr, defaultttx and defaultcode $defaultnpr = ($info_bits & 0x01); From 01be602fb19ec73984056593b008354526c7b057 Mon Sep 17 00:00:00 2001 From: Quentin VIAL--GOUTEYRON Date: Wed, 15 Jan 2025 08:42:14 +0100 Subject: [PATCH 47/55] FIX Issue 32460 db prefix module builder --- .../modules/mailings/modules_mailings.php | 22 +++++++++---------- htdocs/modulebuilder/template/admin/setup.php | 2 +- .../template/class/api_mymodule.class.php | 8 +++---- .../template/class/myobject.class.php | 8 +++---- .../mailing_mymodule_selector1.modules.php | 4 ++-- .../core/modules/modMyModule.class.php | 18 +++++++-------- .../mymodule/mod_myobject_standard.php | 4 ++-- .../modulebuilder/template/mymoduleindex.php | 6 ++--- .../modulebuilder/template/myobject_list.php | 10 ++++----- .../template/scripts/mymodule.php | 2 +- 10 files changed, 42 insertions(+), 42 deletions(-) diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index e45bd655ef3f6..9605cbe901960 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -169,14 +169,14 @@ public function update_nb($mailing_id) { // phpcs:enable // Mise a jour nombre de destinataire dans table des mailings - $sql = "SELECT COUNT(*) nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; + $sql = "SELECT COUNT(*) nb FROM ".$this->db->prefix()."mailing_cibles"; $sql .= " WHERE fk_mailing = ".((int) $mailing_id); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); $nb = $obj->nb; - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing"; + $sql = "UPDATE ".$this->db->prefix()."mailing"; $sql .= " SET nbemail = ".((int) $nb)." WHERE rowid = ".((int) $mailing_id); if (!$this->db->query($sql)) { dol_syslog($this->db->error()); @@ -208,7 +208,7 @@ public function addTargetsToDatabase($mailing_id, $cibles) $num = count($cibles); foreach ($cibles as $targetarray) { if (!empty($targetarray['email'])) { // avoid empty email address - $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles"; + $sql = "INSERT INTO ".$this->db->prefix()."mailing_cibles"; $sql .= " (fk_mailing,"; $sql .= " fk_contact,"; $sql .= " lastname, firstname, email, other, source_url, source_id,"; @@ -244,27 +244,27 @@ public function addTargetsToDatabase($mailing_id, $cibles) /* //Update the status to show thirdparty mail that don't want to be contacted anymore' - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql = "UPDATE ".$this->db->prefix()."mailing_cibles"; $sql .= " SET statut=3"; - $sql .= " WHERE fk_mailing = ".((int) $mailing_id)." AND email in (SELECT email FROM ".MAIN_DB_PREFIX."societe where fk_stcomm=-1)"; + $sql .= " WHERE fk_mailing = ".((int) $mailing_id)." AND email in (SELECT email FROM ".$this->db->prefix()."societe where fk_stcomm=-1)"; $sql .= " AND source_type='thirdparty'"; dol_syslog(__METHOD__.": mailing update status to display thirdparty mail that do not want to be contacted"); $result=$this->db->query($sql); //Update the status to show contact mail that don't want to be contacted anymore' - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql = "UPDATE ".$this->db->prefix()."mailing_cibles"; $sql .= " SET statut=3"; - $sql .= " WHERE fk_mailing = ".((int) $mailing_id)." AND source_type='contact' AND (email in (SELECT sc.email FROM ".MAIN_DB_PREFIX."socpeople AS sc "; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid=sc.fk_soc WHERE s.fk_stcomm=-1 OR no_email=1))"; + $sql .= " WHERE fk_mailing = ".((int) $mailing_id)." AND source_type='contact' AND (email in (SELECT sc.email FROM ".$this->db->prefix()."socpeople AS sc "; + $sql .= " INNER JOIN ".$this->db->prefix()."societe s ON s.rowid=sc.fk_soc WHERE s.fk_stcomm=-1 OR no_email=1))"; dol_syslog(__METHOD__.": mailing update status to display contact mail that do not want to be contacted",LOG_DEBUG); $result=$this->db->query($sql); */ if (empty($this->evenunsubscribe)) { - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql = "UPDATE ".$this->db->prefix()."mailing_cibles as mc"; $sql .= " SET mc.statut = 3"; $sql .= " WHERE mc.fk_mailing = ".((int) $mailing_id); - $sql .= " AND EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = mc.email and mu.entity = ".((int) $conf->entity).")"; + $sql .= " AND EXISTS (SELECT rowid FROM ".$this->db->prefix()."mailing_unsubscribe as mu WHERE mu.email = mc.email and mu.entity = ".((int) $conf->entity).")"; dol_syslog(__METHOD__.":mailing update status to display emails that do not want to be contacted anymore", LOG_DEBUG); $result = $this->db->query($sql); @@ -291,7 +291,7 @@ public function addTargetsToDatabase($mailing_id, $cibles) public function clear_target($mailing_id) { // phpcs:enable - $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles"; + $sql = "DELETE FROM ".$this->db->prefix()."mailing_cibles"; $sql .= " WHERE fk_mailing = ".((int) $mailing_id); if (!$this->db->query($sql)) { diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index d7d87fe8f1e22..306a28aa5b92e 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -478,7 +478,7 @@ // Load array def with activated templates $def = array(); $sql = "SELECT nom"; - $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; + $sql .= " FROM ".$db->prefix()."document_model"; $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 14b89da504c7b..e67def67c0caf 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -136,8 +136,8 @@ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, } $sql = "SELECT t.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." AS t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmpobject->table_element."_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields + $sql .= " FROM ".$this->db->prefix().$tmpobject->table_element." AS t"; + $sql .= " LEFT JOIN ".$this->db->prefix().$tmpobject->table_element."_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields $sql .= " WHERE 1 = 1"; if ($tmpobject->ismultientitymanaged) { $sql .= ' AND t.entity IN ('.getEntity($tmpobject->element).')'; @@ -148,9 +148,9 @@ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, // Search on sale representative if ($search_sale && $search_sale != '-1') { if ($search_sale == -2) { - $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)"; + $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".$this->db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)"; } elseif ($search_sale > 0) { - $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).")"; + $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".$this->db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).")"; } } if ($sqlfilters) { diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index f9251809d17bb..7c43d256d17c3 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -587,7 +587,7 @@ public function validate($user, $notrigger = 0) if (!empty($num)) { // Validate - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql = "UPDATE ".$this->db->prefix().$this->table_element; $sql .= " SET "; if (!empty($this->fields['ref'])) { $sql .= " ref = '".$this->db->escape($num)."',"; @@ -625,14 +625,14 @@ public function validate($user, $notrigger = 0) // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'myobject/".$this->db->escape($this->newref)."'"; + $sql = 'UPDATE '.$this->db->prefix()."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'myobject/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'myobject/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (!$resql) { $error++; $this->error = $this->db->lasterror(); } - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'myobject/".$this->db->escape($this->newref)."'"; + $sql = 'UPDATE '.$this->db->prefix()."ecm_files set filepath = 'myobject/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filepath = 'myobject/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (!$resql) { @@ -1026,7 +1026,7 @@ public function info($id) if (!empty($this->fields['fk_user_valid'])) { $sql .= ", fk_user_valid"; } - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql .= " FROM ".$this->db->prefix().$this->table_element." as t"; $sql .= " WHERE t.rowid = ".((int) $id); $result = $this->db->query($sql); diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailing_mymodule_selector1.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailing_mymodule_selector1.modules.php index a14f339306b72..b55fa3e6fe31a 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailing_mymodule_selector1.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailing_mymodule_selector1.modules.php @@ -111,7 +111,7 @@ public function add_to_target($mailing_id) $j = 0; $sql = "SELECT rowid as id, firstname, lastname, email"; - $sql .= " FROM ".MAIN_DB_PREFIX."myobject"; + $sql .= " FROM ".$this->db->prefix()."myobject"; $sql .= " WHERE email IS NOT NULL AND email <> ''"; if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') { $sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'"; @@ -195,7 +195,7 @@ public function getSqlArrayForStats() public function getNbOfRecipients($sql = '') { $sql = "SELECT COUNT(DISTINCT(email)) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."myobject as p"; + $sql .= " FROM ".$this->db->prefix()."myobject as p"; $sql .= " WHERE email IS NOT NULL AND email <> ''"; $a = parent::getNbOfRecipients($sql); diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 9a0e08299724a..2a894544b8e07 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -228,7 +228,7 @@ public function __construct($db) // Label of tables 'tablib' => array("Table1", "Table2", "Table3"), // Request to select fields - 'tabsql' => array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), + 'tabsql' => array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.$this->db->prefix().'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.$this->db->prefix().'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.$this->db->prefix().'table3 as f'), // Sort order 'tabsqlsort' => array("label ASC", "label ASC", "label ASC"), // List of fields (result of select to show dictionary) @@ -411,8 +411,8 @@ public function __construct($db) //$this->export_examplevalues_array[$r] = array('t.field' => 'Example'); //$this->export_help_array[$r] = array('t.field' => 'FieldDescHelp'); $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'mymodule_myobject as t'; - //$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'mymodule_myobject_line as tl ON tl.fk_myobject = t.rowid'; + $this->export_sql_end[$r] =' FROM '.$this->db->prefix().'mymodule_myobject as t'; + //$this->export_sql_end[$r] .=' LEFT JOIN '.$this->db->prefix().'mymodule_myobject_line as tl ON tl.fk_myobject = t.rowid'; $this->export_sql_end[$r] .=' WHERE 1 = 1'; $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; $r++; */ @@ -426,7 +426,7 @@ public function __construct($db) $this->import_code[$r] = $this->rights_class.'_'.$r; $this->import_label[$r] = 'MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->import_icon[$r] = $this->picto; - $this->import_tables_array[$r] = array('t' => MAIN_DB_PREFIX.'mymodule_myobject', 'extra' => MAIN_DB_PREFIX.'mymodule_myobject_extrafields'); + $this->import_tables_array[$r] = array('t' => $this->db->prefix().'mymodule_myobject', 'extra' => $this->db->prefix().'mymodule_myobject_extrafields'); $this->import_tables_creator_array[$r] = array('t' => 'fk_user_author'); // Fields to store import user id $import_sample = array(); $keyforclass = 'MyObject'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobject@mymodule'; @@ -434,7 +434,7 @@ public function __construct($db) $import_extrafield_sample = array(); $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php'; - $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'mymodule_myobject'); + $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.$this->db->prefix().'mymodule_myobject'); $this->import_regex_array[$r] = array(); $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); $this->import_updatekeys_array[$r] = array('t.ref' => 'Ref'); @@ -512,10 +512,10 @@ public function init($options = '') } $sql = array_merge($sql, array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity), - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")", - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity), - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")" + "DELETE FROM ".$this->db->prefix()."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity), + "INSERT INTO ".$this->db->prefix()."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")", + "DELETE FROM ".$this->db->prefix()."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity), + "INSERT INTO ".$this->db->prefix()."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")" )); } } diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php index 4d2329d8a2f85..98d9b5fbffec7 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php @@ -93,7 +93,7 @@ public function canBeActivated($object) $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql .= " FROM ".MAIN_DB_PREFIX."mymodule_myobject"; + $sql .= " FROM ".$db->prefix()."mymodule_myobject"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; if ($object->ismultientitymanaged == 1) { $sql .= " AND entity = ".$conf->entity; @@ -131,7 +131,7 @@ public function getNextValue($object) // first we get the max value $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql .= " FROM ".MAIN_DB_PREFIX."mymodule_myobject"; + $sql .= " FROM ".$db->prefix()."mymodule_myobject"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; if ($object->ismultientitymanaged == 1) { $sql .= " AND entity = ".$conf->entity; diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index 8ac978ddfa6fb..892231a8f01dc 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -132,8 +132,8 @@ $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql.= " FROM ".$db->prefix()."commande as c"; + $sql.= ", ".$db->prefix()."societe as s"; $sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " AND c.fk_statut = 0"; $sql.= " AND c.entity IN (".getEntity('commande').")"; @@ -204,7 +204,7 @@ // Last modified myobject if (isModEnabled('mymodule') && $user->hasRight('mymodule', 'read')) { $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."mymodule_myobject as s"; + $sql.= " FROM ".$db->prefix()."mymodule_myobject as s"; $sql.= " WHERE s.entity IN (".getEntity($myobjectstatic->element).")"; //if ($socid) $sql.= " AND s.rowid = $socid"; $sql .= " ORDER BY s.tms DESC"; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 864ad8adf9d04..85bf290801a42 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -317,10 +317,10 @@ $sqlfields = $sql; // $sql fields to remove for count total -$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."anothertable as rc ON rc.parent = t.rowid"; +$sql .= " FROM ".$db->prefix().$object->table_element." as t"; +//$sql .= " LEFT JOIN ".$db->prefix()."anothertable as rc ON rc.parent = t.rowid"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; + $sql .= " LEFT JOIN ".$db->prefix().$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } // Add table from hooks $parameters = array(); @@ -378,9 +378,9 @@ // Search on sale representative if ($search_sale && $search_sale != '-1') { if ($search_sale == -2) { - $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)"; + $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)"; } elseif ($search_sale > 0) { - $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).")"; + $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).")"; } } // Search on socid diff --git a/htdocs/modulebuilder/template/scripts/mymodule.php b/htdocs/modulebuilder/template/scripts/mymodule.php index 24978ec7f1560..8b19deb0a5e57 100644 --- a/htdocs/modulebuilder/template/scripts/mymodule.php +++ b/htdocs/modulebuilder/template/scripts/mymodule.php @@ -184,7 +184,7 @@ // An example of a direct SQL read without using the fetch method /* $sql = "SELECT field1, field2"; -$sql.= " FROM ".MAIN_DB_PREFIX."myobject"; +$sql.= " FROM ".$db->prefix()."myobject"; $sql.= " WHERE field3 = 'xxx'"; $sql.= " ORDER BY field1 ASC"; From 41bfe889a16c221c685558d481084d8c6f3b8499 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 15 Jan 2025 11:40:37 +0100 Subject: [PATCH 48/55] Try fix br into custom css --- htdocs/admin/ihm.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index af9b9ff5eec90..ede222b86f3c9 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -325,7 +325,10 @@ if ($mode == 'css') { //file_put_contents(DOL_DATA_ROOT.'/admin/customcss.css', $data); //dol_chmod(DOL_DATA_ROOT.'/admin/customcss.css'); - dolibarr_set_const($db, "MAIN_IHM_CUSTOM_CSS", GETPOST('MAIN_IHM_CUSTOM_CSS', 'restricthtml'), 'chaine', 0, '', $conf->entity); + $csscontent = GETPOST('MAIN_IHM_CUSTOM_CSS', 'restricthtml'); + $csscontent = dol_string_nohtmltag($csscontent, 2); + + dolibarr_set_const($db, "MAIN_IHM_CUSTOM_CSS", $csscontent, 'chaine', 0, '', $conf->entity); } $_SESSION["mainmenu"] = ""; // The menu manager may have changed From 0cf6b8b8a4bf0c53fb1ffac01753241108a26ea2 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 15 Jan 2025 11:40:39 +0100 Subject: [PATCH 49/55] Try fix br into custom css From 929e7047b9fc247ae47c0b48ac4f354328857144 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 15 Jan 2025 11:44:59 +0100 Subject: [PATCH 50/55] Fix message --- htdocs/admin/ihm.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index ede222b86f3c9..1ec7c21252fca 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -329,6 +329,8 @@ $csscontent = dol_string_nohtmltag($csscontent, 2); dolibarr_set_const($db, "MAIN_IHM_CUSTOM_CSS", $csscontent, 'chaine', 0, '', $conf->entity); + + setEventMessages($langs->trans("RecordSaved"), null); } $_SESSION["mainmenu"] = ""; // The menu manager may have changed From 9e8c52e2961af41da49fb0f2940786755904cea4 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 15 Jan 2025 12:10:36 +0100 Subject: [PATCH 51/55] Fix function not enabled --- htdocs/core/lib/functions.lib.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index df7b61f06c092..0dae150f1f6af 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8585,17 +8585,19 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = ' // We replace chars from a/A to z/Z encoded with numeric HTML entities with the real char so we won't loose the chars at the next step (preg_replace). // No need to use a loop here, this step is not to sanitize (this is done at next step, this is to try to save chars, even if they are // using a non conventionnal way to be encoded, to not have them sanitized just after) - $out = preg_replace_callback( - '/&#(x?[0-9][0-9a-f]+;?)/i', - /** - * @param string[] $m - * @return string - */ - static function ($m) { - return realCharForNumericEntities($m); - }, - $out - ); + if (function_exists('realCharForNumericEntities')) { // May not exist when main.inc.php not loaded, for example in a CLI context + $out = preg_replace_callback( + '/&#(x?[0-9][0-9a-f]+;?)/i', + /** + * @param string[] $m + * @return string + */ + static function ($m) { + return realCharForNumericEntities($m); + }, + $out + ); + } // Now we remove all remaining HTML entities starting with a number. We don't want such entities. $out = preg_replace('/&#x?[0-9]+/i', '', $out); // For example if we have javascript with an entities without the ; to hide the 'a' of 'javascript'. From ac049e1f23305fdee24b0d38395f032b0b64fd65 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 15 Jan 2025 12:13:23 +0100 Subject: [PATCH 52/55] Fix test --- test/phpunit/AllTests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 9eb4e51e7fa0b..0627951128622 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -48,7 +48,7 @@ print "Error: Default language for company to run tests must be set to en_US or auto. Current is ".$langs->defaultlang."\n"; exit(1); } -if (!isModEnabled('adherent')) { +if (!isModEnabled('member')) { print "Error: Module member must be enabled to have significant results.\n"; exit(1); } From 1b09d9abf614b69e4cbb32f886517284c11892cf Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 15 Jan 2025 14:00:11 +0100 Subject: [PATCH 53/55] Missing ip in list --- htdocs/contact/class/contact.class.php | 2 +- htdocs/contact/list.php | 24 ++++++++++++++++++++- htdocs/societe/list.php | 29 +++++++++++++++++++++++--- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index f6719809fbbd1..e2961594ea4eb 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -120,12 +120,12 @@ class Contact extends CommonObject 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 3, 'position' => 200, 'searchall' => 1), 'default_lang' => array('type' => 'varchar(6)', 'label' => 'Default lang', 'enabled' => 1, 'visible' => 3, 'position' => 205), 'canvas' => array('type' => 'varchar(32)', 'label' => 'Canvas', 'enabled' => 1, 'visible' => 3, 'position' => 210), + 'ip' => array('type' => 'ip', 'label' => 'IPAddress', 'enabled' => '1', 'position' => 700, 'notnull' => 0, 'visible' => '-2', 'comment' => 'ip used to create record (for public submission page)'), 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -1, 'position' => 300), 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 305), 'fk_user_creat' => array('type' => 'integer', 'label' => 'UserAuthor', 'enabled' => 1, 'visible' => 3, 'position' => 310), 'fk_user_modif' => array('type' => 'integer', 'label' => 'UserModif', 'enabled' => 1, 'visible' => 3, 'position' => 315), 'statut' => array('type' => 'tinyint(4)', 'label' => 'Status', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'position' => 500), - 'ip' => array('type' => 'varchar(250)', 'label' => 'Ip', 'enabled' => '1', 'position' => 700, 'notnull' => 0, 'visible' => '0', 'comment' => 'ip used to create record (for public submission page)'), 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -1, 'position' => 1000), ); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 9661927d24018..527449dec4a6d 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -486,7 +486,7 @@ $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,"; $sql .= " p.rowid, p.ref_ext, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email, p.birthday,"; $sql .= " p.socialnetworks, p.photo,"; -$sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_modification,"; +$sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.ip, p.datec as date_creation, p.tms as date_modification,"; $sql .= " p.import_key, p.fk_stcommcontact as stcomm_id, p.fk_prospectlevel,"; $sql .= " st.libelle as stcomm, st.picto as stcomm_picto,"; $sql .= " co.label as country, co.code as country_code"; @@ -1240,6 +1240,11 @@ $parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; +// IP +if (!empty($arrayfields['p.ip']['checked'])) { + print '
'; + print ''; @@ -1385,6 +1390,12 @@ $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; +// IP +if (!empty($arrayfields['p.ip']['checked'])) { + print_liste_field_titre($arrayfields['p.ip']['label'], $_SERVER["PHP_SELF"], "p.ip", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + $totalarray['nbfield']++; +} +// Date creation if (!empty($arrayfields['p.datec']['checked'])) { print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); $totalarray['nbfield']++; @@ -1754,6 +1765,17 @@ $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + + // IP creation + if (!empty($arrayfields['p.ip']['checked'])) { + print ''; + print dol_print_ip($obj->ip); + print ''; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index ab2571bfcfba1..ec7e8ba23a529 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -319,8 +319,9 @@ 's.fk_prospectlevel' => array('label' => "ProspectLevel", 'position' => 62, 'checked' => $checkprospectlevel), 's.fk_stcomm' => array('label' => "StatusProsp", 'position' => 63, 'checked' => $checkstcomm), 's2.nom' => array('label' => 'ParentCompany', 'position' => 64, 'checked' => 0), - 's.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 500), - 's.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 500), + 's.ip' => array('type'=>'ip', 'label' => "IPAddress", 'checked' => -2, 'position' => 500), + 's.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 501), + 's.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 505), 's.note_public' => array('label' => 'NotePublic', 'checked' => 0, 'position' => 520, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))), 's.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'position' => 521, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))), 's.status' => array('label' => "Status", 'checked' => 1, 'position' => 1000), @@ -569,7 +570,7 @@ $sql .= " s.entity,"; $sql .= " st.libelle as stcomm, st.picto as stcomm_picto, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status, s.note_private, s.note_public,"; $sql .= " s.email, s.phone, s.phone_mobile, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; -$sql .= " s.tms as date_modification, s.datec as date_creation, s.import_key,"; +$sql .= " s.ip, s.tms as date_modification, s.datec as date_creation, s.import_key,"; $sql .= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,s.price_level,"; $sql .= " s2.nom as name2,"; $sql .= " typent.code as typent_code,"; @@ -1556,6 +1557,11 @@ $parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; +// IP address +if (!empty($arrayfields['s.ip']['checked'])) { + print ''; + print ''; @@ -1773,6 +1779,12 @@ $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; +// IP Address +if (!empty($arrayfields['s.ip']['checked'])) { + print_liste_field_titre($arrayfields['s.ip']['label'], $_SERVER["PHP_SELF"], "s.ip", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + $totalarray['nbfield']++; // For the column action +} +// Date creation if (!empty($arrayfields['s.datec']['checked'])) { print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); $totalarray['nbfield']++; // For the column action @@ -1845,6 +1857,8 @@ $companystatic->tva_intra = $obj->tva_intra; $companystatic->country_code = $obj->country_code; + $companystatic->ip = $obj->ip; + $companystatic->code_compta_client = $obj->code_compta; $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; $companystatic->note_public = $obj->note_public; @@ -2227,6 +2241,15 @@ $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + // IP + if (!empty($arrayfields['s.ip']['checked'])) { + print ''; + print dol_print_ip($obj->ip); + print ''; From ac5d29a4f648622a30eacc0e755a043706a31494 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 15 Jan 2025 14:11:57 +0100 Subject: [PATCH 54/55] Fix phpunit --- htdocs/core/modules/modAdherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 0994133905a92..51dd74cc11787 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -414,7 +414,7 @@ public function __construct($db) 'unitfrequency'=> 3600 * 24, 'priority'=>50, 'status'=>1, - 'test'=>'isModEnabled("adherent")', + 'test'=>'isModEnabled("member")', 'datestart'=>$datestart ), ); From acf1430bedf51eba495fbc4ed53e5616b661af07 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Jan 2025 14:18:22 +0100 Subject: [PATCH 55/55] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ede456909d5df..adbc77946c264 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6927,8 +6927,10 @@ public function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_ven $reshook = $hookmanager->executeHooks('load_tva', $parameters); if ($reshook > 0) { return $hookmanager->resPrint; + } elseif ($reshook === 0) { + $return .= $hookmanager->resPrint; } - + // Define defaultnpr, defaultttx and defaultcode $defaultnpr = ($info_bits & 0x01); $defaultnpr = (preg_match('/\*/', $selectedrate) ? 1 : $defaultnpr);