diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php
index 1e5de3b9a46..bba227f9acc 100644
--- a/htdocs/admin/system/modules.php
+++ b/htdocs/admin/system/modules.php
@@ -25,32 +25,64 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-// Load translation files required by the page
-$langs->loadLangs(array("install", "other", "admin"));
-
if (!$user->admin)
accessforbidden();
+// Load translation files required by the page
+$langs->loadLangs(array("install", "other", "admin"));
+
+$optioncss = GETPOST('optioncss', 'alpha');
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moduleoverview';
+
+$search_name = GETPOST("search_name", 'alpha');
+$search_id = GETPOST("search_id", 'alpha');
+$search_version = GETPOST("search_version", 'alpha');
+$search_permission = GETPOST("search_permission", 'alpha');
+
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
+
+if (!$sortfield) $sortfield = "id";
+if (!$sortorder) $sortorder = "asc";
+
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
+$hookmanager->initHooks(array('moduleoverview'));
+$form = new Form($db);
+$object = new stdClass();
+
+// Definition of fields for lists
+$arrayfields = array(
+ 'name'=>array('label'=>$langs->trans("Modules"), 'checked'=>1, 'position'=>10),
+ 'version'=>array('label'=>$langs->trans("Version"), 'checked'=>1, 'position'=>20),
+ 'id'=>array('label'=>$langs->trans("IdModule"), 'checked'=>1, 'position'=>30),
+ 'permission'=>array('label'=>$langs->trans("IdPermissions"), 'checked'=>1, 'position'=>40)
+);
+
+$arrayfields = dol_sort_array($arrayfields, 'position');
/*
- * View
+ * Actions
*/
-llxHeader();
+$parameters = array();
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-print load_fiche_titre($langs->trans("AvailableModules"), '', 'title_setup');
+if (empty($reshook))
+{
+ // Selection of new fields
+ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+}
-print ''.$langs->trans("ToActivateModule").'
';
-print "
\n";
+// Load list of modules
+$moduleList = array();
$modules = array();
-$modules_names = array();
$modules_files = array();
$modules_fullpath = array();
$modulesdir = dolGetModulesDirs();
+$rights_ids = array();
-// Load list of modules
-$i = 0;
foreach ($modulesdir as $dir)
{
$handle = @opendir(dol_osencode($dir));
@@ -69,7 +101,9 @@ foreach ($modulesdir as $dir)
{
// File duplicate
print "Warning duplicate file found : ".$file." (Found ".$dir.$file.", already found ".$modules_fullpath[$file].")
";
- } else {
+ }
+ else
+ {
// File to load
$res = include_once $dir.$file;
if (class_exists($modName))
@@ -78,15 +112,16 @@ foreach ($modulesdir as $dir)
$objMod = new $modName($db);
$modules[$objMod->numero] = $objMod;
- $modules_names[$objMod->numero] = $objMod->name;
$modules_files[$objMod->numero] = $file;
$modules_fullpath[$file] = $dir.$file;
- $picto[$objMod->numero] = (isset($objMod->picto) && $objMod->picto) ? $objMod->picto : 'generic';
- } catch (Exception $e)
+ }
+ catch (Exception $e)
{
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
}
- } else {
+ }
+ else
+ {
print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
";
}
}
@@ -97,60 +132,267 @@ foreach ($modulesdir as $dir)
}
}
-print '
| '.$langs->trans("Modules").' | '; -print ''.$langs->trans("Version").' | '; -print ''.$langs->trans("IdModule").' | '; -print ''.$langs->trans("IdPermissions").' | '; -print '
| '; - $alt = $name.' - '.$modules_files[$numero]; - if (!empty($picto[$numero])) + $newModule = new stdClass(); + + $newModule->name = $module->getName(); + $newModule->version = $module->getVersion(); + $newModule->id = $key; + + $alt = $module->name.' - '.$modules_files[$key]; + + if (!empty($module->picto)) { - if (preg_match('/^\//', $picto[$numero])) print img_picto($alt, $picto[$numero], 'width="14px"', 1); - else print img_object($alt, $picto[$numero], 'width="14px"'); - } else { - print img_object($alt, $picto[$numero], 'width="14px"'); + if (preg_match('/^\//', $module->picto)) $newModule->picto = img_picto($alt, $module->picto, 'width="14px"', 1); + else $newModule->picto = img_object($alt, $module->picto, 'width="14px"'); } - print ' '.$modules[$numero]->getName(); - print " | "; - // Version - print ''.$modules[$numero]->getVersion().' | '; - // Id - print ''.$numero.' | '; - // Permissions - if ($modules[$numero]->rights) + else { - foreach ($modules[$numero]->rights as $rights) + $newModule->picto = img_object($alt, 'generic', 'width="14px"'); + } + + $permission = array(); + if ($module->rights) + { + foreach ($module->rights as $rights) { - $idperms .= ($idperms ? ", " : "").$rights[0]; + if (empty($rights[0])) + { + continue; + } + + $permission[] = $rights[0]; + array_push($rights_ids, $rights[0]); } } - print ''.($idperms ? $idperms : " ").' | '; - print "