From 8be8249f859d4bf16188fe9e5be7feee71b69c6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 12:40:42 +0200 Subject: [PATCH] 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.