From f058fa19382a584b66fee60066d7d8b067528d8c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Aug 2017 12:19:31 +0200 Subject: [PATCH] Better detection if a module provide triggers --- htdocs/admin/modulehelp.php | 14 ++++++++++++-- htdocs/core/class/interfaces.class.php | 3 ++- htdocs/core/modules/modAccounting.class.php | 3 --- .../core/modules/modExpenseReport.class.php | 19 ++++++++----------- htdocs/core/modules/modHoliday.class.php | 7 ++----- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 27d5595d4d5..830b323545f 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -269,7 +269,7 @@ if ($objMod->isCoreOrExternalModule() == 'external') $modulename=$objMod->getName(); $moduledesc=$objMod->getDesc(); $moduleauthor=$objMod->getPublisher(); - +$moduledir=strtolower(preg_replace('/^mod/i','',get_class($objMod))); print '
'; @@ -458,7 +458,17 @@ if ($mode == 'feature') { $yesno='No'; } - // TODO Try autodetection by scanning all triggers files for a file interface_99_modModule_xxx.class.php to set $moreinfoontriggerfile + require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interfaces = new Interfaces($db); + $triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external')?'/'.$moduledir:'').'/core/triggers')); + foreach($triggers as $triggercursor) + { + if ($triggercursor['module'] == $moduledir) + { + $yesno='Yes'; + $moreinfoontriggerfile=' ('.$triggercursor['relpath'].')'; + } + } $text.=$langs->trans($yesno).$moreinfoontriggerfile; diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index ef64ac8d8e5..d81d8f22ac5 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -325,8 +325,9 @@ class Interfaces { $module=preg_replace('/^mod/i','',$reg[2]); $constparam='MAIN_MODULE_'.strtoupper($module); - if (strtolower($reg[2]) == 'all') $disabledbymodule=0; + if (strtolower($module) == 'all') $disabledbymodule=0; else if (empty($conf->global->$constparam)) $disabledbymodule=2; + $triggers[$j]['module']=strtolower($module); } // We set info of modules diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index cfdd15fcc00..496d054d86c 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -56,9 +56,6 @@ class modAccounting extends DolibarrModules $this->special = 0; $this->picto = 'accounting'; - // Defined if the directory /mymodule/inc/triggers/ contains triggers or not - // $this->triggers = 1; - // Data directories to create when module is enabled $this->dirs = array('/accounting/temp'); diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index cbaf141809f..571c2b2e28a 100644 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -54,9 +54,6 @@ class modExpenseReport extends DolibarrModules $this->special = 0; $this->picto='trip'; - // Defined if the directory /mymodule/inc/triggers/ contains triggers or not - $this->triggers = 0; - // Data directories to create when module is enabled. $this->dirs = array("/expensereport/temp"); $r=0; @@ -114,56 +111,56 @@ class modExpenseReport extends DolibarrModules $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; - + $this->rights[$r][0] = 772; $this->rights[$r][1] = 'Create/modify expense reports'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'creer'; $r++; - + $this->rights[$r][0] = 773; $this->rights[$r][1] = 'Delete expense reports'; $this->rights[$r][2] = 'd'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'supprimer'; $r++; - + $this->rights[$r][0] = 775; $this->rights[$r][1] = 'Approve expense reports'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'approve'; $r++; - + $this->rights[$r][0] = 776; $this->rights[$r][1] = 'Pay expense reports'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'to_paid'; $r++; - + $this->rights[$r][0] = 777; $this->rights[$r][1] = 'Read expense reports of everybody'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 1; $this->rights[$r][4] = 'readall'; $r++; - + $this->rights[$r][0] = 778; $this->rights[$r][1] = 'Create expense reports for everybody'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'writeall_advance'; $r++; - + $this->rights[$r][0] = 779; $this->rights[$r][1] = 'Export expense reports'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'export'; $r++; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 9ce003c1a5b..d57800872fd 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -69,9 +69,6 @@ class modHoliday extends DolibarrModules // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' $this->picto='holiday'; - // Defined if the directory /mymodule/inc/triggers/ contains triggers or not - $this->triggers = 0; - // Data directories to create when module is enabled. // Example: this->dirs = array("/mymodule/temp"); $this->dirs = array(); @@ -173,11 +170,11 @@ class modHoliday extends DolibarrModules $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + // Exports $r=1;