*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
";
dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)");
$handle=@opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
//print "$i ".$file."\n
";
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
{
$modName = substr($file, 0, dol_strlen($file) - 10);
if ($modName)
{
if (! empty($modNameLoaded[$modName]))
{
$mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
";
setEventMessages($mesg, null, 'warnings');
dol_syslog($mesg, LOG_ERR);
continue;
}
try
{
$res=include_once $dir.$file;
if (class_exists($modName))
{
try {
$objMod = new $modName($db);
$modNameLoaded[$modName]=$dir;
if (! $objMod->numero > 0 && $modName != 'modUser')
{
dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR);
}
$j = $objMod->numero;
$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' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=0;
if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0;
if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=0;
// We discard modules according to property disabled
if (! empty($objMod->hidden)) $modulequalified=0;
if ($modulequalified > 0)
{
$publisher=dol_escape_htmltag($objMod->getPublisher());
$external=($objMod->isCoreOrExternalModule() == 'external');
if ($external)
{
if ($publisher)
{
$arrayofnatures['external_'.$publisher]=$langs->trans("External").' - '.$publisher;
}
else
{
$arrayofnatures['external_']=$langs->trans("External").' - '.$langs->trans("UnknownPublishers");
}
}
ksort($arrayofnatures);
}
// Define array $categ with categ with at least one qualified module
if ($modulequalified > 0)
{
$modules[$i] = $objMod;
$filename[$i]= $modName;
$special = $objMod->special;
// Gives the possibility to the module, to provide his own family info and position of this family
if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) {
$familyinfo = array_merge($familyinfo, $objMod->familyinfo);
$familykey = key($objMod->familyinfo);
} else {
$familykey = $objMod->family;
}
$moduleposition = ($objMod->module_position?$objMod->module_position:'500');
if ($moduleposition == 500 && ($objMod->isCoreOrExternalModule() == 'external'))
{
$moduleposition = 800;
}
if ($special == 1) $familykey='interface';
$orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number
$dirmod[$i] = $dir;
//print $i.'-'.$dirmod[$i].'
';
// Set categ[$i]
$specialstring = isset($specialtostring[$special])?$specialtostring[$special]:'unknown';
if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev';
if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories
else $categ[$specialstring]=1;
$j++;
$i++;
}
else dol_syslog("Module ".get_class($objMod)." not qualified");
}
catch(Exception $e)
{
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
}
}
else
{
print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
";
}
}
catch(Exception $e)
{
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
}
}
}
}
closedir($handle);
}
else
{
dol_syslog("htdocs/admin/modulehelp.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING);
}
}
asort($orders);
//var_dump($orders);
//var_dump($categ);
//var_dump($modules);
$h = 0;
$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=desc';
$head[$h][1] = $langs->trans("Description");
$head[$h][2] = 'desc';
$h++;
$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=feature';
$head[$h][1] = $langs->trans("TechnicalServicesProvided");
$head[$h][2] = 'feature';
$h++;
$i=0;
foreach($orders as $tmpkey => $tmpvalue)
{
$objMod = $modules[$tmpkey];
if ($objMod->numero == $id)
{
$key = $i;
$modName = $filename[$tmpkey];
$dirofmodule = $dirmod[$tmpkey];
break;
}
$i++;
}
$value = $orders[$key];
$special = $objMod->special;
$tab=explode('_',$value);
$familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3];
// Check filters
$modulename=$objMod->getName();
$moduledesc=$objMod->getDesc();
$moduleauthor=$objMod->getPublisher();
print '