From 25ea797aed961cd1bbc2df647a7ab532e18922e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Sep 2024 18:26:24 +0200 Subject: [PATCH 01/11] Fix not default template for BOM --- htdocs/bom/class/bom.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 68cd44dcf46..0ad0cddf96d 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -986,7 +986,7 @@ class BOM extends CommonObject $outputlangs->load("products"); if (!dol_strlen($modele)) { - $modele = 'standard'; + $modele = ''; if ($this->model_pdf) { $modele = $this->model_pdf; From f287d100a367a84c262a0f35b86c45e4cfa4cc5a Mon Sep 17 00:00:00 2001 From: atm-irvine <165771178+atm-irvine@users.noreply.github.com> Date: Fri, 4 Oct 2024 11:49:44 +0200 Subject: [PATCH 02/11] Use <= 0 instead of ! because delete method returns -1 or 1 (#31268) * Use <= 0 instead of ! because delete method returns -1 or 1 * Added contact * Removed user from parameters --- htdocs/categories/class/api_categories.class.php | 4 ++-- htdocs/societe/class/api_contacts.class.php | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index e10371f87b6..77356ba2a87 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -267,8 +267,8 @@ class Categories extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$this->category->delete(DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when delete category'); + if ($this->category->delete(DolibarrApiAccess::$user) <= 0) { + throw new RestException(500, 'Error when delete category : ' . $this->category->error); } return array( diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index afd6c5807a5..d8839c9a122 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -348,7 +348,7 @@ class Contacts extends DolibarrApi * Delete contact * * @param int $id Contact ID - * @return integer + * @return array[] */ public function delete($id) { @@ -364,7 +364,17 @@ class Contacts extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->contact->oldcopy = clone $this->contact; - return $this->contact->delete(); + + if ($this->contact->delete() <= 0) { + throw new RestException(500, 'Error when delete contact ' . $this->contact->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact deleted' + ) + ); } /** From 934d291194fc54b8296cb7710860b3b1f3cf58dd Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Fri, 4 Oct 2024 18:45:54 +0200 Subject: [PATCH 03/11] fix: action/card.php do not display priority field if hidden conf not activated (#31277) --- htdocs/comm/action/card.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 5f5da42d233..2b004f0ff10 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -2511,9 +2511,11 @@ if ($id > 0) { } // Priority - print ''.$langs->trans("Priority").''; - print($object->priority ? $object->priority : ''); - print ''; + if (getDolGlobalString('AGENDA_SUPPORT_PRIORITY_IN_EVENTS')) { + print '' . $langs->trans("Priority") . ''; + print($object->priority ? $object->priority : ''); + print ''; + } // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table // for such objects because there is already a dedicated field into table llx_actioncomm. From 63f6d0aa43e0a48a356c719dee53fd11b6737899 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Sun, 6 Oct 2024 13:53:16 +0200 Subject: [PATCH 04/11] Fix: Number of decimals for stock values ignores configuration (#31285) * Fix: Number of decimals for stock values ignores configuration In the select filed for adding a new line for a proposal/invoice/... product as a line, the stock level is always printed with exactly two decimals. The number of decimals should be controlled by the existing global variable MAIN_MAX_DECIMALS_STOCK, but it is not taken into account: Building the stock level with the function price from the function price2num, which uses the configured number of decimals always lead to exactly two decimals. * Fixed patch according to suggestion. --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a4b050def56..aaf856152b7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3334,7 +3334,7 @@ class Form if (isModEnabled('stock') && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))) { if ($user->hasRight('stock', 'lire')) { - $opt .= ' - ' . $langs->trans("Stock") . ': ' . price(price2num($objp->stock, 'MS')); + $opt .= ' - ' . $langs->trans("Stock") . ': ' . price(price2num($objp->stock, 'MS'), 0, $langs, 0, 0); if ($objp->stock > 0) { $outval .= ' - '; From d8a980444a3d6f834fd2e564f1d92a03e8adaa52 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 6 Oct 2024 13:55:48 +0200 Subject: [PATCH 05/11] Flow: Setup mariadb after restoring cache (#31274) # Flow: Setup mariadb after restoring cache To use the cache, it has to be restored first. The original order of actions did not enable the reuse of the mariadb executable from cache --- .github/workflows/windows-ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index e245a67683e..e7d330324dd 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -36,11 +36,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - name: Setup MariaDB - uses: frederic34/setup-mariadb@v1 - with: - # mariadb-version: ${{ matrix.mariadb-version }} - database: travis # Specify your database name - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -79,6 +74,12 @@ jobs: ${{ env.KEY_ROOT }}-${{ env.HASH }}- ${{ env.KEY_ROOT }}- + - name: Setup MariaDB + uses: frederic34/setup-mariadb@v1 + with: + # mariadb-version: ${{ matrix.mariadb-version }} + database: travis # Specify your database name + - name: Create local php.ini with open_basedir restrictions shell: cmd # Objective: separate step, and before database initialisation to verify open_basedir restrictions From 63d4b5e3d8c22f76f5e4ca46fb3fc45a8dcf771b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Oct 2024 22:17:26 +0200 Subject: [PATCH 06/11] FIX Backport fix fatal error on price with some truncating setup --- htdocs/core/lib/functions.lib.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 785889eab78..0218301af75 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5931,9 +5931,10 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ $nbdecimal = dol_strlen($decpart); } // Si on depasse max - if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) { - $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_SHOWN; - if (preg_match('/\.\.\./i', $conf->global->MAIN_MAX_DECIMALS_SHOWN)) { + $max_nbdecimal = (int) str_replace('...', '', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN')); + if ($trunc && $nbdecimal > $max_nbdecimal) { + $nbdecimal = $max_nbdecimal; + if (preg_match('/\.\.\./i', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN'))) { // Si un affichage est tronque, on montre des ... $end = '...'; } From 0811ff5f07f7a5fce258e2897511111bf27e654b Mon Sep 17 00:00:00 2001 From: Mikko Virtanen <18483074+mikko80@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:52:12 +0300 Subject: [PATCH 07/11] FIX dolFICalculatePaymentReference for Finland in functions_fi.lib.php (#31281) * Update functions_fi.lib.php Fix calculation from some base numbers * Update functions_fi.lib.php --- htdocs/core/lib/functions_fi.lib.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions_fi.lib.php b/htdocs/core/lib/functions_fi.lib.php index 75d28b51975..e09f49bd589 100644 --- a/htdocs/core/lib/functions_fi.lib.php +++ b/htdocs/core/lib/functions_fi.lib.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Mikko Virtanen * * 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 @@ -37,16 +38,16 @@ function dolFICalculatePaymentReference($invoice_number, $statut, $use_rf) { if ($statut >= 1) { $invoice_number = preg_replace('/[^0-9]/', '', $invoice_number); // Keep only numbers - $invoice_number = ltrim($invoice_number, '0'); //Remove any leading zero or zeros - $invoice_number = strrev($invoice_number); // Reverse the reference number - $coefficients = array(7, 3, 1, 7, 3); // Define the coefficient numbers + $invoice_number = ltrim($invoice_number, '0'); // Remove leading zeros + $coefficients = array(7, 3, 1); // Define the coefficient numbers (rotating 7, 3, 1) $sum = 0; $stlen_invoice_number = (int) strlen($invoice_number); - for ($i = 0; $i < $stlen_invoice_number; $i++) { // Calculate the sum using coefficients - $sum += (int) $invoice_number[$i] * $coefficients[$i % 5]; + // Calculate the weighted sum from right to left + for ($i = 0; $i < $stlen_invoice_number; $i++) { + $sum += (int) $invoice_number[$stlen_invoice_number - $i - 1] * $coefficients[$i % 3]; } $check_digit = (10 - ($sum % 10)) % 10; // Calculate the check digit - $bank_reference_fi = strrev($invoice_number) . $check_digit; // Concatenate the Reversed reference number and the check digit + $bank_reference_fi = $invoice_number . $check_digit; // Concatenate the reference number and the check digit if ($use_rf) { // SEPA RF creditor reference $reference_with_suffix = $bank_reference_fi . "271500"; // Append "271500" to the end of the payment reference number $remainder = (int) bcmod($reference_with_suffix, '97'); // Calculate the remainder when dividing by 97 From f5262ceefade921c23d9c03b952c6a1f72ad00b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2024 15:25:19 +0200 Subject: [PATCH 08/11] Prepare 20.0.1 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 2a3c0a7e4e8..ec66d6cf58b 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -35,7 +35,7 @@ if (!defined('DOL_APPLICATION_TITLE')) { define('DOL_APPLICATION_TITLE', 'Dolibarr'); } if (!defined('DOL_VERSION')) { - define('DOL_VERSION', '20.0.0'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '20.0.1'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { From 728ca6a2e6c6a84343387103891656778cd3012f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2024 15:28:48 +0200 Subject: [PATCH 09/11] Prepare 20.0.1 --- ChangeLog | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6f2c15dfe29..ee320d33ba3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,56 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 20.0.1 compared to 20.0.0 ***** + +FIX: #30960 show and search extrafields (#31026) +FIX: #31076 Bad position of hooks +FIX: #31152 +FIX: #31237 (#31239) +FIX: #31241 (#31245) +FIX: accounting transfer when nb of lines is not zero but amount is zero +FIX: Add same security test when nuploading files from API than from GUI (#31114) +FIX: allow "class" into search string in website module +FIX: autoselect the fiscal period by default +FIX: avoid odt errors (#31126) +FIX: Backport fix fatal error on price with some truncating setup +FIX: better compatibility with some old extrafield syntax filter +FIX: box_actions.php still uses fk_user_done which no longer exists (#31190) +FIX: Browser Notification ko with firefox +FIX: custom CSS for WebPortal (#31022) +FIX: Debug calculation of the delay of purchase order +FIX: Debug option WORKFLOW_TICKET_LINK_CONTRACT. Bad id stored. Bad +FIX: dolFICalculatePaymentReference for Finland in functions_fi.lib.php (#31281) +FIX: Duplicate trigger printFieldPreListTitle +FIX: edit contract of intervention broken by CSRF protection +FIX: error return missing in mo creation when qty to consume is <= 0 (#31134) +FIX: Extrafields does not appear on form +FIX: FATAL ERROR abusively triggered due to incomplete regex (#31052) +FIX: if you call fetchLines several times, your $object->lines contains duplicates (#31167) +FIX: late order search option (v18+) (#30692) +FIX: late propal search option (v18+) (#30687) +FIX: Maxi debug edit/delete accounting transaction +FIX: member must be found to search the linked partnership (WebPortal) (#30977) +FIX: Missing picto on user link +FIX: mysql error during dump for enable sandbox M999999 (#31116) +FIX: OAuth generation of token for Microsoft, Stripe and Generic +FIX: param id in website account list from third-party card (#30975) +FIX: Position of box for shipping address in PDF +FIX: Protection to avoid an extrafield to be mandatory if computed +FIX: removed unreachable code (#31141) +FIX: Remove wrong button +FIX: retrieving user specific constant +FIX: Revert storing of ticket files into event dir, too many troubles. +FIX: Selection of country - state in resource +FIX: State dropdown is not working on User card #31198 (#31205) +FIX: Tool to convert into utf8 or utf8mb4 +FIX: use price() to display qty on a product's stats tab to avoid showing too many decimals when rounding errors are possible (#31165) +FIX: Warning visible when it should not +FIX: webhook must send POST in body. Add WEBHOOK_POST_SEND_DATA_IN_BODY +FIX: when qty is not an integer, apply price() (#31138) +FIX: Wrong price for BOM with workstation (#31142) +FIX: determine multi-currency price on object line create tpl (#28021) + ***** ChangeLog for 20.0.0 compared to 19.0 ***** From 7faa9bad6777310993bbcf9f29fb2e66d5530c83 Mon Sep 17 00:00:00 2001 From: John BOTELLA <68917336+thersane-john@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:42:17 +0200 Subject: [PATCH 10/11] Fix 20.0 Action buttion url autocomplete (button dropdown part04) (#31266) * Fix dol get action buttion url autocomplette * change mailto * change mailto * Remove anonymous function * Remove anonymous function * Update functions.lib.php --------- Co-authored-by: Laurent Destailleur --- htdocs/core/lib/functions.lib.php | 53 +++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 669aa6689d1..b8bb9d7f3a1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12264,6 +12264,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * $arrayforbutaction = array( * 10 => array('attr' => array('class'=>''), 'lang'=>'propal', 'enabled'=>isModEnabled("propal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), * 20 => array('attr' => array('class'=>''), 'lang'=>'mymodule', 'enabled'=>isModEnabled("mymodule"), 'perm'=>$user->hasRight('mymodule', 'write'), 'label' => 'MyModuleAction', 'urlroot'=>dol_build_patch('/mymodule/mypage.php?action=create')), + * 30 => array('attr' => array('class'=>''), 'lang'=>'mymodule', 'enabled'=>isModEnabled("mymodule"), 'perm'=>$user->hasRight('mymodule', 'write'), 'label' => 'MyModuleOtherAction', 'urlraw' => '# || external Url || javascript: || tel: || mailto:' ), * ); ); * @param string $id Attribute id of action button. Example 'action-delete'. This can be used for full ajax confirm if this code is reused into the ->formconfirm() method. * @param int|boolean $userRight User action right @@ -12329,17 +12330,18 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = $langs->load($subbutton['lang']); } - if (!empty($subbutton['urlroot'])) { - $tmpurl = $subbutton['urlroot'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); + if (!empty($subbutton['urlraw'])) { + $tmpurl = $subbutton['urlraw']; // Use raw url, no url completion, use only what developer send } else { - $tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); + $tmpurl = !empty($subbutton['urlroot']) ? $subbutton['urlroot'] : $subbutton['url']; + $tmpurl = dolCompletUrlForDropdownButton($tmpurl, $params, empty($subbutton['urlroot'])); } $subbuttonparam = array(); if (!empty($subbutton['attr'])) { $subbuttonparam['attr'] = $subbutton['attr']; } - $subbuttonparam['isDropDown'] = (empty($params['isDropDown']) ? $subbutton['isDropDown'] : $params['isDropDown']); + $subbuttonparam['isDropDown'] = (empty($params['isDropDown']) ? ($subbutton['isDropDown']??false) : $params['isDropDown']); $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, $subbutton['id'] ?? '', $subbutton['perm'], $subbuttonparam); } @@ -12351,10 +12353,11 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = $langs->load($subbutton['lang']); } - if (!empty($subbutton['urlroot'])) { - $tmpurl = $subbutton['urlroot'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); + if (!empty($subbutton['urlraw'])) { + $tmpurl = $subbutton['urlraw']; // Use raw url, no url completion, use only what developer send } else { - $tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); + $tmpurl = !empty($subbutton['urlroot']) ? $subbutton['urlroot'] : $subbutton['url']; + $tmpurl = dolCompletUrlForDropdownButton($tmpurl, $params, empty($subbutton['urlroot'])); } $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm'], $params); @@ -12489,6 +12492,42 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = } } + +/** + * An function to complete dropdown url in dolGetButtonAction + * + * @param string $url the Url to complete + * @param array|array $params params of dolGetButtonAction function + * @param bool $addDolUrlRoot to add root url + * @return string + */ +function dolCompletUrlForDropdownButton(string $url, array $params, bool $addDolUrlRoot = true) +{ + if (empty($url)) { + return ''; + } + + $parsedUrl = parse_url($url); + if ((isset($parsedUrl['scheme']) && in_array($parsedUrl['scheme'], ['javascript', 'mailto', 'tel'])) || strpos($url, '#') === 0) { + return $url; + } + + if (!empty($parsedUrl['query'])) { + // Use parse_str() function to parse the string passed via URL + parse_str($parsedUrl['query'], $urlQuery); + if (!isset($urlQuery['backtopage']) && isset($params['backtopage'])) { + $url.= '&backtopage='.urlencode($params['backtopage']); + } + } + + if (!isset($parsedUrl['scheme']) && $addDolUrlRoot) { + $url = DOL_URL_ROOT.$url; + } + + return $url; +} + + /** * Add space between dolGetButtonTitle * From 21eb8e585f88ea8306f9a093ff7a59bbffe1b9be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 8 Oct 2024 20:48:37 +0200 Subject: [PATCH 11/11] Fix detection of text browser with w3m --- htdocs/core/lib/functions.lib.php | 6 +++++- htdocs/main.inc.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 360cbb05edf..0961223b02e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -603,8 +603,12 @@ function getBrowserInfo($user_agent) $version = end($reg); } elseif (preg_match('/l[iy]n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { // MS products at end - $name = 'lynxlinks'; + $name = 'textbrowser'; $version = empty($reg[3]) ? '' : $reg[3]; + } elseif (preg_match('/w3m\/([\d\.]+)/i', $user_agent, $reg)) { + // MS products at end + $name = 'textbrowser'; + $version = empty($reg[1]) ? '' : $reg[1]; } if ($tablet) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 7a8f3cebb37..737053673f0 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -510,7 +510,7 @@ if (GETPOST('theme', 'aZ09')) { } // Set global MAIN_OPTIMIZEFORTEXTBROWSER (must be before login part) -if (GETPOSTINT('textbrowser') || (!empty($conf->browser->name) && $conf->browser->name == 'lynxlinks')) { // If we must enable text browser +if (GETPOSTINT('textbrowser') || (!empty($conf->browser->name) && $conf->browser->name == 'textbrowser')) { // If we must enable text browser $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER = 2; }