From 34145ed4432416943ee2d00532822a674b9fa7c2 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Sun, 11 Mar 2018 21:58:32 +0100 Subject: [PATCH 01/14] Do not display multicurrency cols if currency of object is same as main currency --- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/tpl/objectline_create.tpl.php | 6 +++--- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- htdocs/core/tpl/objectline_view.tpl.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4d44a4b6fec..9c1cd3cb6bd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3370,7 +3370,7 @@ abstract class CommonObject print ''.$langs->trans('PriceUHT').''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; @@ -3409,7 +3409,7 @@ abstract class CommonObject print ''.$langs->trans('TotalHTShort').''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f14af2b838f..1deef2e2412 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -65,7 +65,7 @@ if ($nolinesbefore) { trans('VAT'); ?> trans('PriceUHT'); ?> - multicurrency->enabled)) { $colspan++;?> + multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++;?> trans('PriceUHTCurrency'); ?> @@ -266,7 +266,7 @@ else { "> - multicurrency->enabled)) { $colspan++;?> + multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++;?> "> @@ -402,7 +402,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da } } - if (!empty($conf->multicurrency->enabled)) $colspan+=2; + if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) $colspan+=2; if (! empty($usemargins)) { diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index d982516bd67..80d8c617c44 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -122,7 +122,7 @@ $coldisplay=-1; // We remove first td if ($this->situation_counter > 1) print ' readonly'; print '>'; - if (!empty($conf->multicurrency->enabled)) { + if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++; print ''; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 0a20c2679a1..984af537ea9 100755 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -138,7 +138,7 @@ if (empty($usemargins)) $usemargins=0; subprice); ?> - multicurrency->enabled)) { ?> + multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { ?> multicurrency_subprice); ?> @@ -204,7 +204,7 @@ if (empty($usemargins)) $usemargins=0; trans('Option'); ?> total_ht); ?> - multicurrency->enabled)) { ?> + multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { ?> multicurrency_total_ht); ?> From c044d9ab584705e231a1ee03ad87b13fb5d60730 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 25 Apr 2018 16:20:09 +0200 Subject: [PATCH 02/14] FIX: actioncomm export: type filtering not working --- htdocs/core/modules/modAgenda.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 83175bcdefc..5f78b229461 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -378,7 +378,7 @@ class modAgenda extends DolibarrModules $this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date", 'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric", 'ac.durationp'=>"Duree", - 'cac.libelle'=>"List:c_actioncomm:libelle:id", + 'cac.libelle'=>"List:c_actioncomm:libelle:libelle", 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text', 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text', 's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text'); @@ -400,7 +400,7 @@ class modAgenda extends DolibarrModules $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda',1).')'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR ac.fk_soc IS NULL)'; if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id); - $this->export_sql_end[$r] .=' ORDER BY ac.datep'; + $this->export_sql_order[$r]=' ORDER BY ac.datep'; } From 7cedf55c273d36353540c70a5d0fc01f8e94cab4 Mon Sep 17 00:00:00 2001 From: jfefe Date: Fri, 27 Apr 2018 20:54:48 +0200 Subject: [PATCH 03/14] FIX : missing english name for object 'product' is used by API to check perms and return a 401 error even if user has correct permissions --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index a901dd817d5..c9968bb459f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -384,7 +384,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh if ($feature == 'project') $feature='projet'; if ($feature == 'task') $feature='projet_task'; - $check = array('adherent','banque','don','user','usergroup','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company) + $check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object $checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet','project'); // Test for project object From e79c907ae080d8065b6a58920bc957f489a7e6e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 11:01:33 +0200 Subject: [PATCH 04/14] Fix edit of capital --- htdocs/societe/card.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e235f6f431c..40e3083e125 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -60,7 +60,7 @@ $mesg=''; $error=0; $errors=array(); $action = (GETPOST('action','aZ09') ? GETPOST('action','aZ09') : 'view'); $cancel = GETPOST('cancel','alpha'); $backtopage = GETPOST('backtopage','alpha'); -$confirm = GETPOST('confirm'); +$confirm = GETPOST('confirm','alpha'); $socid = GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; @@ -181,12 +181,12 @@ if (empty($reshook)) // Merge categories $static_cat = new Categorie($db); - + $custcats_ori = $static_cat->containing($soc_origin->id, 'customer', 'id'); $custcats = $static_cat->containing($object->id, 'customer', 'id'); $custcats = array_merge($custcats,$custcats_ori); $object->setCategories($custcats, 'customer'); - + $suppcats_ori = $static_cat->containing($soc_origin->id, 'supplier', 'id'); $suppcats = $static_cat->containing($object->id, 'supplier', 'id'); $suppcats = array_merge($suppcats,$suppcats_ori); @@ -1885,7 +1885,9 @@ else // Capital print ''.fieldLabel('Capital','capital').''; - print ' '.$langs->trans("Currency".$conf->currency).''; + print ' '.$langs->trans("Currency".$conf->currency).''; // Default language if (! empty($conf->global->MAIN_MULTILANGS)) From ab85fa87219dd4db9982906c72cf0da85c28bfe1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 17:45:34 +0200 Subject: [PATCH 05/14] Backport EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS to solve blocking situation. --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index f70982fd429..63abda22fed 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -216,7 +216,7 @@ if (empty($reshook)) if ($ret < 0) $error++; } - if ($object->periode_existe($fuser,$object->date_debut,$object->date_fin)) + if (empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS) && $object->periode_existe($fuser,$object->date_debut,$object->date_fin)) { $error++; setEventMessages($langs->trans("ErrorDoubleDeclaration"), null, 'errors'); From d975dd507bc64b760d53840224a532b98a77a089 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 11:17:47 +0200 Subject: [PATCH 06/14] Revert "No display object line curreny if not necessary" --- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/tpl/objectline_create.tpl.php | 6 +++--- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- htdocs/core/tpl/objectline_view.tpl.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9c1cd3cb6bd..4d44a4b6fec 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3370,7 +3370,7 @@ abstract class CommonObject print ''.$langs->trans('PriceUHT').''; // Multicurrency - if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; @@ -3409,7 +3409,7 @@ abstract class CommonObject print ''.$langs->trans('TotalHTShort').''; // Multicurrency - if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 1deef2e2412..f14af2b838f 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -65,7 +65,7 @@ if ($nolinesbefore) { trans('VAT'); ?> trans('PriceUHT'); ?> - multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++;?> + multicurrency->enabled)) { $colspan++;?> trans('PriceUHTCurrency'); ?> @@ -266,7 +266,7 @@ else { "> - multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++;?> + multicurrency->enabled)) { $colspan++;?> "> @@ -402,7 +402,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da } } - if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) $colspan+=2; + if (!empty($conf->multicurrency->enabled)) $colspan+=2; if (! empty($usemargins)) { diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 80d8c617c44..d982516bd67 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -122,7 +122,7 @@ $coldisplay=-1; // We remove first td if ($this->situation_counter > 1) print ' readonly'; print '>'; - if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { + if (!empty($conf->multicurrency->enabled)) { $colspan++; print ''; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 984af537ea9..0a20c2679a1 100755 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -138,7 +138,7 @@ if (empty($usemargins)) $usemargins=0; subprice); ?> - multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { ?> + multicurrency->enabled)) { ?> multicurrency_subprice); ?> @@ -204,7 +204,7 @@ if (empty($usemargins)) $usemargins=0; trans('Option'); ?> total_ht); ?> - multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { ?> + multicurrency->enabled)) { ?> multicurrency_total_ht); ?> From 8be8249f859d4bf16188fe9e5be7feee71b69c6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 12:40:42 +0200 Subject: [PATCH 07/14] Clean code, fix warnings --- htdocs/core/modules/DolibarrModules.class.php | 14 ++++--------- htdocs/core/modules/modDav.class.php | 14 +------------ .../core/modules/modMultiCurrency.class.php | 15 ------------- htdocs/core/modules/modResource.class.php | 21 +------------------ htdocs/core/modules/modTicketsup.class.php | 14 ------------- 5 files changed, 6 insertions(+), 72 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 7fb9f76119b..70e22bace45 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -158,14 +158,7 @@ class DolibarrModules // Can not be abstract, because we need to insta * // Set this to relative path of js file if module must load a js on all pages * 'js' => '/mymodule/js/mymodule.js', * // Set here all hooks context managed by module - * 'hooks' => array('hookcontext1','hookcontext2'), - * // Set here all workflow context managed by module - * 'workflow' => array( - * 'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' = >array( - * 'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', - * 'picto'=>'yourpicto@mymodule' - * ) - * ) + * 'hooks' => array('hookcontext1','hookcontext2') * ) */ public $module_parts = array(); @@ -2083,7 +2076,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (is_array($value)) { // Can defined other parameters - if (is_array($value['data']) && ! empty($value['data'])) + // Example when $key='hooks', then $value is an array('data'=>array('hookcontext1','hookcontext2'), 'entity'=>X) + if (isset($value['data']) && is_array($value['data'])) { $newvalue = json_encode($value['data']); if (isset($value['entity'])) $entity = $value['entity']; @@ -2093,7 +2087,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $newvalue = $value['data']; if (isset($value['entity'])) $entity = $value['entity']; } - else + else // when hook is declared with syntax 'hook'=>array('hookcontext1','hookcontext2',...) { $newvalue = json_encode($value); } diff --git a/htdocs/core/modules/modDav.class.php b/htdocs/core/modules/modDav.class.php index ae71f02753b..77c3f8feef7 100644 --- a/htdocs/core/modules/modDav.class.php +++ b/htdocs/core/modules/modDav.class.php @@ -80,19 +80,7 @@ class modDav extends DolibarrModules // for default path (eg: /dav/core/xxxxx) (0=disable, 1=enable) // for specific path of parts (eg: /dav/core/modules/barcode) // for specific css file (eg: /dav/css/dav.css.php) - $this->module_parts = array( - 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) - 'login' => 0, // Set this to 1 if module has its own login method file (core/login) - 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) - 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) - 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) - 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) - 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - 'css' => array(), // Set this to relative path of css file if module has its own css file - 'js' => array(), // Set this to relative path of js file if module must load a js on all pages - 'hooks' => array() // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' - ); + $this->module_parts = array(); // Data directories to create when module is enabled. // Example: this->dirs = array("/dav/temp","/dav/subdir"); diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 7908f203c69..7c87ef35a53 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -74,21 +74,6 @@ class modMultiCurrency extends DolibarrModules // for default path (eg: /multicurrency/core/xxxxx) (0=disable, 1=enable) // for specific path of parts (eg: /multicurrency/core/modules/barcode) // for specific css file (eg: /multicurrency/css/multicurrency.css.php) - //$this->module_parts = array( - // 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) - // 'login' => 0, // Set this to 1 if module has its own login method directory (core/login) - // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) - // 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) - // 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - // 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) - // 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) - // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - // 'css' => array('/multicurrency/css/multicurrency.css.php'), // Set this to relative path of css file if module has its own css file - // 'js' => array('/multicurrency/js/multicurrency.js'), // Set this to relative path of js file if module must load a js on all pages - // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module - // 'dir' => array('output' => 'othermodulename'), // To force the default directories names - // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@multicurrency')) // Set here all workflow context managed by module - // ); $this->module_parts = array(); // Data directories to create when module is enabled. diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 0cf19ec31e2..15b414947ef 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -79,26 +79,7 @@ class modResource extends DolibarrModules // for default path (eg: /resource/core/xxxxx) (0=disable, 1=enable) // for specific path of parts (eg: /resource/core/modules/barcode) // for specific css file (eg: /resource/css/resource.css.php) - $this->module_parts = array( - // Set this to 1 if module has its own trigger directory - //'triggers' => 1, - // Set this to 1 if module has its own login method directory - //'login' => 0, - // Set this to 1 if module has its own substitution function file - //'substitutions' => 0, - // Set this to 1 if module has its own menus handler directory - //'menus' => 0, - // Set this to 1 if module has its own barcode directory - //'barcode' => 0, - // Set this to 1 if module has its own models directory - //'models' => 0, - // Set this to relative path of css if module has its own css file - //'css' => '/resource/css/resource.css.php', - // Set here all hooks context managed by module - // 'hooks' => array('actioncard','actioncommdao','resource_card','element_resource') - // Set here all workflow context managed by module - //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) - ); + $this->module_parts = array(); // Data directories to create when module is enabled. // Example: this->dirs = array("/resource/temp"); diff --git a/htdocs/core/modules/modTicketsup.class.php b/htdocs/core/modules/modTicketsup.class.php index 3dcd3a3423f..594835dad4a 100644 --- a/htdocs/core/modules/modTicketsup.class.php +++ b/htdocs/core/modules/modTicketsup.class.php @@ -82,22 +82,8 @@ class modTicketsup extends DolibarrModules $this->module_parts = array( // Set this to 1 if module has its own trigger directory 'triggers' => 1, - // Set this to 1 if module has its own login method directory - //'login' => 0, - // Set this to 1 if module has its own substitution function file - //'substitutions' => 0, - // Set this to 1 if module has its own menus handler directory - //'menus' => 0, - // Set this to 1 if module has its own barcode directory - //'barcode' => 0, // Set this to 1 if module has its own models directory 'models' => 1, - // Set this to relative path of css if module has its own css file - //'css' => '', - // Set here all hooks context managed by module - 'hooks' => array('admin') - // Set here all workflow context managed by module - //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) ); // Data directories to create when module is enabled. From c3b5664fb51f3573cb8bbb0bd0ab2f47242609e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 16:24:40 +0200 Subject: [PATCH 08/14] Fix sort order of email templates --- htdocs/admin/mails_templates.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index d282acd3447..4e731021199 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -169,10 +169,6 @@ if ($conf->adherent->enabled) $elementList['member']=$langs->trans('Mai if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); if ($conf->projet->enabled) $elementList['project']=$langs->trans('MailToProject'); $elementList['user']=$langs->trans('MailToUser'); -sort($elementList); -// Add all and none after the sort -$elementList['all'] ='-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')'; -$elementList['none']='-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')'; $parameters=array('elementList'=>$elementList); $reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks @@ -182,6 +178,12 @@ if ($reshook == 0) { } } +// Add all and none after the sort +$elementList['all'] ='-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')'; +$elementList['none']='-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')'; + +asort($elementList); + $id = 25; @@ -211,7 +213,7 @@ if (empty($reshook)) } // Actions add or modify an entry into a dictionary - if (GETPOST('actionadd') || GETPOST('actionmodify')) + if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) { $listfield=explode(',', str_replace(' ', '',$tabfield[$id])); $listfieldinsert=explode(',',$tabfieldinsert[$id]); @@ -227,7 +229,7 @@ if (empty($reshook)) if ($value == 'content') continue; if ($value == 'content_lines') continue; - if (GETPOST('actionmodify') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; + if (GETPOST('actionmodify','alpha') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') { @@ -269,8 +271,8 @@ if (empty($reshook)) if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]=''; if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0'; if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1'; - if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work - elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="null"; + if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } @@ -316,12 +318,16 @@ if (empty($reshook)) if ($field == 'entity') $_POST[$keycode] = $conf->entity; if ($i) $sql.=","; $sql.= $field."="; - if ($_POST[$keycode] == '' || ($keycode == 'langcode' && empty($_POST[$keycode]))) $sql.="null"; // For vat, we want/accept code = '' + +// print $keycode.' - '.$_POST[$keycode].'
'; + if ($_POST[$keycode] == '' || ($keycode != 'langcode' && $keycode != 'private' && empty($_POST[$keycode]))) $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($keycode == 'private') $sql.=((int) $_POST[$keycode]); // private must be 0 or 1 else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; - +//print $sql;exit; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); From 14fd740b04a08e115a1972604d0cb3f8ac3fe7e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 16:25:06 +0200 Subject: [PATCH 09/14] Fix lang must be '' and not empty in email_template --- htdocs/accountancy/admin/accountmodel.php | 23 +++---------------- .../install/mysql/migration/7.0.0-8.0.0.sql | 1 + 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index db9725ce9f6..f8a31b239bb 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -617,25 +617,13 @@ if ($id) $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; - if ($id == 3) unset($fieldlist[2]); - if (empty($reshook)) { - if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit') - { - fieldListAccountModel($fieldlist,$obj,$tabname[$id],'hide'); - } - else - { - fieldListAccountModel($fieldlist,$obj,$tabname[$id],'add'); - } + fieldListAccountModel($fieldlist,$obj,$tabname[$id],'add'); } print ''; - if ($tabname[$id] != MAIN_DB_PREFIX.'c_email_templates' || $action != 'edit') - { - print ''; - } + print ''; print ''; print ""; @@ -1134,16 +1122,11 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='') } elseif (in_array($fieldlist[$field], array('content'))) { - if ($tabname == MAIN_DB_PREFIX.'c_email_templates') - { - print ''; // To create an artificial CR for the current tr we are on - } - else print ''; + print ''; if ($context != 'hide') { //print ''; $okforextended=true; - if ($tabname == MAIN_DB_PREFIX.'c_email_templates' && empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended=false; $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_5, '90%'); print $doleditor->Create(1); } diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 70cbaeb7e04..287c3bb6aaa 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -441,3 +441,4 @@ ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128); UPDATE llx_rights_def set module = 'asset' where module = 'assets'; +update llx_c_email_templates set lang = '' where lang IS NULL; From cb76d2ce0f8d3c4dcd43ecd0b7b217080312db3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 18:58:19 +0200 Subject: [PATCH 10/14] Better logging --- htdocs/core/class/menubase.class.php | 3 ++ htdocs/core/modules/DolibarrModules.class.php | 28 +++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index a96f62e8cbc..c123356f9ab 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -124,6 +124,9 @@ class Menubase else dol_print_error($this->db); } + // TODO + // Check that entry does not exists yet on key menu_handler-fk_menu-position-url-entity, to avoid errors with postgresql + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."menu("; $sql.= "menu_handler,"; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 70e22bace45..a5211b11b5e 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -953,7 +953,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; $sql.= " AND entity IN (0, ".$entity.")"; - dol_syslog(get_class($this)."::_active", LOG_DEBUG); + dol_syslog(get_class($this)."::_active delect activation constant", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $err++; @@ -965,7 +965,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ", 0, ".$entity; $sql.= ", '".$this->db->escape($note)."')"; - dol_syslog(get_class($this)."::_active", LOG_DEBUG); + dol_syslog(get_class($this)."::_active insert activation constant", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $err++; @@ -1133,6 +1133,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (is_array($this->boxes)) { + dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG); + $pos_name = InfoBox::getListOfPagesForBoxes(); foreach ($this->boxes as $key => $value) @@ -1150,7 +1152,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= " AND entity = ".$conf->entity; if ($note) $sql.=" AND note ='".$this->db->escape($note)."'"; - dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG); $result=$this->db->query($sql); if ($result) { @@ -1304,6 +1305,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (is_array($this->cronjobs)) { + dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG); + foreach ($this->cronjobs as $key => $value) { $entity = isset($this->cronjobs[$key]['entity'])?$this->cronjobs[$key]['entity']:$conf->entity; @@ -1332,7 +1335,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $now=dol_now(); - dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG); $result=$this->db->query($sql); if ($result) { @@ -1369,7 +1371,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= "'".$this->db->escape($test)."'"; $sql.= ")"; - dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $err++; @@ -1466,6 +1467,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (! empty($this->tabs)) { + dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG); + $i=0; foreach ($this->tabs as $key => $value) { @@ -1499,7 +1502,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ", ".$entity; $sql.= ")"; - dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { @@ -1532,6 +1534,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (empty($this->const)) return 0; + dol_syslog(get_class($this)."::insert_const", LOG_DEBUG); + foreach ($this->const as $key => $value) { $name = $this->const[$key][0]; @@ -1567,8 +1571,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ",".$entity; $sql.= ")"; - - dol_syslog(get_class($this)."::insert_const", LOG_DEBUG); if (! $this->db->query($sql) ) { $err++; @@ -1638,13 +1640,14 @@ class DolibarrModules // Can not be abstract, because we need to insta $err=0; $entity=(! empty($force_entity) ? $force_entity : $conf->entity); + dol_syslog(get_class($this)."::insert_permissions", LOG_DEBUG); + // Test if module is activated $sql_del = "SELECT ".$this->db->decrypt('value')." as value"; $sql_del.= " FROM ".MAIN_DB_PREFIX."const"; $sql_del.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; $sql_del.= " AND entity IN (0,".$entity.")"; - dol_syslog(get_class($this)."::insert_permissions", LOG_DEBUG); $resql=$this->db->query($sql_del); if ($resql) @@ -1802,6 +1805,8 @@ class DolibarrModules // Can not be abstract, because we need to insta require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php'; + dol_syslog(get_class($this)."::insert_menus", LOG_DEBUG); + $err=0; $this->db->begin(); @@ -2110,7 +2115,8 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ", ".$entity; $sql.= ")"; - dol_syslog(get_class($this)."::insert_const_".$key."", LOG_DEBUG); + dol_syslog(get_class($this)."::insert_module_parts for key=".$this->const_name."_".strtoupper($key), LOG_DEBUG); + $resql=$this->db->query($sql,1); if (! $resql) { @@ -2121,7 +2127,7 @@ class DolibarrModules // Can not be abstract, because we need to insta } else { - dol_syslog(get_class($this)."::insert_const_".$key." Record already exists.", LOG_WARNING); + dol_syslog(get_class($this)."::insert_module_parts for ".$this->const_name."_".strtoupper($key)." Record already exists.", LOG_WARNING); } } } From 5e14b165c93c1429e0bf30c988f901ad018382d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 19:51:53 +0200 Subject: [PATCH 11/14] NEW Show last result code of cron jobs in error in red --- htdocs/cron/list.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 81e9d57c03b..61b31d37131 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -508,7 +508,10 @@ if ($num > 0) print ''; print ''; - if ($obj->lastresult != '') {print dol_trunc($obj->lastresult);} + if ($obj->lastresult != '') { + if (empty($obj->lastresult)) print $obj->lastresult; + else print ''.dol_trunc($obj->lastresult).''; + } print ''; print ''; From dc9892f803a08e96156c6bea1ee86f183859aca9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 20:17:03 +0200 Subject: [PATCH 12/14] Fix bad log --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2094cd10c5c..2e345a48276 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6181,7 +6181,7 @@ function complete_substitutions_array(&$substitutionarray, $outputlangs, $object { $module=$reg[1]; - dol_syslog("Library functions_".$substitfile['name']." found into ".$dir); + dol_syslog("Library ".$substitfile['name']." found into ".$dir); // Include the user's functions file require_once $dir.$substitfile['name']; // Call the user's function, and only if it is defined From 124abd39b6355b8aea21bae426172ede290e31e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 20:31:57 +0200 Subject: [PATCH 13/14] Code comment --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 28c6f86769f..c275dd6cda3 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -105,7 +105,7 @@ function dol_decode($chain, $key='1') * If constant MAIN_SECURITY_SALT is defined, we use it as a salt (used only if hashing algorightm is something else than 'password_hash'). * * @param string $chain String to hash - * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO then md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. + * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return string Hash of string * @getRandomPassword */ From 2f2d17926ddf917d860cac85f5ac5dc2e7b6393d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 20:52:25 +0200 Subject: [PATCH 14/14] Sort list --- htdocs/admin/security.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 9627164f534..38cd2d12c1b 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -127,7 +127,7 @@ if ($action == 'activate_encryptdbpassconf') if ($result > 0) { sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. - + // database value not required //dolibarr_set_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED", "1"); header("Location: security.php"); @@ -135,7 +135,7 @@ if ($action == 'activate_encryptdbpassconf') } else { - setEventMessages($langs->trans('InstrucToEncodePass',dol_encode($dolibarr_main_db_pass)), null, 'warnings'); + setEventMessages($langs->trans('InstrucToEncodePass',dol_encode($dolibarr_main_db_pass)), null, 'warnings'); } } else if ($action == 'disable_encryptdbpassconf') @@ -144,7 +144,7 @@ else if ($action == 'disable_encryptdbpassconf') if ($result > 0) { sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. - + // database value not required //dolibarr_del_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED",$conf->entity); header("Location: security.php"); @@ -233,6 +233,7 @@ if (is_resource($handle)) } closedir($handle); } +asort($arrayhandler); print ''; print ''; @@ -299,42 +300,42 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print '
'.$langs->trans("PasswordPatternDesc").'
' . $langs->trans("MinLength")."
' . $langs->trans("NbMajMin")."
' . $langs->trans("NbNumMin")."
' . $langs->trans("NbSpeMin")."
' . $langs->trans("NbIteConsecutive")."
' . $langs->trans("NoAmbiCaracAutoGeneration")." '.($tabConf[5] ? $langs->trans("Activated") : $langs->trans("Disabled")).'
'; print '
';