Better error management

This commit is contained in:
Laurent Destailleur 2011-11-02 14:15:14 +01:00
parent e764f2137d
commit dcd97bb1cf

View File

@ -106,6 +106,7 @@ foreach ($conf->file->dol_document_root as $type => $dirroot)
} }
} }
} }
//var_dump($modulesdir);
foreach ($modulesdir as $dir) foreach ($modulesdir as $dir)
{ {
@ -124,38 +125,45 @@ foreach ($modulesdir as $dir)
if ($modName) if ($modName)
{ {
include_once($dir.$file); try
$objMod = new $modName($db);
if ($objMod->numero > 0)
{ {
$j = $objMod->numero; $res=include_once($dir.$file);
$objMod = new $modName($db);
if ($objMod->numero > 0)
{
$j = $objMod->numero;
}
else
{
$j = 1000 + $i;
}
$modulequalified=1;
// We discard modules according to features level (PS: if module is activated we always show it)
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && ! $conf->global->$const_name) $modulequalified=0;
if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && ! $conf->global->$const_name) $modulequalified=0;
if ($modulequalified)
{
$modules[$i] = $objMod;
$filename[$i]= $modName;
$orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module
//print "x".$modName." ".$orders[$i]."\n<br>";
if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories
else $categ[$objMod->special]=1;
$dirmod[$i] = $dirroot;
$j++;
$i++;
}
else dol_syslog("Module ".get_class($objMod)." not qualified");
} }
else catch(Exception $e)
{ {
$j = 1000 + $i; dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
} }
$modulequalified=1;
// We discard modules according to features level (PS: if module is activated we always show it)
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && ! $conf->global->$const_name) $modulequalified=0;
if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && ! $conf->global->$const_name) $modulequalified=0;
if ($modulequalified)
{
$modules[$i] = $objMod;
$filename[$i]= $modName;
$orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module
//print "x".$modName." ".$orders[$i]."\n<br>";
if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories
else $categ[$objMod->special]=1;
$dirmod[$i] = $dirroot;
$j++;
$i++;
}
else dol_syslog("Module ".get_class($objMod)." not qualified");
} }
} }
} }