25 require
'../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
28 if (empty($user->admin)) {
33 $langs->loadLangs(array(
"install",
"other",
"admin"));
35 $optioncss =
GETPOST(
'optioncss',
'alpha');
36 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'moduleoverview';
38 $search_name =
GETPOST(
"search_name",
'alpha');
39 $search_id =
GETPOST(
"search_id",
'alpha');
40 $search_version =
GETPOST(
"search_version",
'alpha');
41 $search_permission =
GETPOST(
"search_permission",
'alpha');
43 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
44 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54 $hookmanager->initHooks(array(
'moduleoverview'));
56 $object =
new stdClass();
60 'name'=>array(
'label'=>$langs->trans(
"Modules"),
'checked'=>1,
'position'=>10),
61 'version'=>array(
'label'=>$langs->trans(
"Version"),
'checked'=>1,
'position'=>20),
62 'id'=>array(
'label'=>$langs->trans(
"IdModule"),
'checked'=>1,
'position'=>30),
63 'module_position'=>array(
'label'=>$langs->trans(
"Position"),
'checked'=>1,
'position'=>35),
64 'permission'=>array(
'label'=>$langs->trans(
"IdPermissions"),
'checked'=>1,
'position'=>40)
75 $parameters = array();
76 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
81 if (empty($reshook)) {
83 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
88 $moduleList = array();
90 $modules_files = array();
91 $modules_fullpath = array();
93 $rights_ids = array();
94 $arrayofpermissions = array();
96 foreach ($modulesdir as $dir) {
98 if (is_resource($handle)) {
99 while (($file = readdir($handle)) !==
false) {
100 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
101 $modName = substr($file, 0,
dol_strlen($file) - 10);
105 if (in_array($file, $modules_files)) {
107 print
"Warning duplicate file found : ".$file.
" (Found ".$dir.$file.
", already found ".$modules_fullpath[$file].
")<br>";
110 $res = include_once $dir.$file;
111 if (class_exists($modName)) {
113 $objMod =
new $modName($db);
115 $modules[$objMod->numero] = $objMod;
116 $modules_files[$objMod->numero] = $file;
117 $modules_fullpath[$file] = $dir.$file;
119 dol_syslog(
"Failed to load ".$dir.$file.
" ".$e->getMessage(), LOG_ERR);
122 print
"Warning bad descriptor file : ".$dir.$file.
" (Class ".$modName.
" not found into file)<br>";
133 foreach ($modules as $key => $module) {
134 $newModule =
new stdClass();
136 $newModule->name = $module->getName();
137 $newModule->version = $module->getVersion();
138 $newModule->id = $key;
139 $newModule->module_position = $module->getModulePosition();
141 $alt = $module->name.
' - '.$modules_files[$key];
143 if (!empty($module->picto)) {
144 if (preg_match(
'/^\//', $module->picto)) {
145 $newModule->picto =
img_picto($alt, $module->picto,
'width="14px"', 1);
147 $newModule->picto =
img_object($alt, $module->picto,
'width="14px"');
150 $newModule->picto =
img_object($alt,
'generic',
'width="14px"');
153 $permission = array();
154 if ($module->rights) {
155 foreach ($module->rights as $rights) {
156 if (empty($rights[0])) {
159 $arrayofpermissions[$rights[0]] = array(
'label'=>
'user->rights->'.$module->rights_class.
'->'.$rights[4].(empty($rights[5]) ?
'' :
'->'.$rights[5]));
160 $permission[] = $rights[0];
162 array_push($rights_ids, $rights[0]);
166 $newModule->permission = $permission;
169 if (!empty($search_name) && !stristr($newModule->name, $search_name)) {
172 if (!empty($search_version) && !stristr($newModule->version, $search_version)) {
175 if (!empty($search_id) && !stristr($newModule->id, $search_id)) {
179 if (!empty($search_permission)) {
182 foreach ($newModule->permission as $permission) {
183 if (stristr($permission, $search_permission)) {
194 $moduleList[] = $newModule;
205 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formulaire">';
206 if ($optioncss !=
'') {
207 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
209 print
'<input type="hidden" name="token" value="'.newToken().
'">';
210 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
211 print
'<input type="hidden" name="action" value="list">';
212 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
213 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
214 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
216 print_barre_liste($langs->trans(
"AvailableModules"), empty($page) ? 0 : $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder,
'', -1,
'',
'title_setup', 0,
'',
'', 0, 1, 1);
218 print
'<span class="opacitymedium">'.$langs->trans(
"ToActivateModule").
'</span>';
222 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
223 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
225 print
'<div class="div-table-responsive-no-min">';
226 print
'<table class="noborder centpercent">';
229 print
'<tr class="liste_titre_filter">';
231 if ($arrayfields[
'name'][
'checked']) {
232 print
'<td class="liste_titre left">';
233 print
'<input class="flat" type="text" name="search_name" size="8" value="'.dol_escape_htmltag($search_name).
'">';
236 if ($arrayfields[
'version'][
'checked']) {
237 print
'<td class="liste_titre left">';
238 print
'<input class="flat" type="text" name="search_version" size="6" value="'.dol_escape_htmltag($search_version).
'">';
241 if ($arrayfields[
'id'][
'checked']) {
242 print
'<td class="liste_titre left">';
243 print
'<input class="flat" type="text" name="search_id" size="6 value="'.dol_escape_htmltag($search_id).
'">';
246 if ($arrayfields[
'permission'][
'checked']) {
247 print
'<td class="liste_titre left">';
248 print
'<input class="flat" type="text" name="search_permission" size="8" value="'.dol_escape_htmltag($search_permission).
'">';
251 if ($arrayfields[
'module_position'][
'checked']) {
252 print
'<td class="liste_titre left">';
256 print
'<td class="liste_titre center maxwidthsearch">';
257 $searchpicto =
$form->showFilterButtons();
263 print
'<tr class="liste_titre">';
265 if ($arrayfields[
'name'][
'checked']) {
266 print_liste_field_titre($arrayfields[
'name'][
'label'], $_SERVER[
"PHP_SELF"],
"name",
"",
"",
"", $sortfield, $sortorder);
268 if ($arrayfields[
'version'][
'checked']) {
269 print_liste_field_titre($arrayfields[
'version'][
'label'], $_SERVER[
"PHP_SELF"],
"version",
"",
"",
"", $sortfield, $sortorder);
271 if ($arrayfields[
'id'][
'checked']) {
272 print_liste_field_titre($arrayfields[
'id'][
'label'], $_SERVER[
"PHP_SELF"],
"id",
"",
"",
"", $sortfield, $sortorder,
'nowraponall ');
274 if ($arrayfields[
'permission'][
'checked']) {
275 print_liste_field_titre($arrayfields[
'permission'][
'label'], $_SERVER[
"PHP_SELF"],
"permission",
"",
"",
"", $sortfield, $sortorder);
277 if ($arrayfields[
'module_position'][
'checked']) {
278 print_liste_field_titre($arrayfields[
'module_position'][
'label'], $_SERVER[
"PHP_SELF"],
"module_position",
"",
"",
"", $sortfield, $sortorder);
282 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
283 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
284 print $hookmanager->resPrint;
286 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
290 if ($sortfield ==
"name" && $sortorder ==
"asc") {
291 usort($moduleList,
function (stdClass $a, stdClass $b) {
292 return strcasecmp($a->name, $b->name);
294 } elseif ($sortfield ==
"name" && $sortorder ==
"desc") {
295 usort($moduleList,
function (stdClass $a, stdClass $b) {
296 return strcasecmp($b->name, $a->name);
298 } elseif ($sortfield ==
"version" && $sortorder ==
"asc") {
299 usort($moduleList,
function (stdClass $a, stdClass $b) {
300 return strcasecmp($a->version, $b->version);
302 } elseif ($sortfield ==
"version" && $sortorder ==
"desc") {
303 usort($moduleList,
function (stdClass $a, stdClass $b) {
304 return strcasecmp($b->version, $a->version);
306 } elseif ($sortfield ==
"id" && $sortorder ==
"asc") {
307 usort($moduleList,
"compareIdAsc");
308 } elseif ($sortfield ==
"id" && $sortorder ==
"desc") {
309 usort($moduleList,
"compareIdDesc");
310 } elseif ($sortfield ==
"permission" && $sortorder ==
"asc") {
311 usort($moduleList,
"comparePermissionIdsAsc");
312 } elseif ($sortfield ==
"permission" && $sortorder ==
"desc") {
313 usort($moduleList,
"comparePermissionIdsDesc");
318 foreach ($moduleList as $module) {
319 print
'<tr class="oddeven">';
321 if ($arrayfields[
'name'][
'checked']) {
322 print
'<td width="300" class="nowrap">';
323 print $module->picto;
324 print
' '.$module->name;
328 if ($arrayfields[
'version'][
'checked']) {
329 print
'<td class="nowraponall">'.$module->version.
'</td>';
332 if ($arrayfields[
'id'][
'checked']) {
333 print
'<td class="center">'.$module->id.
'</td>';
336 if ($arrayfields[
'permission'][
'checked']) {
339 foreach ($module->permission as $permission) {
340 $translationKey =
"Permission".$permission;
341 $labelpermission = $langs->trans($translationKey);
342 $labelpermission .=
' : '.$arrayofpermissions[$permission][
'label'];
343 $idperms .= ($idperms ?
", " :
"").
'<span title="'.$labelpermission.
'">'.$permission.
'</a>';
345 if (!empty($conf->global->MAIN_SHOW_PERMISSION)) {
346 if (empty($langs->tab_translate[$translationKey])) {
347 $tooltip =
'Missing translation (key '.$translationkey.
' not found in admin.lang)';
348 $idperms .=
' <img src="../../theme/eldy/img/warning.png" alt="Warning" title="'.$tooltip.
'">';
353 print
'<td><span class="opacitymedium">'.($idperms ? $idperms :
" ").
'</span></td>';
356 if ($arrayfields[
'module_position'][
'checked']) {
357 print
'<td class="center">'.$module->module_position.
'</td>';
372 foreach ($rights_ids as $right_id) {
373 if ($old == $right_id) {
374 print
"Warning duplicate id on permission : ".$right_id.
"<br>";
394 if ((
int) $a->id == (
int) $b->id) {
398 return ((
int) $a->id < (
int) $b->id) ? -1 : 1;
410 if ((
int) $a->id == (
int) $b->id) {
414 return ((
int) $b->id < (
int) $a->id) ? -1 : 1;
426 if (empty($a->permission) && empty($b->permission)) {
430 if (empty($a->permission)) {
433 if (empty($b->permission)) {
437 if ($a->permission[0] == $b->permission[0]) {
441 return $a->permission[0] < $b->permission[0] ? -1 : 1;
453 if (empty($a->permission) && empty($b->permission)) {
457 if (empty($a->permission)) {
460 if (empty($b->permission)) {
464 if ($a->permission[0] == $b->permission[0]) {
468 return $b->permission[0] < $a->permission[0] ? -1 : 1;