From 52e2e71b00c8d630c9bbb7bd45823e7c7679e567 Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 21 Dec 2022 11:57:07 +0100 Subject: [PATCH 01/50] Fix(scrutinizer) --- htdocs/public/project/new.php | 68 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index 7603c046006..62951407fd1 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -338,50 +338,50 @@ if (empty($reshook) && $action == 'add') { require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $object = $proj; - if ($object->email) { - $subject = ''; - $msg = ''; + // if ($object->email) { + // $subject = ''; + // $msg = ''; - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members", "projects")); - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->PROJECT_EMAIL_TEMPLATE_AUTOLEAD; + // // Send subscription email + // include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + // $formmail = new FormMail($db); + // // Set output language + // $outputlangs = new Translate('', $conf); + // $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // // Load traductions files required by page + // $outputlangs->loadLangs(array("main", "members", "projects")); + // // Get email content from template + // $arraydefaultmessage = null; + // $labeltouse = $conf->global->PROJECT_EMAIL_TEMPLATE_AUTOLEAD; - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'project', $user, $outputlangs, 0, 1, $labeltouse); - } + // if (!empty($labeltouse)) { + // $arraydefaultmessage = $formmail->getEMailTemplate($db, 'project', $user, $outputlangs, 0, 1, $labeltouse); + // } - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } - if (empty($labeltosue)) { - $labeltouse = '['.$mysoc->name.'] '.$langs->trans("YourMessage"); - $msg = $langs->trans("YourMessageHasBeenReceived"); - } + // if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + // $subject = $arraydefaultmessage->topic; + // $msg = $arraydefaultmessage->content; + // } + // if (empty($labeltosue)) { + // $labeltouse = '['.$mysoc->name.'] '.$langs->trans("YourMessage"); + // $msg = $langs->trans("YourMessageHasBeenReceived"); + // } - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); + // $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + // complete_substitutions_array($substitutionarray, $outputlangs, $object); + // $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + // $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); - if ($subjecttosend && $texttosend) { - $moreinheader = 'X-Dolibarr-Info: send_an_email by public/lead/new.php'."\r\n"; + // if ($subjecttosend && $texttosend) { + // $moreinheader = 'X-Dolibarr-Info: send_an_email by public/lead/new.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - } + // $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + // } /*if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); }*/ - } + // } if (!empty($backtopage)) { $urlback = $backtopage; From c4521efa57db526986f80197afda81c568a86db8 Mon Sep 17 00:00:00 2001 From: FLIO Date: Mon, 23 Jan 2023 16:31:14 +0100 Subject: [PATCH 02/50] fix(qodana) fix function comment bad return --- htdocs/fichinter/class/api_interventions.class.php | 4 ++-- htdocs/fourn/class/fournisseur.product.class.php | 4 ++-- htdocs/product/class/product.class.php | 4 ++-- .../class/price_global_variable_updater.class.php | 4 ++-- htdocs/product/stock/class/entrepot.class.php | 4 ++-- htdocs/reception/class/api_receptions.class.php | 4 ++-- htdocs/societe/class/api_thirdparties.class.php | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index f96dc3d6aa7..6cd6595432d 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -341,7 +341,7 @@ class Interventions extends DolibarrApi * * @url POST {id}/validate * - * @return array + * @return Object */ public function validate($id, $notrigger = 0) { @@ -377,7 +377,7 @@ class Interventions extends DolibarrApi * * @url POST {id}/close * - * @return array + * @return Object */ public function closeFichinter($id) { diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index fa1706a523a..1d764cee490 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -673,7 +673,7 @@ class ProductFournisseur extends Product * @param int $limit Limit * @param int $offset Offset * @param int $socid Filter on a third party id - * @return array Array of ProductFournisseur with new properties to define supplier price + * @return array|int Array of ProductFournisseur with new properties to define supplier price */ public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0, $socid = 0) { @@ -1042,7 +1042,7 @@ class ProductFournisseur extends Product * @param string $sortorder Sort order * @param int $limit Limit * @param int $offset Offset - * @return array Array of Log prices + * @return array|int Array of Log prices */ public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 11133d6a6e0..e1251efe8f7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4829,7 +4829,7 @@ class Product extends CommonObject /** * Return all parent products for current product (first level only) * - * @return array Array of product + * @return array|int Array of product * @see hasFatherOrChild() */ public function getFather() @@ -4871,7 +4871,7 @@ class Product extends CommonObject * @param int $firstlevelonly Return only direct child * @param int $level Level of recursing call (start to 1) * @param array $parents Array of all parents of $id - * @return array Return array(prodid=>array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref) + * @return array|int Return array(prodid=>array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref) */ public function getChildsArbo($id, $firstlevelonly = 0, $level = 1, $parents = array()) { diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index 317bc7fb5fd..d43a2e3bf56 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -367,7 +367,7 @@ class PriceGlobalVariableUpdater /** * List all price global variables * - * @return array Array of price global variable updaters + * @return array|int Array of price global variable updaters */ public function listUpdaters() { @@ -404,7 +404,7 @@ class PriceGlobalVariableUpdater /** * List all updaters which need to be processed * - * @return array Array of price global variable updaters + * @return array|int Array of price global variable updaters */ public function listPendingUpdaters() { diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 6e09a81eb7f..d537d7d06cf 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -564,7 +564,7 @@ class Entrepot extends CommonObject /** * Return number of unique different product into a warehouse * - * @return Array Array('nb'=>Nb, 'value'=>Value) + * @return array|int Array('nb'=>Nb, 'value'=>Value) */ public function nb_different_products() { @@ -595,7 +595,7 @@ class Entrepot extends CommonObject /** * Return stock and value of warehosue * - * @return Array Array('nb'=>Nb, 'value'=>Value) + * @return array|int Array('nb'=>Nb, 'value'=>Value) */ public function nb_products() { diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php index 473650161e2..68da64fcc36 100644 --- a/htdocs/reception/class/api_receptions.class.php +++ b/htdocs/reception/class/api_receptions.class.php @@ -502,7 +502,7 @@ class Receptions extends DolibarrApi * * @url POST {id}/validate * - * @return array + * @return Object * \todo An error 403 is returned if the request has an empty body. * Error message: "Forbidden: Content type `text/plain` is not supported." * Workaround: send this in the body @@ -630,7 +630,7 @@ class Receptions extends DolibarrApi * * @url POST {id}/close * - * @return int + * @return Object */ public function close($id, $notrigger = 0) { diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index c4781c0df6a..f81fd066a2c 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -524,7 +524,7 @@ class Thirdparties extends DolibarrApi * Delete thirdparty * * @param int $id Thirdparty ID - * @return integer + * @return array */ public function delete($id) { @@ -1354,7 +1354,7 @@ class Thirdparties extends DolibarrApi * @param int $id Thirdparty id * @param int $companybankid Companybank id * @param string $model Model of document to generate - * @return void + * @return array * * @url GET {id}/generateBankAccountDocument/{companybankid}/{model} */ From 02f4f470830283fbf5dd7a6690fa4ca51bdab3fe Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 24 Jan 2023 23:11:28 +0100 Subject: [PATCH 03/50] fix (qodana) Return value type is not compatible with declared --- htdocs/bom/class/api_boms.class.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/db/sqlite3.class.php | 2 +- htdocs/don/class/api_donations.class.php | 2 +- htdocs/ecm/class/ecmdirectory.class.php | 2 +- htdocs/expedition/class/api_shipments.class.php | 4 ++-- htdocs/supplier_proposal/class/supplier_proposal.class.php | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index fb7d175a229..c2df69b9012 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -365,7 +365,7 @@ class Boms extends DolibarrApi * * @url PUT {id}/lines/{lineid} * - * @return array|bool + * @return object|bool */ public function putLine($id, $lineid, $request_data = null) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 37f250bf92f..7df0c4efe9c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4277,7 +4277,7 @@ abstract class CommonObject * @param string $field_select name of field we need to get a list * @param string $field_where name of field of object we need to get linked items * @param string $table_element name of association table - * @return array Array of record + * @return array|int Array of record, -1 if empty */ public static function getAllItemsLinkedByObjectID($fk_object_where, $field_select, $field_where, $table_element) { diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 8c10c26d464..40d0f10baa8 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -316,7 +316,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $passwd password * @param string $name name of database (not used for mysql, used for pgsql) * @param integer $port Port of database server - * @return SQLite3 Database access handler + * @return SQLite3|string Database access handler * @see close() */ public function connect($host, $login, $passwd, $name, $port = 0) diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index f9af0568bf0..eee681cea7b 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -295,7 +295,7 @@ class Donations extends DolibarrApi * @throws RestException 404 * @throws RestException 500 System error * - * @return array + * @return object */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index fb9b2a35dd0..21a43565a25 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -633,7 +633,7 @@ class EcmDirectory extends CommonObject * level Level of line (Added by buildPathFromId call) * * @param int $force Force reload of full arbo even if already loaded in cache $this->cats - * @return array Tableau de array + * @return array|int Tableau de array if OK, -1 if KO */ public function get_full_arbo($force = 0) { diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 357683ef35a..e5e1f584f5e 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -502,7 +502,7 @@ class Shipments extends DolibarrApi * * @url POST {id}/validate * - * @return array + * @return object * \todo An error 403 is returned if the request has an empty body. * Error message: "Forbidden: Content type `text/plain` is not supported." * Workaround: send this in the body @@ -630,7 +630,7 @@ class Shipments extends DolibarrApi * * @url POST {id}/close * - * @return int + * @return object */ public function close($id, $notrigger = 0) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 1f95e3de5fd..1604cf928e7 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1942,7 +1942,7 @@ class SupplierProposal extends CommonObject * @param int $offset For pagination * @param string $sortfield Sort criteria * @param string $sortorder Sort order - * @return int -1 if KO, array with result if OK + * @return array|int -1 if KO, array with result if OK */ public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datec', $sortorder = 'DESC') { @@ -2223,7 +2223,7 @@ class SupplierProposal extends CommonObject * * @param User $user Object user * @param int $mode "opened" for askprice to close, "signed" for proposal to invoice - * @return int <0 if KO, >0 if OK + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ public function load_board($user, $mode) { From 79f401f5fb68ff05598f01c5e9efddf34a0c6c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Fali=C3=A8re?= Date: Mon, 30 Jan 2023 11:50:23 +0100 Subject: [PATCH 04/50] Get data back when error on command create --- htdocs/commande/card.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 586cf98d606..776b07e0a93 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -13,8 +13,9 @@ * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018-2021 Frédéric France - * Copyright (C) 2022 Gauthier VERDOL - * + * Copyright (C) 2022 Gauthier VERDOL + * Copyright (C) 2023 Benjamin Falière + * * 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 * the Free Software Foundation; either version 3 of the License, or @@ -1730,32 +1731,32 @@ if ($action == 'create' && $usercancreate) { // Delivery delay print ''.$langs->trans('AvailabilityPeriod').''; print img_picto('', 'clock', 'class="pictofixedwidth"'); - $form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); + $form->selectAvailabilityDelay((GETPOST('availability_id')?GETPOST('availability_id'):$availability_id), 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); print ''; // Terms of payment print ''.$langs->trans('PaymentConditionsShort').''; print img_picto('', 'payment', 'class="pictofixedwidth"'); - $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent); + $form->select_conditions_paiements((GETPOST('cond_reglement_id')?GETPOST('cond_reglement_id'):$cond_reglement_id), 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent); print ''; // Payment mode print ''.$langs->trans('PaymentMode').''; print img_picto('', 'bank', 'class="pictofixedwidth"'); - $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx'); + $form->select_types_paiements((GETPOST('mode_reglement_id')?GETPOST('mode_reglement_id'):$mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx'); print ''; // Bank Account if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && !empty($conf->banque->enabled)) { print ''.$langs->trans('BankAccount').''; - print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes($fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); + print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes((GETPOST('fk_account')?GETPOST('fk_account'):$fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); print ''; } // Shipping Method if (isModEnabled('expedition')) { print ''.$langs->trans('SendingMethod').''; - print img_picto('', 'object_dolly', 'class="pictofixedwidth"').$form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); + print img_picto('', 'object_dolly', 'class="pictofixedwidth"').$form->selectShippingMethod((GETPOST('shipping_method_id')?GETPOST('shipping_method_id'):$shipping_method_id), 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print ''; } @@ -1764,14 +1765,14 @@ if ($action == 'create' && $usercancreate) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); print ''.$langs->trans('Warehouse').''; - print img_picto('', 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx'); + print img_picto('', 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses((GETPOST('warehouse_id')?GETPOST('warehouse_id'):$warehouse_id), 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx'); print ''; } // Source / Channel - What trigger creation print ''.$langs->trans('Channel').''; print img_picto('', 'question', 'class="pictofixedwidth"'); - $form->selectInputReason($demand_reason_id, 'demand_reason_id', '', 1, 'maxwidth200 widthcentpercentminusx'); + $form->selectInputReason((GETPOST('demand_reason_id')?GETPOST('demand_reason_id'):$demand_reason_id), 'demand_reason_id', '', 1, 'maxwidth200 widthcentpercentminusx'); print ''; // TODO How record was recorded OrderMode (llx_c_input_method) @@ -1781,7 +1782,7 @@ if ($action == 'create' && $usercancreate) { $langs->load("projects"); print ''; print ''.$langs->trans("Project").''; - print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); + print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), (GETPOST('projectid')?GETPOST('projectid'):$projectid), 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); print ' id).'">'; print ''; print ''; @@ -1840,7 +1841,7 @@ if ($action == 'create' && $usercancreate) { print ''; print ''.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).''; print ''; - print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0, '', false, 'maxwidth200 widthcentpercentminusx'); + print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency((GETPOST('multicurrency_code')?GETPOST('multicurrency_code'):$currency_code), 'multicurrency_code', 0, '', false, 'maxwidth200 widthcentpercentminusx'); print ''; } From f2c877f66af1433a003934c9c8958a867ba2e6bf Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 30 Jan 2023 11:06:30 +0000 Subject: [PATCH 05/50] Fixing style errors. --- htdocs/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 776b07e0a93..4b0fb283e17 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -15,7 +15,7 @@ * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2023 Benjamin Falière - * + * * 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 * the Free Software Foundation; either version 3 of the License, or From e7c6eac984eeb56167b72c0b78a8313e57cc5cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Fali=C3=A8re?= Date: Mon, 30 Jan 2023 14:05:17 +0100 Subject: [PATCH 06/50] Replaced GETPOST with GETPOSTISSET --- htdocs/commande/card.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 4b0fb283e17..d746c93a315 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1731,32 +1731,32 @@ if ($action == 'create' && $usercancreate) { // Delivery delay print ''.$langs->trans('AvailabilityPeriod').''; print img_picto('', 'clock', 'class="pictofixedwidth"'); - $form->selectAvailabilityDelay((GETPOST('availability_id')?GETPOST('availability_id'):$availability_id), 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); + $form->selectAvailabilityDelay((GETPOSTISSET('availability_id')?GETPOST('availability_id'):$availability_id), 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); print ''; // Terms of payment print ''.$langs->trans('PaymentConditionsShort').''; print img_picto('', 'payment', 'class="pictofixedwidth"'); - $form->select_conditions_paiements((GETPOST('cond_reglement_id')?GETPOST('cond_reglement_id'):$cond_reglement_id), 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent); + $form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id')?GETPOST('cond_reglement_id'):$cond_reglement_id), 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent); print ''; // Payment mode print ''.$langs->trans('PaymentMode').''; print img_picto('', 'bank', 'class="pictofixedwidth"'); - $form->select_types_paiements((GETPOST('mode_reglement_id')?GETPOST('mode_reglement_id'):$mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx'); + $form->select_types_paiements((GETPOSTISSET('mode_reglement_id')?GETPOST('mode_reglement_id'):$mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx'); print ''; // Bank Account if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && !empty($conf->banque->enabled)) { print ''.$langs->trans('BankAccount').''; - print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes((GETPOST('fk_account')?GETPOST('fk_account'):$fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); + print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes((GETPOSTISSET('fk_account')?GETPOST('fk_account'):$fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); print ''; } // Shipping Method if (isModEnabled('expedition')) { print ''.$langs->trans('SendingMethod').''; - print img_picto('', 'object_dolly', 'class="pictofixedwidth"').$form->selectShippingMethod((GETPOST('shipping_method_id')?GETPOST('shipping_method_id'):$shipping_method_id), 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); + print img_picto('', 'object_dolly', 'class="pictofixedwidth"').$form->selectShippingMethod((GETPOST('shipping_method_id')?GETPOSTISSET('shipping_method_id'):$shipping_method_id), 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print ''; } @@ -1765,14 +1765,14 @@ if ($action == 'create' && $usercancreate) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); print ''.$langs->trans('Warehouse').''; - print img_picto('', 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses((GETPOST('warehouse_id')?GETPOST('warehouse_id'):$warehouse_id), 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx'); + print img_picto('', 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses((GETPOSTISSET('warehouse_id')?GETPOST('warehouse_id'):$warehouse_id), 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx'); print ''; } // Source / Channel - What trigger creation print ''.$langs->trans('Channel').''; print img_picto('', 'question', 'class="pictofixedwidth"'); - $form->selectInputReason((GETPOST('demand_reason_id')?GETPOST('demand_reason_id'):$demand_reason_id), 'demand_reason_id', '', 1, 'maxwidth200 widthcentpercentminusx'); + $form->selectInputReason((GETPOSTISSET('demand_reason_id')?GETPOST('demand_reason_id'):$demand_reason_id), 'demand_reason_id', '', 1, 'maxwidth200 widthcentpercentminusx'); print ''; // TODO How record was recorded OrderMode (llx_c_input_method) @@ -1782,7 +1782,7 @@ if ($action == 'create' && $usercancreate) { $langs->load("projects"); print ''; print ''.$langs->trans("Project").''; - print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), (GETPOST('projectid')?GETPOST('projectid'):$projectid), 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); + print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), (GETPOSTISSET('projectid')?GETPOST('projectid'):$projectid), 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); print ' id).'">'; print ''; print ''; @@ -1841,7 +1841,7 @@ if ($action == 'create' && $usercancreate) { print ''; print ''.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).''; print ''; - print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency((GETPOST('multicurrency_code')?GETPOST('multicurrency_code'):$currency_code), 'multicurrency_code', 0, '', false, 'maxwidth200 widthcentpercentminusx'); + print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code')?GETPOST('multicurrency_code'):$currency_code), 'multicurrency_code', 0, '', false, 'maxwidth200 widthcentpercentminusx'); print ''; } From 9f85e4a60f93dfe1609c89a192d0243a62d3b395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Fali=C3=A8re?= Date: Mon, 30 Jan 2023 14:21:10 +0100 Subject: [PATCH 07/50] Fixed another little error --- htdocs/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index d746c93a315..6e4c5f45420 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1756,7 +1756,7 @@ if ($action == 'create' && $usercancreate) { // Shipping Method if (isModEnabled('expedition')) { print ''.$langs->trans('SendingMethod').''; - print img_picto('', 'object_dolly', 'class="pictofixedwidth"').$form->selectShippingMethod((GETPOST('shipping_method_id')?GETPOSTISSET('shipping_method_id'):$shipping_method_id), 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); + print img_picto('', 'object_dolly', 'class="pictofixedwidth"').$form->selectShippingMethod((GETPOSTISSET('shipping_method_id')?GETPOST('shipping_method_id'):$shipping_method_id), 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print ''; } From afa1fd3e8ae61d3adae9d2e373a8aad477218c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina=20JOUM?= Date: Wed, 1 Feb 2023 16:51:13 +0100 Subject: [PATCH 08/50] Get data back on product update --- htdocs/product/card.php | 71 ++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 351245794c3..90c48e44140 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1660,15 +1660,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; // Ref - print ''; + print ''; // Label - print ''; + print ''; // Status To sell print ''; if (!empty($object->status_batch) || !empty($conf->use_javascript_ajax)) { $langs->load("admin"); @@ -1815,7 +1815,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Default warehouse print ''; /* @@ -1854,7 +1854,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { // Nature print ''; } } @@ -1862,7 +1862,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (!$object->isService() && !empty($conf->bom->enabled)) { print ''; } @@ -1870,40 +1870,40 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) { // Brut Weight print ''; } if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { // Brut Length print ''; } if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) { // Brut Surface print ''; } if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) { // Brut Volume print ''; } if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) { // Net Measure print ''; } } @@ -1917,7 +1917,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Custom code if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) { - print ''; + print ''; // Origin country print ''; print '"; } @@ -1995,76 +2000,76 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Accountancy_code_sell print ''; print ''; // Accountancy_code_sell_intra if ($mysoc->isInEEC()) { print ''; print ''; } // Accountancy_code_sell_export print ''; print ''; // Accountancy_code_buy print ''; print ''; // Accountancy_code_buy_intra if ($mysoc->isInEEC()) { print ''; print ''; } // Accountancy_code_buy_export print ''; print ''; } else { // For external software // Accountancy_code_sell print ''; - print ''; // Accountancy_code_sell_intra if ($mysoc->isInEEC()) { print ''; - print ''; } // Accountancy_code_sell_export print ''; - print ''; // Accountancy_code_buy print ''; - print ''; // Accountancy_code_buy_intra if ($mysoc->isInEEC()) { print ''; - print ''; } // Accountancy_code_buy_export print ''; - print ''; } } From eb6c25f64d67788a11d54ce0036eb8c2054cc035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 1 Feb 2023 22:06:22 +0100 Subject: [PATCH 09/50] fix https://github.com/Dolibarr/dolibarr/issues/23753 --- .../doc/doc_generic_invoice_odt.modules.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index fc73460bd1b..53f1e6f9619 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -334,15 +334,19 @@ class doc_generic_invoice_odt extends ModelePDFFactures $object->fetchObjectLinked('', '', '', ''); //print_r($object->linkedObjects['propal']); exit; - $propal_object = $object->linkedObjects['propal'][0]; + if (isset($object->linkedObjects['propal'][0])) { + $propal_object = $object->linkedObjects['propal'][0]; + } else { + $propal_object = null; + } // Make substitution $substitutionarray = array( - '__FROM_NAME__' => $this->emetteur->name, - '__FROM_EMAIL__' => $this->emetteur->email, - '__TOTAL_TTC__' => $object->total_ttc, - '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_tva + '__FROM_NAME__' => $this->emetteur->name, + '__FROM_EMAIL__' => $this->emetteur->email, + '__TOTAL_TTC__' => $object->total_ttc, + '__TOTAL_HT__' => $object->total_ht, + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook @@ -433,8 +437,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } - } else // Text - { + } else { + // Text $odfHandler->setVars($key, $value, true, 'UTF-8'); } } catch (OdfException $e) { From 4c5bcd02b7e805952e8c5f1ce079432ab9142b14 Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 1 Feb 2023 23:31:39 +0100 Subject: [PATCH 10/50] fix (scrutinizer) remove comments and create function send an email TODO --- htdocs/projet/class/project.class.php | 24 +++++++++ htdocs/public/project/new.php | 71 +++++++++++++-------------- 2 files changed, 59 insertions(+), 36 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 79ea13dcd40..b5af4af49d9 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2313,4 +2313,28 @@ class Project extends CommonObject $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0, '', '-1', '', 0, 0, array(), 0, array(), 0, $loadRoleMode); } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Function sending an email to the current member with the text supplied in parameter. + * + * @param string $text Content of message (not html entities encoded) + * @param string $subject Subject of message + * @param array $filename_list Array of attached files + * @param array $mimetype_list Array of mime types of attached files + * @param array $mimefilename_list Array of public names of attached files + * @param string $addr_cc Email cc + * @param string $addr_bcc Email bcc + * @param int $deliveryreceipt Ask a delivery receipt + * @param int $msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection + * @param string $errors_to erros to + * @param string $moreinheader Add more html headers + * @return int <0 if KO, >0 if OK + */ + public function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') + { + // phpcs:enable + global $conf, $langs; + // TODO EMAIL + } } diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index dd5424c4f5f..a453e6e0b1e 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -334,51 +334,50 @@ if (empty($reshook) && $action == 'add') { if ($result > 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $object = $proj; + + if ($object->email) { + $subject = ''; + $msg = ''; - // if ($object->email) { - // $subject = ''; - // $msg = ''; + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members", "projects")); + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->PROJECT_EMAIL_TEMPLATE_AUTOLEAD; - // // Send subscription email - // include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - // $formmail = new FormMail($db); - // // Set output language - // $outputlangs = new Translate('', $conf); - // $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // // Load traductions files required by page - // $outputlangs->loadLangs(array("main", "members", "projects")); - // // Get email content from template - // $arraydefaultmessage = null; - // $labeltouse = $conf->global->PROJECT_EMAIL_TEMPLATE_AUTOLEAD; + if (!empty($labeltouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'project', $user, $outputlangs, 0, 1, $labeltouse); + } - // if (!empty($labeltouse)) { - // $arraydefaultmessage = $formmail->getEMailTemplate($db, 'project', $user, $outputlangs, 0, 1, $labeltouse); - // } + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } + if (empty($labeltosue)) { + $labeltouse = '['.$mysoc->name.'] '.$langs->trans("YourMessage"); + $msg = $langs->trans("YourMessageHasBeenReceived"); + } - // if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - // $subject = $arraydefaultmessage->topic; - // $msg = $arraydefaultmessage->content; - // } - // if (empty($labeltosue)) { - // $labeltouse = '['.$mysoc->name.'] '.$langs->trans("YourMessage"); - // $msg = $langs->trans("YourMessageHasBeenReceived"); - // } + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); + if ($subjecttosend && $texttosend) { + $moreinheader = 'X-Dolibarr-Info: send_an_email by public/lead/new.php'."\r\n"; - // $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - // complete_substitutions_array($substitutionarray, $outputlangs, $object); - // $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - // $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); - - // if ($subjecttosend && $texttosend) { - // $moreinheader = 'X-Dolibarr-Info: send_an_email by public/lead/new.php'."\r\n"; - - // $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - // } + $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + } /*if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); }*/ - // } + } if (!empty($backtopage)) { $urlback = $backtopage; From cc0d9b27f2b3dabc65b3088ef8fc648357d9c9bc Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 1 Feb 2023 23:31:53 +0100 Subject: [PATCH 11/50] fix (scrutinizer) remove comments and create function send an email TODO --- htdocs/public/project/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index a453e6e0b1e..726a318c99f 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -334,7 +334,7 @@ if (empty($reshook) && $action == 'add') { if ($result > 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $object = $proj; - + if ($object->email) { $subject = ''; $msg = ''; From 4b61ef946a9b4370ea93ea3675d4c11a239bb343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina=20JOUM?= Date: Thu, 2 Feb 2023 11:44:10 +0100 Subject: [PATCH 12/50] Fix --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 90c48e44140..2a4ad20ed04 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1888,7 +1888,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Brut Surface print ''; } if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) { From f46d9f1a153562808b6dd78470f029e26b432992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina=20JOUM?= Date: Thu, 2 Feb 2023 15:54:24 +0100 Subject: [PATCH 13/50] Fix GETPOST --- htdocs/product/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 2a4ad20ed04..b9b31762037 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1668,7 +1668,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Status To sell print ''; // Label - print ''; + print ''; // Stripe ID print ''; print ''; } @@ -479,7 +479,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; } From 39ec2331384243252bb45212c984c818ae838dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 7 Feb 2023 21:52:33 +0100 Subject: [PATCH 35/50] add count extrafields in admin dolresource --- htdocs/core/lib/resource.lib.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/resource.lib.php b/htdocs/core/lib/resource.lib.php index ebfbaf224f6..1fa2aa2f2e1 100644 --- a/htdocs/core/lib/resource.lib.php +++ b/htdocs/core/lib/resource.lib.php @@ -1,7 +1,8 @@ - * Copyright (C) 2016 Gilles Poirier + * Copyright (C) 2013 Jean-François Ferry + * Copyright (C) 2016 Gilles Poirier + * Copyright (C) 2023 Frédéric France * * 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 @@ -26,7 +27,7 @@ /** * Prepare head for tabs * - * @param Object $object Object + * @param Dolresource $object Object * @return array Array of head entries */ function resource_prepare_head($object) @@ -114,7 +115,10 @@ function resource_prepare_head($object) function resource_admin_prepare_head() { - global $langs, $conf, $user; + global $conf, $db, $langs, $user; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('resource'); $h = 0; $head = array(); @@ -132,6 +136,10 @@ function resource_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); + $nbExtrafields = $extrafields->attributes['resource']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ''.$nbExtrafields.''; + } $head[$h][2] = 'attributes'; $h++; From ea68c44d8f67e87ffffa33f67afa193dd1762d23 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:00:11 +0100 Subject: [PATCH 36/50] Update ChangeLog --- ChangeLog | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 68ce6daabcd..13b5981c8de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,20 +30,20 @@ NEW: #21000 Added columns 'alias_name' on project, supplier invoice, supplier or NEW: #21780 Add pid field to Cronjob class and store PID on job execution NEW: #21395 Added option for dark theme mode in display - color and theme NEW: #21397 added option to auto define barcode numbers for third-parties in barcode module setup -NEW: #21399 +NEW: #21399 add image for event_array NEW: #21442 Enhancement of module builder init NEW: #21654 add bank account number used on invoices for debit -NEW: #22048 Added notes to productlot module +NEW: #22048 added notes to productlot module NEW: #22298 Bank - Add salaries & vat in the tab of planned entries of a bank account -NEW: #22328 -NEW: #22424 +NEW: #22328 OAuth admin +NEW: #22424 online signature for contracts NEW: #22500 member module set up made easier NEW: #22527 projects and thirdparties can be viewed as conversation ("Message" view), like events/agenda. NEW: #22546 can now set user supervisors using mass action in htdocs/user NEW: #22594 can chose if VAT ID is unique or not for third parties NEW: #22622 all partnerships displayed on tab partnership of a thirdparty and member NEW: #22676 massaction for updating product prices -NEW: #22735 Massaction to affect users on projects +NEW: #22735 massaction to affect users on projects NEW: #25594 can chose if VAT ID is unique or not for third parties NEW: #4482 adding js to hide/show advanced option on the export data page @@ -57,27 +57,17 @@ NEW: Add max size send for "backup and link to mail" option NEW: Add method httponly_accessforbidden() NEW: Add more advices into the Setup security page NEW: Add new global variable for keeping the previous signature information on proposale (case of reopen a proposale) -NEW: Add objectLink on expedition -NEW: Add oldcopy to Ticket so triggers intercepting TICKET_MODIFY have access to old values of the updated properties NEW: Add option --force on CLI cron_run_jobs.php NEW: Add option "Show price on the generated documents for receptions" -NEW: invoice export : add accounting affectation -NEW: label on products categories filter -NEW: manage no email with thirdparties (better for GDPR) NEW: Manage VAT on all lines on purchases cycle -NEW: On a bank reconciled line, we can modify the bank receipt NEW: parent company column and filter in invoice and order list -NEW: possibility to select scopes with checkbox for Oauth tokens -NEW: private and public note on user, thirdparty and contact list +NEW: private and public note columns on user, thirdparty and contact lists NEW: Public counters feature -NEW: Saved token of OAUTH module are now encrypted into llx_oauth_token NEW: Save one click to select on delivery ack, on emails. NEW: scheduled job to send unpaid invoice reminder can now use the cc and bcc from email template -NEW: experimental SMTP using PhpImap allowing OAuth2 authentication (need to add option MAIN_IMAP_USE_PHPIMAP) NEW: can substitue project title in mail template NEW: The purge of files can purge only if older than a number of seconds NEW: Update ActionComm type_code on email message ticket -NEW: Finance - VAT - Admin - Add information on deadline day for submission of VAT declaration NEW: Add the target to select attendees of event for emailings NEW: add redirect on action confirm addconsumedline and addproduceline NEW: Add the referrer-policy to "same-origin" by default on all public pages. @@ -87,17 +77,18 @@ NEW: Can enter the unit price including the VAT NEW: Can invoice task time per different services NEW: Can set a commercial discount by entering amount including VAT NEW: Can set start and end dates and comment on button "Activate all services" -NEW: can sort and preselected best supplier price NEW: show date delivery planned on orders linked to company and product NEW: filter on reception dates (from / to) in cheque paiement card -NEW: Accountancy - Add a graphic option to enable lettering function - FPC21 -NEW: Accountancy - Add a way to clean some words when you generate thirdparty accounting account -NEW: Accountancy - Added an option during export to export or not the lettering FPC21 +NEW: Accountancy - add a graphic option to enable lettering function - FPC21 +NEW: Accountancy - add a way to clean some words when you generate thirdparty accounting account +NEW: Accountancy - added an option during export to export or not the lettering FPC21 +NEW: Accountancy - Invoice export : add accounting affectation NEW: Accountancy - Manage supplier deposit with specific account NEW: Accountancy - Model Digitaria - Add a way to clean some words when you generate thirdparty accounting account FPC22 NEW: Agenda - start a simple support of recurrent events on agenda NEW: Bank - add salaries & VAT in tab planned entries +NEW: Bank - on a bank reconciled line, we can modify the bank receipt NEW: Contracts - add a method doAutoRenewContracts that can be used as a cron task NEW: Contracts - default template of contract is not mandatory NEW: Contracts - Manage Position (Rank) on Contract Lines @@ -108,22 +99,29 @@ NEW: EMail - can send an email on scheduled job error NEW: EMail - on a form to send an email, we show all emails of all contacts of object NEW: EMail - add the SMTP header References on ticket email created by email NEW: EMail - add substitution key __SENDEREMAIL_SIGNATURE__ +NEW: EMail - experimental SMTP using PhpImap allowing OAuth2 authentication (need to add option MAIN_IMAP_USE_PHPIMAP) NEW: EMail-Collector - add IMAP port setting NEW: EMail-Collector - add a button "Test collect" -NEW: Export - Add " as enclosure by default for CSV export. Keep removing CR/LF. NEW: Event-Organization - add date event (!= date project) and location on event organization +NEW: Expedition - add objectLink on expedition +NEW: Export - Add " as enclosure by default for CSV export. Keep removing CR/LF. NEW: Extrafields - add badge in admin extrafields setup NEW: Extrafields - can edit property css, cssview, csslist on extrafields NEW: Extrafields - default values in extrafields are not more limited to 255 char. NEW: Extrafields - field price with currency NEW: Extrafields - support IP type to store IP addresses +NEW: Finance - VAT - Admin - Add information on deadline day for submission of VAT declaration NEW: Interventions - enable online signature for interventions -NEW: Invoice - Add french mention on pdf when vat debit option is on +NEW: Invoice - add french mention on PDF when VAT debit option is on NEW: Members - default_lang for members -NEW: Members - Table of membership types +NEW: Members - table of membership types NEW: Members - add free membership amounts at the membership type level +NEW: OAuth - possibility to select scopes with checkbox for OAuth tokens +NEW: OAuth - saved token of OAUTH module are now encrypted into llx_oauth_token NEW: Orders - resize parent company column in order list -NEW: Products supplier price - autofill default supplier VAT +NEW: Products - Categories - label on products categories filter +NEW: Products - Supplier price - autofill default supplier VAT +NEW: Products - Supplier price - can sort and preselected best supplier price NEW: Projects - add author on list NEW: Projects - add thirdparty column to the time list (projet/tasks/time.php) NEW: Proposals - show delivery mode on PDF for proposals @@ -144,8 +142,10 @@ NEW: TakePOS - display currency in TakePOS menu NEW: TakePOS - Header Scroll in TakePOS NEW: TakePOS - Receipt preview in TakePOS setup NEW: TakePOS - support of Stripe Terminal with TakePOS +NEW: Thirdparty - manage no email with thirdparties (better for GDPR) NEW: Thirdparty - set thirdparty type with company modify trigger NEW: Tickets - change filter type on tickets list into a multiselect combo +NEW: Tickets - add oldcopy to Ticket so triggers intercepting TICKET_MODIFY have access to old values of the updated properties NEW: Website - can delete a whole website if disabled NEW: Website - can remove a website template NEW: Website - can set header "Strict-Transport-Security" in web sites. @@ -176,11 +176,16 @@ NEW: Security: add fail2ban rules examples to limit access to /public pages Option / Const for System: NEW: FICHINTER_ALLOW_EXTERNAL_DOWNLOAD +NEW: MAIN_CHECKBOX_LEFT_COLUMN +NEW: MAIN_EMAIL_SUPPORT_ACK +NEW: MAIN_IMAP_USE_PHPIMAP NEW: MAIN_SEARCH_CATEGORY_PRODUCT_ON_LISTS - const to show category customer filter +NEW: PRODUCT_ALLOW_EXTERNAL_DOWNLOAD NEW: PRODUCTBATCH_SHOW_WAREHOUSE_ON_SHIPMENT - showing warehouse on PDF NEW: PRODUIT_DESC_IN_FORM accept - desktop only or +smartphone NEW: PROPAL_BYPASS_VALIDATED_STATUS NEW: PROPAL_NEW_AS_SIGNED +NEW: PROPAL_SKIP_ACCEPT_REFUSE NEW: TIMESPENT_ALWAYS_UPDATE_THM - when it's on we always check current thm of user to update it in task time line Localisation: From 81400b1fc5667f9930ad4b05fa9cd5940b619949 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:14:53 +0100 Subject: [PATCH 37/50] Update llx_c_availability.sql add 1-5 days --- htdocs/install/mysql/data/llx_c_availability.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/install/mysql/data/llx_c_availability.sql b/htdocs/install/mysql/data/llx_c_availability.sql index b98db76b48e..7768477c5d1 100644 --- a/htdocs/install/mysql/data/llx_c_availability.sql +++ b/htdocs/install/mysql/data/llx_c_availability.sql @@ -33,6 +33,11 @@ -- INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_NOW', 'Immediate', null, 0, 1, 10); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_1D', '1 day', 'd', 1, 1, 11); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_2D', '2 days', 'd', 2, 1, 12); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_3D', '3 days', 'd', 3, 1, 13); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_4D', '4 days', 'd', 4, 1, 14); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_5D', '5 days', 'd', 5, 1, 15); INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_1W', '1 week', 'w', 1, 1, 20); INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_2W', '2 weeks', 'w', 2, 1, 30); INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_3W', '3 weeks', 'w', 3, 1, 40); From 821b423a240d3a9aa8a354360042488d91919c45 Mon Sep 17 00:00:00 2001 From: muhalikin <40883042+muhalikin@users.noreply.github.com> Date: Wed, 8 Feb 2023 15:34:18 +0300 Subject: [PATCH 38/50] Fix Shipment Creation from Order via REST API --- htdocs/commande/class/api_orders.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 1a879173684..0318cbcd5bf 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -1053,6 +1053,7 @@ class Orders extends DolibarrApi } $shipment = new Expedition($this->db); $shipment->socid = $this->commande->socid; + $shipment->origin_id = $this->commande->id; $result = $shipment->create(DolibarrApiAccess::$user); if ($result <= 0) { throw new RestException(500, 'Error on creating expedition :'.$this->db->lasterror()); From 28c722ef598728c8b9e8c847f287f9bf544a67c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 8 Feb 2023 15:19:00 +0100 Subject: [PATCH 39/50] error message may be overwritten by other error message --- htdocs/product/class/product.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 60de90d819d..bb34fc2e3eb 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -14,7 +14,7 @@ * Copyright (C) 2014 Ion agorria * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2017 Gustavo Novaro - * Copyright (C) 2019-2022 Frédéric France + * Copyright (C) 2019-2023 Frédéric France * * 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 @@ -1566,7 +1566,7 @@ class Product extends CommonObject } } elseif (isset($this->multilangs[$key])) { if (empty($this->multilangs["$key"]["label"])) { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")); + $this->errors[] = $key . ' : ' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")); return -1; } From 98bfba1f461be23fcce1451cd1f275ab82c9020e Mon Sep 17 00:00:00 2001 From: avolani <31508728+avolani@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:20:47 +0100 Subject: [PATCH 40/50] Add missing table_element This allow usage of extrafields logic (still missing table and setup pages) --- htdocs/expensereport/class/expensereport.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index bc7e0f36baa..04c16fc2654 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2680,6 +2680,11 @@ class ExpenseReportLine extends CommonObjectLine * @var DoliDB Database handler. */ public $db; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'expensereport_det'; /** * @var string Error code (or message) From 637603731a3785eadbdd454ae96ecc79ed570b7a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 8 Feb 2023 15:26:10 +0000 Subject: [PATCH 41/50] Fixing style errors. --- htdocs/expensereport/class/expensereport.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 04c16fc2654..6ee3c8e19e7 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2680,11 +2680,11 @@ class ExpenseReportLine extends CommonObjectLine * @var DoliDB Database handler. */ public $db; - + /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'expensereport_det'; + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'expensereport_det'; /** * @var string Error code (or message) From f35d63cec148ae06928571e85ae9821b03b86a48 Mon Sep 17 00:00:00 2001 From: avolani <31508728+avolani@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:41:06 +0100 Subject: [PATCH 42/50] Clean placeholder of missing related project and products --- htdocs/core/class/commondocgenerator.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 82012400f68..05837331e16 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -538,6 +538,12 @@ abstract class CommonDocGenerator $resarray[$array_key.'_project_description'] = $object->project->description; $resarray[$array_key.'_project_date_start'] = dol_print_date($object->project->date_start, 'day'); $resarray[$array_key.'_project_date_end'] = dol_print_date($object->project->date_end, 'day'); + } else { // empty replacement + $resarray[$array_key.'_project_ref'] =''; + $resarray[$array_key.'_project_title'] = ''; + $resarray[$array_key.'_project_description'] = ''; + $resarray[$array_key.'_project_date_start'] = ''; + $resarray[$array_key.'_project_date_end'] = ''; } // Add vat by rates @@ -701,6 +707,14 @@ abstract class CommonDocGenerator foreach ($tmpproduct->array_options as $key => $label) { $resarray["line_product_".$key] = $label; } + } else { + // Set unused placeholders as blank + $extrafields->fetch_name_optionals_label("product"); + $extralabels = $extrafields->attributes["product"]['label']; + + foreach ($extralabels as $key => $label) { + $resarray['line_product_options_'.$key] = ''; + } } return $resarray; From 9fe920b2a925fd5464e54a950c31509c7e156899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 8 Feb 2023 21:45:46 +0100 Subject: [PATCH 43/50] deprecate method send_an_email --- htdocs/adherents/card.php | 6 +++--- htdocs/adherents/class/adherent.class.php | 25 +++++++++++++++++++++++ htdocs/adherents/subscription.php | 2 +- htdocs/projet/class/project.class.php | 7 ++++--- htdocs/public/members/new.php | 2 +- htdocs/public/partnership/new.php | 2 +- htdocs/public/payment/paymentok.php | 2 +- htdocs/public/project/new.php | 2 +- 8 files changed, 37 insertions(+), 11 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index f57bb2e312d..f9a43e47f0f 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -674,7 +674,7 @@ if (empty($reshook)) { $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); @@ -745,7 +745,7 @@ if (empty($reshook)) { $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); @@ -816,7 +816,7 @@ if (empty($reshook)) { $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index a9db33b9980..df7737213a5 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -440,11 +440,36 @@ class Adherent extends CommonObject * @param int $msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection * @param string $errors_to erros to * @param string $moreinheader Add more html headers + * @deprecated since V18 + * @see sendEmail * @return int <0 if KO, >0 if OK */ public function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') { // phpcs:enable + dol_syslog('Warning using deprecated Adherent::send_an_email', LOG_WARNING); + return $this->sendEmail($text, $subject, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, $errors_to, $moreinheader); + } + + /** + * Function sending an email to the current member with the text supplied in parameter. + * + * @param string $text Content of message (not html entities encoded) + * @param string $subject Subject of message + * @param array $filename_list Array of attached files + * @param array $mimetype_list Array of mime types of attached files + * @param array $mimefilename_list Array of public names of attached files + * @param string $addr_cc Email cc + * @param string $addr_bcc Email bcc + * @param int $deliveryreceipt Ask a delivery receipt + * @param int $msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection + * @param string $errors_to erros to + * @param string $moreinheader Add more html headers + * @since V18 + * @return int <0 if KO, >0 if OK + */ + public function sendEmail($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') + { global $conf, $langs; // Detect if message is HTML diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 8c423d53029..004bd7eaf4b 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -405,7 +405,7 @@ if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'subscripti $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader); + $result = $object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader); if ($result < 0) { $errmsg = $object->error; setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 51bae7ab6e9..305cfdd570b 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2314,7 +2314,6 @@ class Project extends CommonObject $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0, '', '-1', '', 0, 0, array(), 0, array(), 0, $loadRoleMode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function sending an email to the current member with the text supplied in parameter. * @@ -2329,12 +2328,14 @@ class Project extends CommonObject * @param int $msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection * @param string $errors_to erros to * @param string $moreinheader Add more html headers + * @since V18 * @return int <0 if KO, >0 if OK */ - public function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') + public function sendEmail($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') { - // phpcs:enable global $conf, $langs; // TODO EMAIL + + return 1; } } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 943280d6e2d..9ac60d8f823 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -372,7 +372,7 @@ if (empty($reshook) && $action == 'add') { if ($subjecttosend && $texttosend) { $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); } /*if ($result < 0) { $error++; diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index af2583abece..d5d1dad1d81 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -360,7 +360,7 @@ if (empty($reshook) && $action == 'add') { if ($subjecttosend && $texttosend) { $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); } } diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 4a13de1ef7f..40898f1ff6e 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -775,7 +775,7 @@ if ($ispaymentok) { $moreinheader = 'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, "", $moreinheader); + $result = $object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, "", $moreinheader); if ($result < 0) { $errmsg = $object->error; diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index 726a318c99f..ec891fc3741 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -371,7 +371,7 @@ if (empty($reshook) && $action == 'add') { if ($subjecttosend && $texttosend) { $moreinheader = 'X-Dolibarr-Info: send_an_email by public/lead/new.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); } /*if ($result < 0) { $error++; From b22d5b3e8adde4b6c6d67b214dfada3edf1bebcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 8 Feb 2023 21:47:11 +0100 Subject: [PATCH 44/50] deprecate method send_an_email --- htdocs/adherents/class/adherent.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index df7737213a5..689309f933c 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -448,6 +448,7 @@ class Adherent extends CommonObject { // phpcs:enable dol_syslog('Warning using deprecated Adherent::send_an_email', LOG_WARNING); + return $this->sendEmail($text, $subject, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, $errors_to, $moreinheader); } From 2cdc4406558f597b25877edb71b76de8019fd01c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 8 Feb 2023 21:57:07 +0100 Subject: [PATCH 45/50] doc --- htdocs/reception/class/reception.class.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index e9a89691c88..018d532a363 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -11,7 +11,7 @@ * Copyright (C) 2015 Claudio Aschieri * Copyright (C) 2016-2022 Ferran Marcet * Copyright (C) 2018 Quentin Vial-Gouteyron - * Copyright (C) 2022 Frédéric France + * Copyright (C) 2022-2023 Frédéric France * * 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 @@ -97,6 +97,12 @@ class Reception extends CommonObject public $date_delivery; // Date delivery planed + /** + * @var integer|string Effective delivery date + * @deprecated + * @see $date_reception + */ + public $date; /** * @var integer|string Effective delivery date @@ -396,8 +402,7 @@ class Reception extends CommonObject $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date = $this->db->jdate($obj->date_reception); // TODO deprecated - $this->date_reception = $this->db->jdate($obj->date_reception); // TODO deprecated + $this->date = $this->db->jdate($obj->date_reception); // TODO deprecated $this->date_reception = $this->db->jdate($obj->date_reception); // Date real $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->model_pdf = $obj->model_pdf; From de31fb83f0df5c59268362b50213ebd8b11d1771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 8 Feb 2023 23:33:39 +0100 Subject: [PATCH 46/50] fix links --- htdocs/core/lib/hrm.lib.php | 16 ++++++++-------- htdocs/hrm/establishment/info.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/hrm.lib.php b/htdocs/core/lib/hrm.lib.php index 5335dc1c75e..706af6bd110 100644 --- a/htdocs/core/lib/hrm.lib.php +++ b/htdocs/core/lib/hrm.lib.php @@ -52,15 +52,15 @@ function establishment_prepare_head($object) $head[$h][2] = 'info'; $h++; - $head[$h][0] = dol_buildpath("/hrm/admin/setup.php", 1); - $head[$h][1] = $langs->trans("Settings"); - $head[$h][2] = 'settings'; - $h++; + // $head[$h][0] = dol_buildpath("/hrm/admin/setup.php", 1); + // $head[$h][1] = $langs->trans("Settings"); + // $head[$h][2] = 'settings'; + // $h++; - $head[$h][0] = dol_buildpath("/hrm/admin/about.php", 1); - $head[$h][1] = $langs->trans("About"); - $head[$h][2] = 'about'; - $h++; + // $head[$h][0] = dol_buildpath("/hrm/admin/about.php", 1); + // $head[$h][1] = $langs->trans("About"); + // $head[$h][2] = 'about'; + // $h++; complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm'); diff --git a/htdocs/hrm/establishment/info.php b/htdocs/hrm/establishment/info.php index 3bfbe912279..1a9ba129f10 100644 --- a/htdocs/hrm/establishment/info.php +++ b/htdocs/hrm/establishment/info.php @@ -138,7 +138,7 @@ if ($object->id > 0) { // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; /* From 704faf734af8e885cb8450d5355bea39090e313e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Feb 2023 00:47:33 +0100 Subject: [PATCH 47/50] NEW Auto activate some modules on install (export/import/wysiwyg editor) --- htdocs/admin/index.php | 7 +- htdocs/admin/modules.php | 176 +++++++++--------- htdocs/core/lib/admin.lib.php | 11 +- htdocs/core/menus/standard/eldy.lib.php | 9 +- htdocs/core/modules/DolibarrModules.class.php | 4 + htdocs/core/modules/modFckeditor.class.php | 2 +- htdocs/index.php | 7 +- htdocs/install/step5.php | 53 +++++- 8 files changed, 166 insertions(+), 103 deletions(-) diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 87b49c95468..8a563191303 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -105,10 +105,15 @@ print '
'; print '
'; +$nbmodulesnotautoenabled = count($conf->modules); +if (in_array('fckeditor', $conf->modules)) $nbmodulesnotautoenabled--; +if (in_array('export', $conf->modules)) $nbmodulesnotautoenabled--; +if (in_array('import', $conf->modules)) $nbmodulesnotautoenabled--; + // Show info setup module print img_picto('', 'cog', 'class="paddingright valignmiddle double"').' '.$langs->trans("SetupDescriptionLink", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules")); print '

'.$langs->trans("SetupDescription4b"); -if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled +if ($nbmodulesnotautoenabled <= getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only minimal initial modules enabled $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"'); print '
'; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 837c76adadf..a42ecc5c34d 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -379,99 +379,95 @@ foreach ($modulesdir as $dir) { try { $res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error. if (class_exists($modName)) { - try { - $objMod = new $modName($db); - $modNameLoaded[$modName] = $dir; - if (!$objMod->numero > 0 && $modName != 'modUser') { - dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); - } - $j = $objMod->numero; + $objMod = new $modName($db); + $modNameLoaded[$modName] = $dir; + if (!$objMod->numero > 0 && $modName != 'modUser') { + dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); + } + $j = $objMod->numero; - $modulequalified = 1; + $modulequalified = 1; - // We discard modules according to features level (PS: if module is activated we always show it) - $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); - if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) { - $modulequalified = 0; - } - if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) { - $modulequalified = 0; - } - if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) { - $modulequalified = 0; - } + // We discard modules according to features level (PS: if module is activated we always show it) + $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); + if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) { + $modulequalified = 0; + } + if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) { + $modulequalified = 0; + } + if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) { + $modulequalified = 0; + } - // We discard modules according to property ->hidden - if (!empty($objMod->hidden)) { - $modulequalified = 0; - } + // We discard modules according to property ->hidden + if (!empty($objMod->hidden)) { + $modulequalified = 0; + } - if ($modulequalified > 0) { - $publisher = dol_escape_htmltag($objMod->getPublisher()); - $external = ($objMod->isCoreOrExternalModule() == 'external'); - if ($external) { - if ($publisher) { - $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; - } else { - $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); - } - } - ksort($arrayofnatures); - - // Define array $categ with categ with at least one qualified module - $filename[$i] = $modName; - $modules[$modName] = $objMod; - - // Gives the possibility to the module, to provide his own family info and position of this family - if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { - $familyinfo = array_merge($familyinfo, $objMod->familyinfo); - $familykey = key($objMod->familyinfo); + if ($modulequalified > 0) { + $publisher = dol_escape_htmltag($objMod->getPublisher()); + $external = ($objMod->isCoreOrExternalModule() == 'external'); + if ($external) { + if ($publisher) { + $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; } else { - $familykey = $objMod->family; + $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); } + } + ksort($arrayofnatures); - $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); - if ($objMod->isCoreOrExternalModule() == 'external' && $moduleposition < 100000) { - // an external module should never return a value lower than '80'. - $moduleposition = '80'; // External modules at end by default - } + // Define array $categ with categ with at least one qualified module + $filename[$i] = $modName; + $modules[$modName] = $objMod; - // Add list of warnings to show into arrayofwarnings and arrayofwarningsext - if (!empty($objMod->warnings_activation)) { - $arrayofwarnings[$modName] = $objMod->warnings_activation; - } - if (!empty($objMod->warnings_activation_ext)) { - $arrayofwarningsext[$modName] = $objMod->warnings_activation_ext; - } - - $familyposition = (empty($familyinfo[$familykey]['position']) ? 0 : $familyinfo[$familykey]['position']); - $listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other'); - if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) { - // If module is extern and into a custom group (not into an official predefined one), it must appear at end (custom groups should not be before official groups). - if (is_numeric($familyposition)) { - $familyposition = sprintf("%03d", (int) $familyposition + 100); - } - } - - $orders[$i] = $familyposition."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number - - // Set categ[$i] - $specialstring = 'unknown'; - if ($objMod->version == 'development' || $objMod->version == 'experimental') { - $specialstring = 'expdev'; - } - if (isset($categ[$specialstring])) { - $categ[$specialstring]++; // Array of all different modules categories - } else { - $categ[$specialstring] = 1; - } - $j++; - $i++; + // Gives the possibility to the module, to provide his own family info and position of this family + if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { + $familyinfo = array_merge($familyinfo, $objMod->familyinfo); + $familykey = key($objMod->familyinfo); } else { - dol_syslog("Module ".get_class($objMod)." not qualified"); + $familykey = $objMod->family; } - } catch (Exception $e) { - dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); + + $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); + if ($objMod->isCoreOrExternalModule() == 'external' && $moduleposition < 100000) { + // an external module should never return a value lower than '80'. + $moduleposition = '80'; // External modules at end by default + } + + // Add list of warnings to show into arrayofwarnings and arrayofwarningsext + if (!empty($objMod->warnings_activation)) { + $arrayofwarnings[$modName] = $objMod->warnings_activation; + } + if (!empty($objMod->warnings_activation_ext)) { + $arrayofwarningsext[$modName] = $objMod->warnings_activation_ext; + } + + $familyposition = (empty($familyinfo[$familykey]['position']) ? 0 : $familyinfo[$familykey]['position']); + $listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other'); + if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) { + // If module is extern and into a custom group (not into an official predefined one), it must appear at end (custom groups should not be before official groups). + if (is_numeric($familyposition)) { + $familyposition = sprintf("%03d", (int) $familyposition + 100); + } + } + + $orders[$i] = $familyposition."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number + + // Set categ[$i] + $specialstring = 'unknown'; + if ($objMod->version == 'development' || $objMod->version == 'experimental') { + $specialstring = 'expdev'; + } + if (isset($categ[$specialstring])) { + $categ[$specialstring]++; // Array of all different modules categories + } else { + $categ[$specialstring] = 1; + } + $j++; + $i++; + } else { + dol_syslog("Module ".get_class($objMod)." not qualified"); } } else { print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; @@ -523,12 +519,10 @@ asort($orders); $nbofactivatedmodules = count($conf->modules); -//$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING = 1000; -/*$moreinfo = $langs->trans("TitleNumberOfActivatedModules"); -$moreinfo2 = ''.($nbofactivatedmodules - 1).' / '.count($modules).''; -if ($nbofactivatedmodules <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { - $moreinfo2 .= ' '.img_warning($langs->trans("YouMustEnableOneModule")); -}*/ +$nbmodulesnotautoenabled = count($conf->modules); +if (in_array('fckeditor', $conf->modules)) $nbmodulesnotautoenabled--; +if (in_array('export', $conf->modules)) $nbmodulesnotautoenabled--; +if (in_array('import', $conf->modules)) $nbmodulesnotautoenabled--; print load_fiche_titre($langs->trans("ModulesSetup"), '', 'title_setup'); @@ -539,7 +533,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { $desc .= ' '.$langs->trans("ModulesDesc2", '{picto2}'); $desc = str_replace('{picto}', img_picto('', 'switch_off', 'class="size15x"'), $desc); $desc = str_replace('{picto2}', img_picto('', 'setup', 'class="size15x"'), $desc); - if (!count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled + if ($nbmodulesnotautoenabled <= getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only minimal initial modules enabled $deschelp = '
'.$desc."

\n"; } } @@ -553,7 +547,7 @@ if ($mode == 'develop') { $deschelp = '
'.$langs->trans("ModulesDevelopDesc")."

\n"; } -$head = modules_prepare_head($nbofactivatedmodules, count($modules)); +$head = modules_prepare_head($nbofactivatedmodules, count($modules), $nbmodulesnotautoenabled); if ($mode == 'common' || $mode == 'commonkanban') { diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 92895793082..29d9a9710c8 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -696,11 +696,12 @@ function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0, /** * Prepare array with list of tabs * - * @param int $nbofactivatedmodules Number if activated modules - * @param int $nboftotalmodules Nb of total modules - * @return array Array of tabs to show + * @param int $nbofactivatedmodules Number if activated modules + * @param int $nboftotalmodules Nb of total modules + * @param int $nbmodulesnotautoenabled Nb of modules not auto enabled that are activated + * @return array Array of tabs to show */ -function modules_prepare_head($nbofactivatedmodules, $nboftotalmodules) +function modules_prepare_head($nbofactivatedmodules, $nboftotalmodules, $nbmodulesnotautoenabled) { global $langs, $conf, $user, $form; @@ -711,7 +712,7 @@ function modules_prepare_head($nbofactivatedmodules, $nboftotalmodules) $head = array(); $mode = empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : $conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT; $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$mode; - if ($nbofactivatedmodules <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled) + if ($nbmodulesnotautoenabled <= getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only minimal initial modules enabled) //$head[$h][1] = $form->textwithpicto($langs->trans("AvailableModules"), $desc); $head[$h][1] = $langs->trans("AvailableModules"); $head[$h][1] .= $form->textwithpicto('', $langs->trans("YouMustEnableOneModule").'.

'.$desc.'', 1, 'warning'); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a4ca1d290a1..76ee88fda2d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1087,18 +1087,21 @@ function get_left_menu_home($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = $newmenu->add("/admin/index.php?mainmenu=home&leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup', 0, '', '', '', ''); if ($usemenuhider || empty($leftmenu) || $leftmenu == "setup") { + $nbmodulesnotautoenabled = count($conf->modules); + if (in_array('fckeditor', $conf->modules)) $nbmodulesnotautoenabled--; + if (in_array('export', $conf->modules)) $nbmodulesnotautoenabled--; + if (in_array('import', $conf->modules)) $nbmodulesnotautoenabled--; + // Load translation files required by the page $langs->loadLangs(array("admin", "help")); - $warnpicto = ''; if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete")); } $newmenu->add("/admin/company.php?mainmenu=home", $langs->trans("MenuCompanySetup").$warnpicto, 1); - $warnpicto = ''; - if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only user module enabled + if ($nbmodulesnotautoenabled <= getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only user module enabled $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete")); } diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 8e6bd78632d..e0d7a8741a5 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -365,12 +365,16 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it */ public $phpmin; + public $phpmax; + /** * @var array Minimum version of Dolibarr required by module. * e.g.: Dolibarr ≥ 3.6 = array(3, 6) */ public $need_dolibarr_version; + public $enabled_bydefault; + /** * @var bool Whether to hide the module. */ diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 9dd3fce7fcd..76d8ba4eb23 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -63,7 +63,7 @@ class modFckeditor extends DolibarrModules $this->config_page_url = array("fckeditor.php"); // Dependencies - $this->disabled = in_array(constant('JS_CKEDITOR'), array('disabled', 'disabled/')); + $this->disabled = (defined('JS_CKEDITOR') && in_array(constant('JS_CKEDITOR'), array('disabled', 'disabled/'))); $this->depends = array(); $this->requiredby = array('modWebsites'); $this->enabled_bydefault = true; // Will be enabled during install diff --git a/htdocs/index.php b/htdocs/index.php index f1ce8248921..dd1e36d04f8 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -42,12 +42,17 @@ $hookmanager->initHooks(array('index')); * Actions */ +$nbmodulesnotautoenabled = count($conf->modules); +if (in_array('fckeditor', $conf->modules)) $nbmodulesnotautoenabled--; +if (in_array('export', $conf->modules)) $nbmodulesnotautoenabled--; +if (in_array('import', $conf->modules)) $nbmodulesnotautoenabled--; + // Check if company name is defined (first install) if (!isset($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_NOM)) { header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); exit; } -if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only user module enabled +if ($nbmodulesnotautoenabled <= getDolGlobalString('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only user module enabled header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); exit; } diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index fc0dcf37799..6598843b882 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -29,6 +29,7 @@ * For installation: * It creates the login admin and set the MAIN_SECURITY_SALT to a random value. * It set the value for MAIN_VERSION_LAST_INSTALL + * It activates some modules * It creates the install.lock and shows the final message. * For upgrade: * It updates the value for MAIN_VERSION_LAST_UPGRADE. @@ -42,6 +43,7 @@ if (file_exists($conffile)) { } require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; // for dol_hash +require_once $dolibarr_main_document_root.'/core/lib/functions2.lib.php'; global $langs; @@ -287,6 +289,9 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) { */ } + // List of modules to enable + $tmparray = array(); + // If we ask to force some modules to be enabled if (!empty($force_install_module)) { if (!defined('DOL_DOCUMENT_ROOT') && !empty($dolibarr_main_document_root)) { @@ -294,9 +299,53 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) { } $tmparray = explode(',', $force_install_module); + } + + $modNameLoaded = array(); + + // Search modules dirs + $modulesdir[] = $dolibarr_main_document_root.'/core/modules/'; + + foreach ($modulesdir as $dir) { + // Load modules attributes in arrays (name, numero, orders) from dir directory + //print $dir."\n
"; + dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)"); + $handle = @opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { + $modName = substr($file, 0, dol_strlen($file) - 10); + if ($modName) { + if (!empty($modNameLoaded[$modName])) { // In cache of already loaded modules ? + $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; + setEventMessages($mesg, null, 'warnings'); + dol_syslog($mesg, LOG_ERR); + continue; + } + + try { + $res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error. + if (class_exists($modName)) { + $objMod = new $modName($db); + $modNameLoaded[$modName] = $dir; + if (!empty($objMod->enabled_bydefault) && !in_array($file, $tmparray)) { + $tmparray[] = $file; + } + } + } catch (Exception $e) { + dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); + } + } + } + } + } + } + + // Loop on each modules to activate it + if (!empty($tmparray)) { foreach ($tmparray as $modtoactivate) { $modtoactivatenew = preg_replace('/\.class\.php$/i', '', $modtoactivate); - print $langs->trans("ActivateModule", $modtoactivatenew).'
'; + //print $langs->trans("ActivateModule", $modtoactivatenew).'
'; $file = $modtoactivatenew.'.class.php'; dolibarr_install_syslog('step5: activate module file='.$file); @@ -307,8 +356,10 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) { print 'ERROR: failed to activateModule() file='.$file; } } + //print '
'; } + // Now delete the flag to say install is complete dolibarr_install_syslog('step5: remove MAIN_NOT_INSTALLED const'); $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')." = 'MAIN_NOT_INSTALLED'"); if (!$resql) { From f444dd8f49f7c2e2deae96853e724cf7bce559b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Feb 2023 00:58:55 +0100 Subject: [PATCH 48/50] Trans --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9706ffedb76..90e520cea25 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1234,7 +1234,7 @@ SetupDescription4=%s -> %s

This software is a suite of m SetupDescription5=Other Setup menu entries manage optional parameters. SetupDescriptionLink=%s - %s SetupDescription3b=Basic parameters used to customize the default behavior of your application (e.g for country-related features). -SetupDescription4b=This software is a suite of many modules/applications. The modules related to your needs must be enabled and configured. Menu entries will appears with the activation of these modules. +SetupDescription4b=This software is a suite of many modules/applications. The modules related to your needs must be activated. Menu entries will appears with the activation of these modules. AuditedSecurityEvents=Security events that are audited NoSecurityEventsAreAduited=No security events are audited. You can enable them from menu %s Audit=Security events From 8f2076e83e0183b95446321b3676524397c572d9 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 9 Feb 2023 11:07:30 +0100 Subject: [PATCH 49/50] fix problems in menus for modulebuilder --- htdocs/modulebuilder/index.php | 133 +++++++++++++++++++-------------- 1 file changed, 76 insertions(+), 57 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 6f62e8f142c..916a91ecf61 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -896,6 +896,17 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) { // Init an object if ($dirins && $action == 'initobject' && $module && $objectname) { + // check if module is enabled + if (isModEnabled(strtolower($module))) { + $result = unActivateModule(strtolower($module)); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + if ($result) { + setEventMessages($result, null, 'errors'); + } + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); + setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings'); + } + $objectname = ucfirst($objectname); $dirins = $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath']; @@ -1341,43 +1352,31 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { // Regenerate left menu entry in descriptor for $objectname $stringtoadd = " \$this->menu[\$r++]=array( - // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'fk_menu'=>'fk_mainmenu=mymodule', - // This is a Left menu entry 'type'=>'left', 'titre'=>'List MyObject', 'mainmenu'=>'mymodule', 'leftmenu'=>'mymodule_myobject', 'url'=>'/mymodule/myobject_list.php', - // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'mymodule@mymodule', 'position'=>1100+\$r, - // Define condition to show or hide menu entry. Use '\$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '\$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'\$conf->mymodule->enabled', - // Use 'perms'=>'\$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'perms'=>'1', 'target'=>'', - // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, ); \$this->menu[\$r++]=array( - // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule_myobject', - // This is a Left menu entry 'type'=>'left', 'titre'=>'New MyObject', 'mainmenu'=>'mymodule', 'leftmenu'=>'mymodule_myobject', 'url'=>'/mymodule/myobject_card.php?action=create', - // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'mymodule@mymodule', 'position'=>1100+\$r, - // Define condition to show or hide menu entry. Use '\$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '\$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'\$conf->mymodule->enabled', - // Use 'perms'=>'\$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'perms'=>'1', 'target'=>'', - // 0=Menu for internal users, 1=external users, 2=both 'user'=>2 );\n"; $stringtoadd = preg_replace('/MyObject/', $objectname, $stringtoadd); @@ -1389,8 +1388,28 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { // TODO Allow a replace with regex using dolReplaceInFile with param arryreplacementisregex to 1 // TODO Avoid duplicate addition - dolReplaceInFile($moduledescriptorfile, array('END MODULEBUILDER LEFTMENU MYOBJECT */' => '*/'."\n".$stringtoadd."\n\t\t/* END MODULEBUILDER LEFTMENU MYOBJECT */")); - + // load class and check if menu exist with same object name + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + dol_include_once($pathtofile); + $class = 'mod'.$module; + if (class_exists($class)) { + try { + $moduleobj = new $class($db); + } catch (Exception $e) { + $error++; + dol_print_error($db, $e->getMessage()); + } + } + $menus = $moduleobj->menu; + $counter = 0 ; + foreach ($menus as $menu) { + if ($menu['leftmenu'] == strtolower($module).'_'.strtolower($objectname)) { + $counter++; + } + } + if (!$counter) { + dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER LEFTMENU MYOBJECT */' => '/*LEFTMENU '.strtoupper($objectname).'*/'.$stringtoadd."\n\t\t".'/*END LEFTMENU '.strtoupper($objectname).'*/'."\n\t\t".'/* END MODULEBUILDER LEFTMENU MYOBJECT */')); + } // Add module descriptor to list of files to replace "MyObject' string with real name of object. $filetogenerate[] = 'core/modules/mod'.$module.'.class.php'; } @@ -1728,6 +1747,16 @@ if ($dirins && $action == 'confirm_deletemodule') { } if ($dirins && $action == 'confirm_deleteobject' && $objectname) { + // check if module is enabled (if it's disabled and send msg event) + if (isModEnabled(strtolower($module))) { + $result = unActivateModule(strtolower($module)); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + if ($result) { + setEventMessages($result, null, 'errors'); + } + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); + setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings'); + } if (preg_match('/[^a-z0-9_]/i', $objectname)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); @@ -1766,53 +1795,43 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) { ); //menu for the object selected - $stringtoedit = "\$this->menu[\$r++]=array( - // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'fk_menu'=>'fk_mainmenu=".strtolower($module)."', - // This is a Left menu entry - 'type'=>'left', - 'titre'=>'List ".ucfirst($objectname)."', - 'mainmenu'=>'".strtolower($module)."', - 'leftmenu'=>'".strtolower($module)."_".strtolower($objectname)."', - 'url'=>'/".strtolower($module)."/".strtolower($objectname)."_list.php', - // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'langs'=>'".strtolower($module)."@".strtolower($module)."', - 'position'=>1100+\$r, - // Define condition to show or hide menu entry. Use '\$conf->".strtolower($module)."->enabled' if entry must be visible if module is enabled. Use '\$leftmenu==\'system\'' to show if leftmenu system is selected. - 'enabled'=>'\$conf->".strtolower($module)."->enabled', - // Use 'perms'=>'\$user->rights->".strtolower($module)."->level1->level2' if you want your menu with a permission rules - 'perms'=>'1', - 'target'=>'', - // 0=Menu for internal users, 1=external users, 2=both - 'user'=>2, - ); - \$this->menu[\$r++]=array( - // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'fk_menu'=>'fk_mainmenu=".strtolower($module).",fk_leftmenu=".strtolower($module)."_".strtolower($objectname)."', - // This is a Left menu entry - 'type'=>'left', - 'titre'=>'New ".ucfirst($objectname)."', - 'mainmenu'=>'".strtolower($module)."', - 'leftmenu'=>'".strtolower($module)."_".strtolower($objectname)."', - 'url'=>'/".strtolower($module)."/".strtolower($objectname)."_card.php?action=create', - // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'langs'=>'".strtolower($module)."@".strtolower($module)."', - 'position'=>1100+\$r, - // Define condition to show or hide menu entry. Use '\$conf->".strtolower($module)."->enabled' if entry must be visible if module is enabled. Use '\$leftmenu==\'system\'' to show if leftmenu system is selected. - 'enabled'=>'\$conf->".strtolower($module)."->enabled', - // Use 'perms'=>'\$user->rights->".strtolower($module)."->level1->level2' if you want your menu with a permission rules - 'perms'=>'1', - 'target'=>'', - // 0=Menu for internal users, 1=external users, 2=both - 'user'=>2 - );"; + // load class and check if menu exist for this object + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + dol_include_once($pathtofile); + $class = 'mod'.$module; + if (class_exists($class)) { + try { + $moduleobj = new $class($db); + } catch (Exception $e) { + $error++; + dol_print_error($db, $e->getMessage()); + } + } + $menus = $moduleobj->menu; $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; - $check = dolReplaceInFile($moduledescriptorfile, array($stringtoedit => '')); - if ($check > 0) { - dolReplaceInFile($moduledescriptorfile, array('/*'.strtoupper($objectname).'*/' => '')); + foreach ($menus as $menu) { + if ($menu['type'] == 'left' && $menu['leftmenu'] == strtolower($module).'_'.strtolower($objectname)) { + $left="\$this->menu[\$r++]=array( + 'fk_menu'=>'".$menu['fk_menu']."', + 'type'=>'".$menu['type']."', + 'titre'=>'".$menu['titre']."', + 'mainmenu'=>'".$menu['mainmenu']."', + 'leftmenu'=>'".$menu['leftmenu']."', + 'url'=>'".$menu['url']."', + 'langs'=>'".$menu['langs']."', + 'position'=>1100+\$r, + 'enabled'=>'".$menu['enabled']."', + 'perms'=>'".$menu['perms']."', + 'target'=>'".$menu['target']."', + 'user'=>".$menu['user'].", + );"; + dolReplaceInFile($moduledescriptorfile, array($left => '')); + } } + // Remarque : "\n" not handling yet + $check = dolReplaceInFile($moduledescriptorfile, array('/*LEFTMENU '.strtoupper($objectname).'*/'."\n" => '',"\t\t".'/*END LEFTMENU '.strtoupper($objectname).'*/'."\n" => '')); // regenerate permissions and delete them $rights = " From 78c6f12a8aa676b32710609e34122487b5a4dfdd Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 9 Feb 2023 11:40:43 +0100 Subject: [PATCH 50/50] NEW functionality (delete menu manually) in modulebuilder --- htdocs/langs/en_US/modulebuilder.lang | 5 +- htdocs/langs/fr_FR/modulebuilder.lang | 5 +- htdocs/modulebuilder/index.php | 85 +++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 600dfba7227..3c442fcc84a 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -169,4 +169,7 @@ GeneratePermissions=I want to add the rights for this object GeneratePermissionsHelp=generate default rights for this object PermissionDeletedSuccesfuly=Permission has been successfully removed PermissionUpdatedSuccesfuly=Permission has been successfully updated -PermissionAddedSuccesfuly=Permission has been successfully added \ No newline at end of file +PermissionAddedSuccesfuly=Permission has been successfully added +MenuDeletedSuccessfuly=Menu has been successfully deleted +MenuAddedSuccessfuly=Menu has been successfully added +MenuUpdatedSuccessfuly=Menu has been successfully updated \ No newline at end of file diff --git a/htdocs/langs/fr_FR/modulebuilder.lang b/htdocs/langs/fr_FR/modulebuilder.lang index 3c4161941e8..c9c0b9ef1bc 100644 --- a/htdocs/langs/fr_FR/modulebuilder.lang +++ b/htdocs/langs/fr_FR/modulebuilder.lang @@ -169,4 +169,7 @@ GeneratePermissions=Je souhaite ajouter les droits pour cet objet GeneratePermissionsHelp=générer les droits par défault pour cet objet PermissionDeletedSuccesfuly=La permission a été supprimée avec succès PermissionUpdatedSuccesfuly=La permission a été mise à jour avec succès -PermissionAddedSuccesfuly= La permission a été ajoutée avec succès \ No newline at end of file +PermissionAddedSuccesfuly= La permission a été ajoutée avec succès +MenuDeletedSuccessfuly=Menu a été supprimé avec succès +MenuAddedSuccessfuly=Menu a été ajouté avec succès +MenuUpdatedSuccessfuly=Menu a été mise à jour avec succès \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 916a91ecf61..e52985e8c50 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2360,6 +2360,91 @@ if ($action == 'reset' && $user->admin) { exit; } +// delete menu +if ($dirins && $action == 'confirm_deletemenu' && GETPOST('menukey', 'int')) { + // check if module is enabled + if (isModEnabled(strtolower($module))) { + $result = unActivateModule(strtolower($module)); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + if ($result) { + setEventMessages($result, null, 'errors'); + } + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); + setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings'); + } + // load class and check if menu exist + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + dol_include_once($pathtofile); + $class = 'mod'.$module; + if (class_exists($class)) { + try { + $moduleobj = new $class($db); + } catch (Exception $e) { + $error++; + dol_print_error($db, $e->getMessage()); + } + } + + $menus = $moduleobj->menu; + + $key = (int) GETPOST('menukey', 'int'); + $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + + + if ($menus[$key]['type'] == 'top') { + $menuTop = " + \$this->menu[\$r++] = array( + 'fk_menu'=>'".$menus[$key]['fk_menu']."', + 'type'=>'".$menus[$key]['type']."', + 'titre'=>'".$menus[$key]['titre']."', + 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'), + 'mainmenu'=>'".$menus[$key]['mainmenu']."', + 'leftmenu'=> '', + 'url'=>'".$menus[$key]['url']."', + 'langs'=>'".$menus[$key]['langs']."', + 'position'=>1000 + \$r, + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'perms' =>'".$menus[$key]['perms']."', + 'target'=>'".$menus[$key]['target']."', + 'user'=>".$menus[$key]['user'].", + );"; + $check = dolReplaceInFile($moduledescriptorfile, array($menuTop => '',"\t\t".'/*TOPMENU '.strtolower($menus[$key]['titre']).'*/'."\n" => '', '/*END TOPMENU '.strtolower($menus[$key]['titre']).'*/'."\n\t\t" => '')); + } + if ($menus[$key]['type'] == 'left') { + $left="\$this->menu[\$r++]=array( + 'fk_menu'=>'".$menus[$key]['fk_menu']."', + 'type'=>'".$menus[$key]['type']."', + 'titre'=>'".$menus[$key]['titre']."', + 'mainmenu'=>'".$menus[$key]['mainmenu']."', + 'leftmenu'=>'".$menus[$key]['leftmenu']."', + 'url'=>'".$menus[$key]['url']."', + 'langs'=>'".$menus[$key]['langs']."', + 'position'=>1100+\$r, + 'enabled'=>'".$menus[$key]['enabled']."', + 'perms'=>'".$menus[$key]['perms']."', + 'target'=>'".$menus[$key]['target']."', + 'user'=>".$menus[$key]['user'].", + );"; + $check = dolReplaceInFile($moduledescriptorfile, array($left => '')); + + // check if still had menu created when initial object + // if not we delete the comments from file + $menuForObj = 0; + foreach ($menus as $menu) { + if ($menu['leftmenu'] == $menus[$key]['leftmenu']) { + $menuForObj++; + } + } + if ($menuForObj == 1) { + $extractObjName = explode("_", $menus[$key]['leftmenu']); + dolReplaceInFile($moduledescriptorfile, array('/*LEFTMENU '.strtoupper($extractObjName[1]).'*/'."\n" => '','/*END LEFTMENU '.strtoupper($extractObjName[1]).'*/' => '')); + } + } + + setEventMessages($langs->trans('MenuDeletedSuccessfuly'), null); + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=menus&module='.$module); + exit; +} /*
'.$langs->trans("Ref").'
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; print '
'.$langs->trans("ManageLotSerial").''; $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"), '2' => $langs->trans("ProductStatusOnSerial")); - print $form->selectarray('status_batch', $statutarray, $object->status_batch); + print $form->selectarray('status_batch', $statutarray, (GETPOSTISSET('status_batch') ? GETPOST('status_batch') : $object->status_batch)); print '
'.$langs->trans("DefaultWarehouse").''; print img_picto($langs->trans("DefaultWarehouse"), 'stock', 'class="pictofixedwidth"'); - print $formproduct->selectWarehouses($object->fk_default_warehouse, 'fk_default_warehouse', 'warehouseopen', 1); + print $formproduct->selectWarehouses((GETPOSTISSET('fk_default_warehouse') ? GETPOST('fk_default_warehouse') : $object->fk_default_warehouse), 'fk_default_warehouse', 'warehouseopen', 1); print ' '; print '
'.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).''; - print $formproduct->selectProductNature('finished', $object->finished); + print $formproduct->selectProductNature('finished', (GETPOSTISSET('finished') ? GETPOST('finished') : $object->finished)); print '
'.$form->textwithpicto($langs->trans("DefaultBOM"), $langs->trans("DefaultBOMDesc", $langs->transnoentitiesnoconv("Finished"))).''; $bomkey = "Bom:bom/class/bom.class.php:0:t.status=1 AND t.fk_product=".((int) $object->id); - print $form->selectForForms($bomkey, 'fk_default_bom', $object->fk_default_bom, 1); + print $form->selectForForms($bomkey, 'fk_default_bom', (GETPOSTISSET('fk_default_bom') ? GETPOST('fk_default_bom') : $object->fk_default_bom), 1); print '
'.$langs->trans("Weight").''; - print ' '; - print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); + print ' '; + print $formproduct->selectMeasuringUnits("weight_units", "weight", (GETPOSTISSET('weight_units') ? GETPOST('weight_units') : $object->weight_units), 0, 2); print '
'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").''; - print 'x'; - print 'x'; - print ' '; - print $formproduct->selectMeasuringUnits("size_units", "size", $object->length_units, 0, 2); + print 'x'; + print 'x'; + print ' '; + print $formproduct->selectMeasuringUnits("size_units", "size", (GETPOSTISSET('size_units') ? GETPOST('size_units') : $object->length_units), 0, 2); print '
'.$langs->trans("Surface").''; - print ' '; - print $formproduct->selectMeasuringUnits("surface_units", "surface", $object->surface_units, 0, 2); + print ' '; + print $formproduct->selectMeasuringUnits("surface_units", "surface", (GETPOSTISSET('surface_units') ? GETPOST('surface_units') : $object->volume), 0, 2); print '
'.$langs->trans("Volume").''; - print ' '; - print $formproduct->selectMeasuringUnits("volume_units", "volume", $object->volume_units, 0, 2); + print ' '; + print $formproduct->selectMeasuringUnits("volume_units", "volume", (GETPOSTISSET('volume_units') ? GETPOST('volume_units') : $volume_units), 0, 2); print '
'.$langs->trans("NetMeasure").''; - print ' '; - print $formproduct->selectMeasuringUnits("net_measure_units", "", $object->net_measure_units, 0, 0); + print ' '; + print $formproduct->selectMeasuringUnits("net_measure_units", "", (GETPOSTISSET('net_measure') ? GETPOST('net_measure') : $object->net_measure), 0, 0); print '
'.$langs->trans("CustomCode").'
'.$langs->trans("CustomCode").'
'.$langs->trans("CountryOrigin").''; @@ -1970,6 +1970,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $arrayselected[] = $cat->id; } } + if (GETPOSTISSET('categories', 'array')) { + foreach (GETPOST('categories', 'array') as $cat) { + $arrayselected[] = $cat; + } + } print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print "
'.$langs->trans("ProductAccountancySellCode").''; - print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print $formaccounting->select_account((GETPOSTISSET('accountancy_code_sell') ? GETPOST('accountancy_code_sell') : $object->accountancy_code_sell), 'accountancy_code_sell', 1, '', 1, 1, 'minwidth150 maxwidth300'); print '
'.$langs->trans("ProductAccountancySellIntraCode").''; - print $formaccounting->select_account($object->accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print $formaccounting->select_account((GETPOSTISSET('accountancy_code_sell_intra') ? GETPOST('accountancy_code_sell_intra') : $object->accountancy_code_sell_intra), 'accountancy_code_sell_intra', 1, '', 1, 1, 'minwidth150 maxwidth300'); print '
'.$langs->trans("ProductAccountancySellExportCode").''; - print $formaccounting->select_account($object->accountancy_code_sell_export, 'accountancy_code_sell_export', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print $formaccounting->select_account((GETPOSTISSET('accountancy_code_sell_export') ? GETPOST('accountancy_code_sell_export') : $object->accountancy_code_sell_export), 'accountancy_code_sell_export', 1, '', 1, 1, 'minwidth150 maxwidth300'); print '
'.$langs->trans("ProductAccountancyBuyCode").''; - print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print $formaccounting->select_account((GETPOSTISSET('accountancy_code_buy') ? GETPOST('accountancy_code_buy') : $object->accountancy_code_buy), 'accountancy_code_buy', 1, '', 1, 1, 'minwidth150 maxwidth300'); print '
'.$langs->trans("ProductAccountancyBuyIntraCode").''; - print $formaccounting->select_account($object->accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print $formaccounting->select_account((GETPOSTISSET('accountancy_code_buy_intra') ? GETPOST('accountancy_code_buy_intra') : $object->accountancy_code_buy_intra), 'accountancy_code_buy_intra', 1, '', 1, 1, 'minwidth150 maxwidth300'); print '
'.$langs->trans("ProductAccountancyBuyExportCode").''; - print $formaccounting->select_account($object->accountancy_code_buy_export, 'accountancy_code_buy_export', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print $formaccounting->select_account((GETPOSTISSET('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export') : $object->accountancy_code_buy_export), 'accountancy_code_buy_export', 1, '', 1, 1, 'minwidth150 maxwidth300'); print '
'.$langs->trans("ProductAccountancySellCode").''; + print ''; print '
'.$langs->trans("ProductAccountancySellIntraCode").''; + print ''; print '
'.$langs->trans("ProductAccountancySellExportCode").''; + print ''; print '
'.$langs->trans("ProductAccountancyBuyCode").''; + print ''; print '
'.$langs->trans("ProductAccountancyBuyIntraCode").''; + print ''; print '
'.$langs->trans("ProductAccountancyBuyExportCode").''; + print ''; print '
'.$langs->trans("Surface").''; print ' '; - print $formproduct->selectMeasuringUnits("surface_units", "surface", (GETPOSTISSET('surface_units') ? GETPOST('surface_units') : $object->volume), 0, 2); + print $formproduct->selectMeasuringUnits("surface_units", "surface", (GETPOSTISSET('surface_units') ? GETPOST('surface_units') : $object->surface_units), 0, 2); print '
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; print '
'.dol_escape_htmltag($rib->label).''.dol_escape_htmltag($rib->label).''; if ($rib->stripe_card_ref) { From e671b63a029e1b1690cfd0128c7f09835d37e4b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Feb 2023 01:32:44 +0100 Subject: [PATCH 32/50] Trans --- htdocs/langs/en_US/main.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 4c4d79398b2..a4457363d70 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1223,5 +1223,5 @@ AddToContacts=Add address to my contacts LastAccess=Last access UploadAnImageToSeeAPhotoHere=Upload an image from the tab %s to see a photo here LastPasswordChangeDate=Last password change date -PublicVirtualCardUrl=Public virtual user card +PublicVirtualCardUrl=Virtual business card page TreeView=Tree view From 23d212d9dce614e0ae9b53835cf2f189b6fc1c50 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 7 Feb 2023 13:58:29 +0000 Subject: [PATCH 33/50] Fixing style errors. --- htdocs/modulebuilder/index.php | 241 ++++++++++++++++----------------- 1 file changed, 118 insertions(+), 123 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 758aaaa487c..704870294f0 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1950,31 +1950,31 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { dol_include_once($pathtofile); $class = 'mod'.$module; if (class_exists($class)) { - try { - $moduleobj = new $class($db); - } catch (Exception $e) { - $error++; - dol_print_error($db, $e->getMessage()); - } - } + try { + $moduleobj = new $class($db); + } catch (Exception $e) { + $error++; + dol_print_error($db, $e->getMessage()); + } + } - // verify informations entred - if (!GETPOST('label','alpha')) { + // verify informations entred + if (!GETPOST('label', 'alpha')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } - if (!GETPOST('permissionObj','alpha')) { + if (!GETPOST('permissionObj', 'alpha')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Rights")), null, 'errors'); } - + $label = GETPOST('label', 'alpha'); - $objectForPerms = strtolower(GETPOST('permissionObj','alpha')); + $objectForPerms = strtolower(GETPOST('permissionObj', 'alpha')); $crud = GETPOST('crud', 'alpha'); // check coherence between crud and label - if ($label == "Read objects of $module" && $crud != "read"){ - $crud = "read"; + if ($label == "Read objects of $module" && $crud != "read") { + $crud = "read"; $label == "Read objects of $module"; } if ($label == "Create/Update objects of $module" && $crud != "write") { @@ -1994,39 +1994,39 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { $existRight = 0; $allObject = array(); - - - for ($i =0; $itrans("ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)), null, 'errors'); - } + } } // if not found permission for the object - if (!in_array($objectForPerms,array_unique($allObject))){ + if (!in_array($objectForPerms, array_unique($allObject))) { $firstRight++; $existRight = 0; } if (!$error) { - if (isModEnabled(strtolower($module))){ + if (isModEnabled(strtolower($module))) { $result = unActivateModule(strtolower($module)); dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); if ($result) { setEventMessages($result, null, 'errors'); } header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); - setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null,'warnings'); + setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings'); } //prepare stirng to add $rightToAdd = " @@ -2037,24 +2037,22 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { \$r++; "; $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; - if (!$existRight){ + if (!$existRight) { //var_dump(1);exit; dolReplaceInFile($moduledescriptorfile, array('/*END '.strtoupper($objectForPerms).'*/' => $rightToAdd.'/*END '.strtoupper($objectForPerms).'*/')); setEventMessages($langs->trans('PermissionAddedSuccesfuly'), null); } - if ($firstRight){ + if ($firstRight) { //var_dump(array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectForPerms).'*/'.$rightToAdd."/*END ".strtoupper($objectForPerms).'*/'."\n\t\t"."/* END MODULEBUILDER PERMISSIONS */"));exit; dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectForPerms).'*/'.$rightToAdd."/*END ".strtoupper($objectForPerms).'*/'."\n\t\t"."/* END MODULEBUILDER PERMISSIONS */")); setEventMessages($langs->trans('PermissionAddedSuccesfuly'), null); } - } header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); exit; - } -// Delete permission +// Delete permission if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('permskey', 'int')) { $error = 0; // load class and check if right exist @@ -2062,16 +2060,16 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('p dol_include_once($pathtofile); $class = 'mod'.$module; if (class_exists($class)) { - try { - $moduleobj = new $class($db); - } catch (Exception $e) { - $error++; - dol_print_error($db, $e->getMessage()); - } - } - + try { + $moduleobj = new $class($db); + } catch (Exception $e) { + $error++; + dol_print_error($db, $e->getMessage()); + } + } + $permissions = $moduleobj->rights; - $key = (int)GETPOST('permskey','int')-1; + $key = (int) GETPOST('permskey', 'int')-1; //get permission want to delete from permissions array $x1 = $permissions[$key][1]; $x2 = $permissions[$key][4]; @@ -2084,41 +2082,40 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('p \$this->rights[\$r][5] = '$x3'; \$r++; "; - + $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; $check = dolReplaceInFile($moduledescriptorfile, array($rightTodelete => ''."\n\t\t")); - if ($check > 0) { - //check if all permissions of object was deleted - $permsForObj = array(); - foreach($permissions as $perms){ - $permsForObj[] = $perms[4]; - } - $permsForObj = array_count_values($permsForObj); - //var_dump($permsForObj[$permissions[$key][4]]);exit; - if($permsForObj[$permissions[$key][4]] == 1) { - $delObjStart = dolReplaceInFile($moduledescriptorfile, array('/*'.strtoupper($permissions[$key][4].'*/') => '','/*END '.strtoupper($permissions[$key][4].'*/') => '')); - } - } - if(!$error){ - // check if module is enabled - if (isModEnabled(strtolower($module))){ - $result = unActivateModule(strtolower($module)); - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); - if ($result) { - setEventMessages($result, null, 'errors'); - } - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); - setEventMessages($langs->trans('PermissionDeletedSuccesfuly'), null); - setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null,'warnings'); - exit; - } - else{ - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); - setEventMessages($langs->trans('PermissionDeletedSuccesfuly'), null); - exit; - } + if ($check > 0) { + //check if all permissions of object was deleted + $permsForObj = array(); + foreach ($permissions as $perms) { + $permsForObj[] = $perms[4]; } + $permsForObj = array_count_values($permsForObj); + //var_dump($permsForObj[$permissions[$key][4]]);exit; + if ($permsForObj[$permissions[$key][4]] == 1) { + $delObjStart = dolReplaceInFile($moduledescriptorfile, array('/*'.strtoupper($permissions[$key][4].'*/') => '','/*END '.strtoupper($permissions[$key][4].'*/') => '')); + } + } + if (!$error) { + // check if module is enabled + if (isModEnabled(strtolower($module))) { + $result = unActivateModule(strtolower($module)); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + if ($result) { + setEventMessages($result, null, 'errors'); + } + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); + setEventMessages($langs->trans('PermissionDeletedSuccesfuly'), null); + setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings'); + exit; + } else { + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); + setEventMessages($langs->trans('PermissionDeletedSuccesfuly'), null); + exit; + } + } } // Update permission @@ -2129,30 +2126,30 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e dol_include_once($pathtofile); $class = 'mod'.$module; if (class_exists($class)) { - try { - $moduleobj = new $class($db); - } catch (Exception $e) { - $error++; - dol_print_error($db, $e->getMessage()); - } - } - // verify informations entred - if (!GETPOST('label','alpha')) { + try { + $moduleobj = new $class($db); + } catch (Exception $e) { + $error++; + dol_print_error($db, $e->getMessage()); + } + } + // verify informations entred + if (!GETPOST('label', 'alpha')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } - if (!GETPOST('permissionObj','alpha')) { + if (!GETPOST('permissionObj', 'alpha')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Rights")), null, 'errors'); } - + $label = GETPOST('label', 'alpha'); - $objectForPerms = strtolower(GETPOST('permissionObj','alpha')); + $objectForPerms = strtolower(GETPOST('permissionObj', 'alpha')); $crud = GETPOST('crud', 'alpha'); - - if ($label == "Read objects of $module" && $crud != "read"){ - $crud = "read"; + + if ($label == "Read objects of $module" && $crud != "read") { + $crud = "read"; $label == "Read objects of $module"; } if ($label == "Create/Update objects of $module" && $crud != "write") { @@ -2165,7 +2162,7 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e } $permissions = $moduleobj->rights; - $r =(int)GETPOST('counter'); + $r =(int) GETPOST('counter'); //get permission want to delete from permissions array $x1 = $permissions[$r-1][1]; $x2 = $permissions[$r-1][4]; @@ -2177,26 +2174,26 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e $firstRight = 0; $existRight = 0; $allObject = array(); - - for ($i =0; $itrans("ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)), null, 'errors'); - } + + for ($i =0; $itrans("ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)), null, 'errors'); + } + } + } + //prepare right want to delete $right = " \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); @@ -2205,7 +2202,7 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e \$this->rights[\$r][5] = '$x3'; \$r++; "; - + $rightUpdated = " \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); \$this->rights[\$r][1] = '$label'; @@ -2213,26 +2210,24 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e \$this->rights[\$r][5] = '$crud'; \$r++; "; - if(!$error){ - - if (isModEnabled(strtolower($module))){ - $result = unActivateModule(strtolower($module)); - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); - if ($result) { - setEventMessages($result, null, 'errors'); - } - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); - setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null,'warnings'); + if (!$error) { + if (isModEnabled(strtolower($module))) { + $result = unActivateModule(strtolower($module)); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + if ($result) { + setEventMessages($result, null, 'errors'); } - - $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; - $check = dolReplaceInFile($moduledescriptorfile, array($right => $rightUpdated)); - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); - setEventMessages($langs->trans('PermissionUpdatedSuccesfuly'), null); - exit; + setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings'); } - + + $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + $check = dolReplaceInFile($moduledescriptorfile, array($right => $rightUpdated)); + + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); + setEventMessages($langs->trans('PermissionUpdatedSuccesfuly'), null); + exit; + } } // Save file if ($action == 'savefile' && empty($cancel)) { From 6f8c26fa4741b8d491d78c8937aeb3bfcf2da50f Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 7 Feb 2023 16:18:13 +0100 Subject: [PATCH 34/50] NEW can stay on edit field when errors occurs --- htdocs/core/class/html.form.class.php | 8 ++++++-- htdocs/product/stock/productlot_card.php | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c6cf71fbe44..7de2938e299 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -202,9 +202,10 @@ class Form * @param string $paramid Key of parameter for id ('id', 'socid') * @param string $gm 'auto' or 'tzuser' or 'tzuserrel' or 'tzserver' (when $typeofdata is a date) * @param array $moreoptions Array with more options. For example array('addnowlink'=>1), array('valuealreadyhtmlescaped'=>1) + * @param string $editaction [=''] use GETPOST default action or set action to edit mode * @return string HTML edit field */ - public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 1, $formatfunc = '', $paramid = 'id', $gm = 'auto', $moreoptions = array()) + public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 1, $formatfunc = '', $paramid = 'id', $gm = 'auto', $moreoptions = array(), $editaction = '') { global $conf, $langs; @@ -233,7 +234,10 @@ class Form if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;|day|datepicker|dayhour|datehourpicker/', $typeofdata)) { // TODO add jquery timepicker and support select $ret .= $this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg); } else { - $editmode = (GETPOST('action', 'aZ09') == 'edit'.$htmlname); + if ($editaction == '') { + $editaction = GETPOST('action', 'aZ09'); + } + $editmode = ($editaction == 'edit'.$htmlname); if ($editmode) { $ret .= "\n"; $ret .= '
'; diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index acf2f526773..a39d92f93aa 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -469,7 +469,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); print ''; - print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action); print '
'; print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); print ''; - print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action); print '