diff --git a/htdocs/admin/triggers.php b/htdocs/admin/triggers.php index ba0cc449a50..eebbae9b87f 100644 --- a/htdocs/admin/triggers.php +++ b/htdocs/admin/triggers.php @@ -58,47 +58,15 @@ print "\n"; // Define dir directory $interfaces=new Interfaces($db); -$dir = $interfaces->dir; +$interfaces->getModulesTriggers(); $handle=opendir($dir); $files = array(); $modules = array(); $orders = array(); $i = 0; -while (($file = readdir($handle))!==false) -{ - if (is_readable($dir.'/'.$file) && preg_match('/^interface_([^_]+)_(.+)\.class\.php/',$file,$reg)) - { - $modName = 'Interface'.ucfirst($reg[2]); - //print "file=$file"; print "modName=$modName"; exit; - if (in_array($modName,$modules)) - { - $langs->load("errors"); - print '
'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateTrigger",$modName,"/htdocs/includes/triggers/").'
'; - $objMod = new $modName($db); - $modules[$i] = $modName; - $files[$i] = $file; - $orders[$i] = $objMod->family; // Tri par famille - $i++; - } - else - { - include_once($dir.'/'.$file); - $objMod = new $modName($db); - - $modules[$i] = $modName; - $files[$i] = $file; - $orders[$i] = $objMod->family; // Tri par famille - $i++; - } - } -} -closedir($handle); - -// Find external module triggers -$interfaces->getModulesTriggers(); -foreach($interfaces->pathoftriggers as $dir) +foreach($interfaces->dir as $dir) { $handle=opendir($dir); diff --git a/htdocs/interfaces.class.php b/htdocs/interfaces.class.php index 6b9b27c966b..41fa9163b5d 100644 --- a/htdocs/interfaces.class.php +++ b/htdocs/interfaces.class.php @@ -33,9 +33,8 @@ class Interfaces { - var $dir; // Directory with all core trigger files - var $errors = array(); // Array for errors - var $pathoftriggers = array(); // Array for path of triggers + var $dir; // Directory with all core and external triggers files + var $errors = array(); // Array for errors /** * \brief Constructeur. @@ -44,7 +43,6 @@ class Interfaces function Interfaces($DB) { $this->db = $DB ; - $this->dir = DOL_DOCUMENT_ROOT . "/includes/triggers"; } /** @@ -155,6 +153,9 @@ class Interfaces { global $conf; + // Directory of core triggers + $this->dir[] = DOL_DOCUMENT_ROOT . "/includes/triggers"; + foreach($conf->global as $key => $value) { if (preg_match('/^MAIN_TRIGGER_/',$key)) @@ -165,7 +166,7 @@ class Interfaces { $modulename = strtolower($regs[1]); $pathoftrigger = DOL_DOCUMENT_ROOT.'/'.$modulename.'/inc/triggers/'; - $this->pathoftriggers[] = $pathoftrigger; + $this->dir[] = $pathoftrigger; } } }