Qual: More POO.

Qual: Doxygen
This commit is contained in:
Laurent Destailleur 2011-09-20 17:34:15 +00:00
parent e11ca0f95a
commit 70521b63ee
2 changed files with 116 additions and 116 deletions

View File

@ -58,9 +58,9 @@ class Menubase
/** /**
* Constructor * Constructor
* *
* @param DoliDB $DB Database handler * @param DoliDB $DB Database handler
* @param string $menu_handler Menu handler * @param string $menu_handler
* @param string $type Type * @param string $type
*/ */
function Menubase($DB,$menu_handler='',$type='') function Menubase($DB,$menu_handler='',$type='')
{ {
@ -167,11 +167,10 @@ class Menubase
} }
/** /**
* Update menu entry into database. * Update menu entry into database
* * @param user User that modify
* @param User $user User that modify * @param notrigger 0=no, 1=yes (no update trigger)
* @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK
* @return int <0 if KO, >0 if OK
*/ */
function update($user=0, $notrigger=0) function update($user=0, $notrigger=0)
{ {
@ -303,11 +302,10 @@ class Menubase
} }
/** /*
* Delete object in database * \brief Delete object in database
* * \param user User that delete
* @param User $user User that delete * \return int <0 if KO, >0 if OK
* @return int <0 if KO, >0 if OK
*/ */
function delete($user) 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 $tab
* @param int $pere Id of parent * @param $pere
* @param int $rang Rang * @param $rang
* @param string $myleftmenu Value for left that defined leftmenu * @param $myleftmenu Value for left that defined leftmenu
* @return void
*/ */
function recur($tab, $pere, $rang, $myleftmenu) function recur($tab, $pere, $rang, $myleftmenu)
{ {
@ -403,14 +400,12 @@ class Menubase
} }
/** /**
* Load tabMenu array * Load tabMenu array
* * @param type_user 0=Internal,1=External,2=All
* @param string $mainmenu Value for mainmenu that defined top menu * @param mainmenu Value for mainmenu that defined top menu
* @param string $myleftmenu Left menu name * @param menu_handler Name of menu_handler used (auguria, eldy...)
* @param int $type_user 0=Internal,1=External,2=All * @param tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
* @param string $menu_handler Name of menu_handler used (auguria, eldy...) * @return array Return array with menu entries for top menu
* @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
*/ */
function menuTopCharger($mainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu=null) 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. * Load entries found in database in a menu array
* * @param $newmenu Menu array to complete
* @param array $newmenu Menu array to complete * @param $mainmenu Value for mainmenu that defined top menu of left menu
* @param string $mainmenu Value for mainmenu that defined top menu of left menu * @param $myleftmenu Value that defined leftmenu
* @param string $myleftmenu Value that defined leftmenu * @param $type_user 0=Internal,1=External,2=All
* @param int $type_user 0=Internal,1=External,2=All * @param $menu_handler Name of menu_handler used (auguria, eldy...)
* @param string $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)
* @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
* @return array Menu array for particular mainmenu value or full tabArray
*/ */
function menuLeftCharger($newmenu, $mainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu=null) 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. * Load entries found in database in a menu array
* * @param $myleftmenu Value for left that defined leftmenu
* @param string $myleftmenu Value for left that defined leftmenu * @param $type_user 0=Internal,1=External,2=All
* @param int $type_user 0=Internal,1=External,2=All * @param $menu_handler Name of menu_handler used (auguria, eldy...)
* @param string $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)
* @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
* @return int >0 if OK, <0 if KO
*/ */
function menuLoad($myleftmenu, $type_user, $menu_handler, &$tabMenu=array()) function menuLoad($myleftmenu, $type_user, $menu_handler, &$tabMenu=array())
{ {

View File

@ -73,92 +73,99 @@ class Import
$dir = $dirroot.'/includes/modules'; $dir = $dirroot.'/includes/modules';
// Search available exports // Search available exports
$handle=@opendir(dol_osencode($dir)); $handle=@opendir($dir);
if (! is_resource($handle)) continue; if (is_resource($handle))
// Search module files
while (($file = readdir($handle))!==false)
{ {
if (! preg_match("/^(mod.*)\.class\.php/i",$file,$reg)) continue; // Search module files
while (($file = readdir($handle))!==false)
$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))
{ {
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 // Defined if module is enabled
/*$perm=$module->import_permission[$r][0]; $enabled=true;
//print_r("$perm[0]-$perm[1]-$perm[2]<br>"); $part=strtolower(preg_replace('/^mod/i','',$modulename));
if ($perm[2]) if (empty($conf->$part->enabled)) $enabled=false;
{
$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]"."<br>";
*/
// Load lang file if ($enabled)
$langtoload=$module->getLangFilesArray();
if (is_array($langtoload))
{ {
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]<br>");
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]"."<br>";
*/
// 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; return 1;
} }