diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 156067a0b23..c2855b42514 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -58,9 +58,9 @@ class Menubase /** * Constructor * - * @param DoliDB $DB Database handler - * @param string $menu_handler Menu handler - * @param string $type Type + * @param DoliDB $DB Database handler + * @param string $menu_handler + * @param string $type */ function Menubase($DB,$menu_handler='',$type='') { @@ -167,11 +167,10 @@ class Menubase } /** - * Update menu entry into database. - * - * @param User $user User that modify - * @param int $notrigger 0=no, 1=yes (no update trigger) - * @return int <0 if KO, >0 if OK + * Update menu entry into database + * @param user User that modify + * @param notrigger 0=no, 1=yes (no update trigger) + * @return int <0 if KO, >0 if OK */ function update($user=0, $notrigger=0) { @@ -303,11 +302,10 @@ class Menubase } - /** - * Delete object in database - * - * @param User $user User that delete - * @return int <0 if KO, >0 if OK + /* + * \brief Delete object in database + * \param user User that delete + * \return int <0 if KO, >0 if OK */ function delete($user) { @@ -360,13 +358,12 @@ class Menubase /** - * Complete this->newmenu with menu entry found in $tab + * Complete this->newmenu with menu entry found in $tab * - * @param array $tab Tab array - * @param int $pere Id of parent - * @param int $rang Rang - * @param string $myleftmenu Value for left that defined leftmenu - * @return void + * @param $tab + * @param $pere + * @param $rang + * @param $myleftmenu Value for left that defined leftmenu */ function recur($tab, $pere, $rang, $myleftmenu) { @@ -403,14 +400,12 @@ class Menubase } /** - * Load tabMenu array - * - * @param string $mainmenu Value for mainmenu that defined top menu - * @param string $myleftmenu Left menu name - * @param int $type_user 0=Internal,1=External,2=All - * @param string $menu_handler Name of menu_handler used (auguria, eldy...) - * @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) - * @return array Return array with menu entries for top menu + * Load tabMenu array + * @param type_user 0=Internal,1=External,2=All + * @param mainmenu Value for mainmenu that defined top menu + * @param menu_handler Name of menu_handler used (auguria, eldy...) + * @param tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) + * @return array Return array with menu entries for top menu */ function menuTopCharger($mainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu=null) { @@ -454,15 +449,14 @@ class Menubase } /** - * Load entries found in database in a menu array. - * - * @param array $newmenu Menu array to complete - * @param string $mainmenu Value for mainmenu that defined top menu of left menu - * @param string $myleftmenu Value that defined leftmenu - * @param int $type_user 0=Internal,1=External,2=All - * @param string $menu_handler Name of menu_handler used (auguria, eldy...) - * @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) - * @return array Menu array for particular mainmenu value or full tabArray + * Load entries found in database in a menu array + * @param $newmenu Menu array to complete + * @param $mainmenu Value for mainmenu that defined top menu of left menu + * @param $myleftmenu Value that defined leftmenu + * @param $type_user 0=Internal,1=External,2=All + * @param $menu_handler Name of menu_handler used (auguria, eldy...) + * @param $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) + * @return array Menu array for particular mainmenu value or full tabArray */ function menuLeftCharger($newmenu, $mainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu=null) { @@ -502,13 +496,12 @@ class Menubase /** - * Load entries found in database in a menu array. - * - * @param string $myleftmenu Value for left that defined leftmenu - * @param int $type_user 0=Internal,1=External,2=All - * @param string $menu_handler Name of menu_handler used (auguria, eldy...) - * @param array &$tabMenu If array with menu entries already load, we put this array here (in most cases, it's empty) - * @return int >0 if OK, <0 if KO + * Load entries found in database in a menu array + * @param $myleftmenu Value for left that defined leftmenu + * @param $type_user 0=Internal,1=External,2=All + * @param $menu_handler Name of menu_handler used (auguria, eldy...) + * @param $tabMenu If array with menu entries already load, we put this array here (in most cases, it's empty) + * @return int >0 if OK, <0 if KO */ function menuLoad($myleftmenu, $type_user, $menu_handler, &$tabMenu=array()) { diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 1676ba73de1..c6a835fedb5 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -73,92 +73,99 @@ class Import $dir = $dirroot.'/includes/modules'; // Search available exports - $handle=@opendir(dol_osencode($dir)); - if (! is_resource($handle)) continue; - - // Search module files - while (($file = readdir($handle))!==false) + $handle=@opendir($dir); + if (is_resource($handle)) { - if (! preg_match("/^(mod.*)\.class\.php/i",$file,$reg)) continue; - - $modulename=$reg[1]; - - // Defined if module is enabled - $enabled=true; - $part=strtolower(preg_replace('/^mod/i','',$modulename)); - if (empty($conf->$part->enabled)) $enabled=false; - - if (empty($enabled)) continue; - - // Init load class - $file = $dir."/".$modulename.".class.php"; - $classname = $modulename; - require_once($file); - $module = new $classname($this->db); - - if (is_array($module->import_code)) + // Search module files + while (($file = readdir($handle))!==false) { - foreach($module->import_code as $r => $value) + if (preg_match("/^(mod.*)\.class\.php/i",$file,$reg)) { - if ($filter && ($filter != $module->import_code[$r])) continue; + $modulename=$reg[1]; - // Test if permissions are ok - /*$perm=$module->import_permission[$r][0]; - //print_r("$perm[0]-$perm[1]-$perm[2]
"); - if ($perm[2]) - { - $bool=$user->rights->$perm[0]->$perm[1]->$perm[2]; - } - else - { - $bool=$user->rights->$perm[0]->$perm[1]; - } - if ($perm[0]=='user' && $user->admin) $bool=true; - //print $bool." $perm[0]"."
"; - */ + // Defined if module is enabled + $enabled=true; + $part=strtolower(preg_replace('/^mod/i','',$modulename)); + if (empty($conf->$part->enabled)) $enabled=false; - // Load lang file - $langtoload=$module->getLangFilesArray(); - if (is_array($langtoload)) + if ($enabled) { - foreach($langtoload as $key) + // Chargement de la classe + $file = $dir."/".$modulename.".class.php"; + $classname = $modulename; + require_once($file); + $module = new $classname($this->db); + + if (is_array($module->import_code)) { - $langs->load($key); + foreach($module->import_code as $r => $value) + { + if ($filter && ($filter != $module->import_code[$r])) continue; + + // Test if permissions are ok + /*$perm=$module->import_permission[$r][0]; + //print_r("$perm[0]-$perm[1]-$perm[2]
"); + if ($perm[2]) + { + $bool=$user->rights->$perm[0]->$perm[1]->$perm[2]; + } + else + { + $bool=$user->rights->$perm[0]->$perm[1]; + } + if ($perm[0]=='user' && $user->admin) $bool=true; + //print $bool." $perm[0]"."
"; + */ + + // Permissions ok + // if ($bool) + // { + // Charge fichier lang en rapport + $langtoload=$module->getLangFilesArray(); + if (is_array($langtoload)) + { + foreach($langtoload as $key) + { + $langs->load($key); + } + } + + // Module + $this->array_import_module[$i]=$module; + // Permission + $this->array_import_perms[$i]=$user->rights->import->run; + // Icon + $this->array_import_icon[$i]=(isset($module->import_icon[$r])?$module->import_icon[$r]:$module->picto); + // Code du dataset export + $this->array_import_code[$i]=$module->import_code[$r]; + // Libelle du dataset export + $this->array_import_label[$i]=$module->getImportDatasetLabel($r); + // Array of tables to import (key=alias, value=tablename) + $this->array_import_tables[$i]=$module->import_tables_array[$r]; + // Array of tables creator field to import (key=alias, value=creator field) + $this->array_import_tables_creator[$i]=$module->import_tables_creator_array[$r]; + // Array of fiels to import (key=field, value=label) + $this->array_import_fields[$i]=$module->import_fields_array[$r]; + // Tableau des entites a exporter (cle=champ, valeur=entite) + $this->array_import_entities[$i]=$module->import_entities_array[$r]; + // Tableau des alias a exporter (cle=champ, valeur=alias) + $this->array_import_regex[$i]=$module->import_regex_array[$r]; + // Tableau des alias a exporter (cle=champ, valeur=exemple) + $this->array_import_examplevalues[$i]=$module->import_examplevalues_array[$r]; + // Tableau des regles de conversion d'une valeur depuis une autre source (cle=champ, valeur=tableau des regles) + $this->array_import_convertvalue[$i]=$module->import_convertvalue_array[$r]; + + dol_syslog("Import loaded for module ".$modulename." with index ".$i.", dataset=".$module->import_code[$r].", nb of fields=".count($module->import_fields_code[$r])); + $i++; + // } + } } } - - // Module - $this->array_import_module[$i]=$module; - // Permission - $this->array_import_perms[$i]=$user->rights->import->run; - // Icon - $this->array_import_icon[$i]=(isset($module->import_icon[$r])?$module->import_icon[$r]:$module->picto); - // Code du dataset export - $this->array_import_code[$i]=$module->import_code[$r]; - // Libelle du dataset export - $this->array_import_label[$i]=$module->getImportDatasetLabel($r); - // Array of tables to import (key=alias, value=tablename) - $this->array_import_tables[$i]=$module->import_tables_array[$r]; - // Array of tables creator field to import (key=alias, value=creator field) - $this->array_import_tables_creator[$i]=$module->import_tables_creator_array[$r]; - // Array of fiels to import (key=field, value=label) - $this->array_import_fields[$i]=$module->import_fields_array[$r]; - // Tableau des entites a exporter (cle=champ, valeur=entite) - $this->array_import_entities[$i]=$module->import_entities_array[$r]; - // Tableau des alias a exporter (cle=champ, valeur=alias) - $this->array_import_regex[$i]=$module->import_regex_array[$r]; - // Tableau des alias a exporter (cle=champ, valeur=exemple) - $this->array_import_examplevalues[$i]=$module->import_examplevalues_array[$r]; - // Tableau des regles de conversion d'une valeur depuis une autre source (cle=champ, valeur=tableau des regles) - $this->array_import_convertvalue[$i]=$module->import_convertvalue_array[$r]; - - dol_syslog("Import loaded for module ".$modulename." with index ".$i.", dataset=".$module->import_code[$r].", nb of fields=".count($module->import_fields_code[$r])); - $i++; } } } - closedir($handle); } + closedir($handle); return 1; }