2
0
forked from Wavyzz/dolibarr

Better detection if a module provide triggers

This commit is contained in:
Laurent Destailleur
2017-08-03 12:19:31 +02:00
parent 00a1893d93
commit f058fa1938
5 changed files with 24 additions and 22 deletions

View File

@@ -269,7 +269,7 @@ if ($objMod->isCoreOrExternalModule() == 'external')
$modulename=$objMod->getName(); $modulename=$objMod->getName();
$moduledesc=$objMod->getDesc(); $moduledesc=$objMod->getDesc();
$moduleauthor=$objMod->getPublisher(); $moduleauthor=$objMod->getPublisher();
$moduledir=strtolower(preg_replace('/^mod/i','',get_class($objMod)));
print '<div class="centpercent">'; print '<div class="centpercent">';
@@ -458,7 +458,17 @@ if ($mode == 'feature')
{ {
$yesno='No'; $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; $text.=$langs->trans($yesno).$moreinfoontriggerfile;

View File

@@ -325,8 +325,9 @@ class Interfaces
{ {
$module=preg_replace('/^mod/i','',$reg[2]); $module=preg_replace('/^mod/i','',$reg[2]);
$constparam='MAIN_MODULE_'.strtoupper($module); $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; else if (empty($conf->global->$constparam)) $disabledbymodule=2;
$triggers[$j]['module']=strtolower($module);
} }
// We set info of modules // We set info of modules

View File

@@ -56,9 +56,6 @@ class modAccounting extends DolibarrModules
$this->special = 0; $this->special = 0;
$this->picto = 'accounting'; $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 // Data directories to create when module is enabled
$this->dirs = array('/accounting/temp'); $this->dirs = array('/accounting/temp');

View File

@@ -54,9 +54,6 @@ class modExpenseReport extends DolibarrModules
$this->special = 0; $this->special = 0;
$this->picto='trip'; $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. // Data directories to create when module is enabled.
$this->dirs = array("/expensereport/temp"); $this->dirs = array("/expensereport/temp");
$r=0; $r=0;
@@ -114,56 +111,56 @@ class modExpenseReport extends DolibarrModules
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'lire'; $this->rights[$r][4] = 'lire';
$r++; $r++;
$this->rights[$r][0] = 772; $this->rights[$r][0] = 772;
$this->rights[$r][1] = 'Create/modify expense reports'; $this->rights[$r][1] = 'Create/modify expense reports';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'creer'; $this->rights[$r][4] = 'creer';
$r++; $r++;
$this->rights[$r][0] = 773; $this->rights[$r][0] = 773;
$this->rights[$r][1] = 'Delete expense reports'; $this->rights[$r][1] = 'Delete expense reports';
$this->rights[$r][2] = 'd'; $this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'supprimer'; $this->rights[$r][4] = 'supprimer';
$r++; $r++;
$this->rights[$r][0] = 775; $this->rights[$r][0] = 775;
$this->rights[$r][1] = 'Approve expense reports'; $this->rights[$r][1] = 'Approve expense reports';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'approve'; $this->rights[$r][4] = 'approve';
$r++; $r++;
$this->rights[$r][0] = 776; $this->rights[$r][0] = 776;
$this->rights[$r][1] = 'Pay expense reports'; $this->rights[$r][1] = 'Pay expense reports';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'to_paid'; $this->rights[$r][4] = 'to_paid';
$r++; $r++;
$this->rights[$r][0] = 777; $this->rights[$r][0] = 777;
$this->rights[$r][1] = 'Read expense reports of everybody'; $this->rights[$r][1] = 'Read expense reports of everybody';
$this->rights[$r][2] = 'r'; $this->rights[$r][2] = 'r';
$this->rights[$r][3] = 1; $this->rights[$r][3] = 1;
$this->rights[$r][4] = 'readall'; $this->rights[$r][4] = 'readall';
$r++; $r++;
$this->rights[$r][0] = 778; $this->rights[$r][0] = 778;
$this->rights[$r][1] = 'Create expense reports for everybody'; $this->rights[$r][1] = 'Create expense reports for everybody';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'writeall_advance'; $this->rights[$r][4] = 'writeall_advance';
$r++; $r++;
$this->rights[$r][0] = 779; $this->rights[$r][0] = 779;
$this->rights[$r][1] = 'Export expense reports'; $this->rights[$r][1] = 'Export expense reports';
$this->rights[$r][2] = 'r'; $this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'export'; $this->rights[$r][4] = 'export';
$r++; $r++;
// Menus // Menus
//------- //-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager. $this->menu = 1; // This module add menu entries. They are coded into menu manager.

View File

@@ -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' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
$this->picto='holiday'; $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. // Data directories to create when module is enabled.
// Example: this->dirs = array("/mymodule/temp"); // Example: this->dirs = array("/mymodule/temp");
$this->dirs = array(); $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) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$r++; $r++;
// Menus // Menus
//------- //-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager. $this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Exports // Exports
$r=1; $r=1;