From 359dae6af876c8b970e0db79c54436b787539823 Mon Sep 17 00:00:00 2001 From: lainwir3d Date: Sun, 29 Aug 2021 23:13:41 +0400 Subject: [PATCH 01/12] FIX #18542 REST API: set global $user variable to DolibarrApiAccess::user. --- htdocs/api/class/api_access.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 99582b62047..eaaa29d7aa1 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -80,7 +80,7 @@ class DolibarrApiAccess implements iAuthenticate public function __isAllowed() { // phpcs:enable - global $conf, $db; + global $conf, $db, $user; $login = ''; $stored_key = ''; @@ -149,6 +149,7 @@ class DolibarrApiAccess implements iAuthenticate } $fuser->getrights(); static::$user = $fuser; + $user = $fuser; if ($fuser->socid) { static::$role = 'external'; From 4381f67a64bc90c2c2df6b8a8084c169e5aef7e5 Mon Sep 17 00:00:00 2001 From: lainwir3d Date: Mon, 30 Aug 2021 00:08:43 +0400 Subject: [PATCH 02/12] FIX #18544 Shipment REST API: load thirdparty object into the shipment before validating. --- htdocs/commande/class/api_orders.class.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 745fea5ab76..f5e9aea75bd 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -716,7 +716,9 @@ class Orders extends DolibarrApi if (!$result) { throw new RestException(404, 'Order not found'); } - + + $result = $this->commande->fetch_thirdparty(); // do not check result, as failure is not fatal (used only for mail notification substitutes) + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -729,13 +731,6 @@ class Orders extends DolibarrApi throw new RestException(500, 'Error when validating Order: '.$this->commande->error); } $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } - - if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } $this->commande->fetchObjectLinked(); From 01a44760a868b8d2099f058738d4ed79bde68257 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 29 Aug 2021 20:14:19 +0000 Subject: [PATCH 03/12] Fixing style errors. --- htdocs/commande/class/api_orders.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index f5e9aea75bd..b550139cd94 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -716,9 +716,9 @@ class Orders extends DolibarrApi if (!$result) { throw new RestException(404, 'Order not found'); } - + $result = $this->commande->fetch_thirdparty(); // do not check result, as failure is not fatal (used only for mail notification substitutes) - + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } From 7bf6daaca7704e891198c385da7c5f0adcf1f433 Mon Sep 17 00:00:00 2001 From: henrynopo Date: Mon, 30 Aug 2021 15:33:26 +0800 Subject: [PATCH 04/12] Update card.php --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 6cf2f27844a..a784431c841 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -538,7 +538,7 @@ if (empty($reshook)) { } // If some payments were already done, we change the amount to pay using same prorate - if (!empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) { + if (!empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) && $object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded. if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) { $ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc); From 3240a3652dbd3959239b0e832f206b3353c41627 Mon Sep 17 00:00:00 2001 From: henrynopo Date: Mon, 30 Aug 2021 15:34:59 +0800 Subject: [PATCH 05/12] Update card.php --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 3deb7b346c5..a09bc6853d0 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -834,7 +834,7 @@ if (empty($reshook)) { } // If some payments were already done, we change the amount to pay using same prorate - if (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) { + if (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) && $object->type == Facture::TYPE_CREDIT_NOTE) { $alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded. if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) { $ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc); From d09d036f06acfeb5959c3b4489ceac4008286328 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 31 Aug 2021 16:10:55 +0200 Subject: [PATCH 06/12] Fix supplier invoice pdf generation canelle Thirdparty wrongly fetched was causing errors on mass generation --- .../core/modules/supplier_invoice/pdf/pdf_canelle.modules.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 01f6369055b..3ef1bc45e5e 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -208,7 +208,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices global $user, $langs, $conf, $mysoc, $hookmanager, $nblines; // Get source company - if (!is_object($object->thirdparty)) $object->fetch_thirdparty(); + $object->fetch_thirdparty(); if (!is_object($object->thirdparty)) $object->thirdparty = $mysoc; // If fetch_thirdparty fails, object has no socid (specimen) $this->emetteur = $object->thirdparty; if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined @@ -224,8 +224,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if ($conf->fournisseur->facture->dir_output) { - $object->fetch_thirdparty(); - $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); From 0f325bdd656882f9123576959ca684151ada6330 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Sep 2021 18:05:24 +0200 Subject: [PATCH 07/12] Update api_access.class.php --- htdocs/api/class/api_access.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index eaaa29d7aa1..075059fefda 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -149,6 +149,8 @@ class DolibarrApiAccess implements iAuthenticate } $fuser->getrights(); static::$user = $fuser; + + // Set the global variable $user to the $user of API $user = $fuser; if ($fuser->socid) { From f391b11da773185bcbdaa47262ebc26f2b903d9d Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Sat, 28 Aug 2021 20:28:09 +0200 Subject: [PATCH 08/12] fix product nature on create --- htdocs/product/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 978616524d7..3a85eaaf47b 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1241,8 +1241,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { // Nature print ''.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).''; - $statutarray = array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); - print $form->selectarray('finished', $statutarray, GETPOST('finished', 'alpha'), 1); + print $formproduct->selectProductNature('finished', $object->finished); print ''; } From 831a66465fb3bf2f23c225080f92c2bfe70d5379 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Sep 2021 18:28:21 +0200 Subject: [PATCH 09/12] Fix trans --- htdocs/langs/en_US/members.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 06f591cc5ab..695a11044b1 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -29,7 +29,7 @@ MenuMembersValidated=Validated members MenuMembersExcluded=Excluded members MenuMembersResiliated=Terminated members MembersWithSubscriptionToReceive=Members with contribution to receive -MembersWithSubscriptionToReceiveShort=Membership contribution to receive +MembersWithSubscriptionToReceiveShort=Contributions to receive DateSubscription=Date of membership DateEndSubscription=End date of membership EndSubscription=End of membership From 03cfea25041cfc80143b36c04699f4e1bea798a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Sep 2021 19:06:58 +0200 Subject: [PATCH 10/12] Fix const setup --- htdocs/adherents/admin/member.php | 10 +++++----- htdocs/install/mysql/data/llx_const.sql | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index f9b10c3ce3b..5a589756feb 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -205,16 +205,16 @@ print ''.$langs->trans("Description").''; print ''.$langs->trans("Value").''; print "\n"; -// Login/Pass required for members -print ''.$langs->trans("AdherentLoginRequired").''; -print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED', (!empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED) ? 0 : 1), 1); -print "\n"; - // Mail required for members print ''.$langs->trans("AdherentMailRequired").''; print $form->selectyesno('ADHERENT_MAIL_REQUIRED', (!empty($conf->global->ADHERENT_MAIL_REQUIRED) ? $conf->global->ADHERENT_MAIL_REQUIRED : 0), 1); print "\n"; +// Login/Pass required for members +print ''.$langs->trans("AdherentLoginRequired").''; +print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED', (!empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED) ? 0 : 1), 1); +print "\n"; + // Send mail information is on by default print ''.$langs->trans("MemberSendInformationByMailByDefault").''; print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? $conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL : 0), 1); diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index ed5449c0bd3..2f2975a158c 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -86,7 +86,7 @@ insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_EXP -- Mail Mailing -- insert into llx_const (name, value, type, note, visible) values ('MAIN_FIX_FOR_BUGGED_MTA','1','chaine','Set constant to fix email ending from PHP with some linux ike system',1); -insert into llx_const (name, value, type, note, visible) values ('MAILING_EMAIL_FROM','dolibarr@domain.com','chaine','EMail emmetteur pour les envois d emailings',0); +insert into llx_const (name, value, type, note, visible) values ('MAILING_EMAIL_FROM','no-reply@mydomain.com','chaine','EMail emmetteur pour les envois d emailings',0); -- @@ -103,3 +103,9 @@ insert into llx_const (name, value, type, visible, entity) VALUES ('USER_ADDON_P -- INSERT INTO llx_const (name, entity, value, type, visible) VALUES ('PRODUCT_PRICE_BASE_TYPE', 0, 'HT', 'string', 0); + +-- +-- Membership +-- +INSERT INTO llx_const (name, entity, value, type, visible) VALUES ('ADHERENT_LOGIN_NOT_REQUIRED', 0, '1', 'string', 0); + From 076bfd82a3eb61b37e9ba4bc25f02db4b208a7b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Sep 2021 22:37:15 +0200 Subject: [PATCH 11/12] FIX option "Default value for field 'Refuse bulk emailings'" --- htdocs/admin/mailing.php | 21 ++++++++++++++------- htdocs/contact/card.php | 12 ++++++------ htdocs/core/modules/modMailing.class.php | 2 +- htdocs/langs/en_US/mails.lang | 2 +- htdocs/societe/card.php | 6 +++--- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 1b0df5843f3..7988c0dab7f 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -132,6 +132,7 @@ print ''; print ''; print ''; print ''; +print ''; print "\n"; print ''; +print ''; +print ''; print ''; +print ''; +print ''; print ''; +print ''; +print ''; // Constant to add salt into the unsubscribe and check read tag. @@ -165,15 +169,17 @@ print ''; +print ''; +print ''; // default blacklist from mailing print ''; -print ''; +print ''; print ''; +print ''; print ''; @@ -181,7 +187,8 @@ if (!empty($conf->use_javascript_ajax) && $conf->global->MAIN_FEATURES_LEVEL >= print ''; + print ''; + print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").''.$langs->trans("Example").'
'; @@ -140,7 +141,8 @@ print '
'.dol_escape_htmltag(($mysoc->name ? $mysoc->name : 'MyName').' ').'
'; print $langs->trans("MailingEMailError").''; @@ -148,12 +150,14 @@ print '
webmaster@example.com>
'; print $langs->trans("MailingDelay").''; print ''; -print '
' . $langs->trans("DefaultBlacklistMailingStatus") . '' . $langs->trans("DefaultBlacklistMailingStatus", $langs->transnoentitiesnoconv("No_Email")) . ''; -$blacklist_setting=array(0=>$langs->trans('No'),1=>$langs->trans('Yes'),-1=>$langs->trans('DefaultStatusEmptyMandatory')); +$blacklist_setting=array(0=>$langs->trans('No'), 1=>$langs->trans('Yes'), 2=>$langs->trans('DefaultStatusEmptyMandatory')); print $form->selectarray("MAILING_CONTACT_DEFAULT_BULK_STATUS", $blacklist_setting, $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS); print '
'; print $langs->trans("MailAdvTargetRecipients").''; print ajax_constantonoff('EMAILING_USE_ADVANCED_SELECTOR'); - print '
'; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 469869f00e9..2f6b717a2dc 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -225,7 +225,7 @@ if (empty($reshook)) { $action = 'create'; } - if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1 && $object->no_email == -1 && !empty($object->email)) { + if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && $object->no_email == -1 && !empty($object->email)) { $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")); $action = 'create'; @@ -317,7 +317,7 @@ if (empty($reshook)) { $action = 'edit'; } - if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1 && GETPOST("no_email", "int") == -1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) { + if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && GETPOST("no_email", "int") == -1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) { $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")); $action = 'edit'; @@ -780,7 +780,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Unsubscribe if (!empty($conf->mailing->enabled)) { - if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1) { + if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) { print "\n".'