26require
'../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
29if (empty($user->admin)) {
34$langs->loadLangs(array(
"install",
"other",
"admin"));
36$optioncss =
GETPOST(
'optioncss',
'alpha');
37$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'moduleoverview';
39$search_name =
GETPOST(
"search_name",
'alpha');
40$search_id =
GETPOST(
"search_id",
'alpha');
41$search_version =
GETPOST(
"search_version",
'alpha');
42$search_permission =
GETPOST(
"search_permission",
'alpha');
44$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
45$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
55$hookmanager->initHooks(array(
'moduleoverview'));
57$object =
new stdClass();
61 'name'=>array(
'label'=>$langs->trans(
"Modules"),
'checked'=>1,
'position'=>10),
62 'version'=>array(
'label'=>$langs->trans(
"Version"),
'checked'=>1,
'position'=>20),
63 'id'=>array(
'label'=>$langs->trans(
"IdModule"),
'checked'=>1,
'position'=>30),
64 'module_position'=>array(
'label'=>$langs->trans(
"Position"),
'checked'=>1,
'position'=>35),
65 'permission'=>array(
'label'=>$langs->trans(
"IdPermissions"),
'checked'=>1,
'position'=>40)
77$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
84 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
91$modules_files = array();
92$modules_fullpath = array();
95$arrayofpermissions = array();
97foreach ($modulesdir as $dir) {
99 if (is_resource($handle)) {
100 while (($file = readdir($handle)) !==
false) {
101 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
102 $modName = substr($file, 0,
dol_strlen($file) - 10);
106 if (in_array($file, $modules_files)) {
108 print
"Warning duplicate file found : ".$file.
" (Found ".$dir.$file.
", already found ".$modules_fullpath[$file].
")<br>";
111 $res = include_once $dir.$file;
112 if (class_exists($modName)) {
114 $objMod =
new $modName($db);
116 $modules[$objMod->numero] = $objMod;
117 $modules_files[$objMod->numero] = $file;
118 $modules_fullpath[$file] = $dir.$file;
120 dol_syslog(
"Failed to load ".$dir.$file.
" ".$e->getMessage(), LOG_ERR);
123 print
"Warning bad descriptor file : ".$dir.$file.
" (Class ".$modName.
" not found into file)<br>";
134foreach ($modules as $key => $module) {
135 $newModule =
new stdClass();
137 $newModule->name = $module->getName();
138 $newModule->version = $module->getVersion();
139 $newModule->id = $key;
140 $newModule->module_position = $module->getModulePosition();
142 $alt = $module->name.
' - '.$modules_files[$key];
144 if (!empty($module->picto)) {
145 if (preg_match(
'/^\//', $module->picto)) {
146 $newModule->picto =
img_picto($alt, $module->picto,
'width="14px"', 1);
148 $newModule->picto =
img_object($alt, $module->picto,
'width="14px"');
151 $newModule->picto =
img_object($alt,
'generic',
'width="14px"');
154 $permission = array();
155 if ($module->rights) {
156 foreach ($module->rights as $rights) {
157 if (empty($rights[0])) {
160 $arrayofpermissions[$rights[0]] = array(
'label'=>
'user->rights->'.$module->rights_class.
'->'.$rights[4].(empty($rights[5]) ?
'' :
'->'.$rights[5]));
161 $permission[] = $rights[0];
163 array_push($rights_ids, $rights[0]);
167 $newModule->permission = $permission;
170 if (!empty($search_name) && !stristr($newModule->name, $search_name)) {
173 if (!empty($search_version) && !stristr($newModule->version, $search_version)) {
176 if (!empty($search_id) && !stristr($newModule->id, $search_id)) {
180 if (!empty($search_permission)) {
183 foreach ($newModule->permission as $permission) {
184 if (stristr($permission, $search_permission)) {
195 $moduleList[] = $newModule;
206print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formulaire">';
207if ($optioncss !=
'') {
208 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
210print
'<input type="hidden" name="token" value="'.newToken().
'">';
211print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
212print
'<input type="hidden" name="action" value="list">';
213print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
214print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
215print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
217print_barre_liste($langs->trans(
"AvailableModules"), empty($page) ? 0 : $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder,
'', -1,
'',
'title_setup', 0,
'',
'', 0, 1, 1);
219print
'<span class="opacitymedium">'.$langs->trans(
"ToActivateModule").
'</span>';
224$arrayofmassactions = array();
226$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
227$selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
228$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
232print
'<div class="div-table-responsive-no-min">';
233print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
236print
'<tr class="liste_titre_filter">';
239 print
'<td class="liste_titre center maxwidthsearch">';
240 $searchpicto = $form->showFilterButtons();
244if ($arrayfields[
'name'][
'checked']) {
245 print
'<td class="liste_titre left">';
246 print
'<input class="flat" type="text" name="search_name" size="8" value="'.dol_escape_htmltag($search_name).
'">';
249if ($arrayfields[
'version'][
'checked']) {
250 print
'<td class="liste_titre left">';
251 print
'<input class="flat" type="text" name="search_version" size="6" value="'.dol_escape_htmltag($search_version).
'">';
254if ($arrayfields[
'id'][
'checked']) {
255 print
'<td class="liste_titre left">';
256 print
'<input class="flat" type="text" name="search_id" size="6" value="'.dol_escape_htmltag($search_id).
'">';
259if ($arrayfields[
'permission'][
'checked']) {
260 print
'<td class="liste_titre left">';
261 print
'<input class="flat" type="text" name="search_permission" size="8" value="'.dol_escape_htmltag($search_permission).
'">';
264if ($arrayfields[
'module_position'][
'checked']) {
265 print
'<td class="liste_titre left">';
270 print
'<td class="liste_titre center maxwidthsearch">';
271 $searchpicto = $form->showFilterButtons();
277print
'<tr class="liste_titre">';
280 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch actioncolumn');
282if ($arrayfields[
'name'][
'checked']) {
283 print_liste_field_titre($arrayfields[
'name'][
'label'], $_SERVER[
"PHP_SELF"],
"name",
"",
"",
"", $sortfield, $sortorder);
285if ($arrayfields[
'version'][
'checked']) {
286 print_liste_field_titre($arrayfields[
'version'][
'label'], $_SERVER[
"PHP_SELF"],
"version",
"",
"",
"", $sortfield, $sortorder);
288if ($arrayfields[
'id'][
'checked']) {
289 print_liste_field_titre($arrayfields[
'id'][
'label'], $_SERVER[
"PHP_SELF"],
"id",
"",
"",
"", $sortfield, $sortorder,
'nowraponall ');
291if ($arrayfields[
'permission'][
'checked']) {
292 print_liste_field_titre($arrayfields[
'permission'][
'label'], $_SERVER[
"PHP_SELF"],
"permission",
"",
"",
"", $sortfield, $sortorder);
294if ($arrayfields[
'module_position'][
'checked']) {
295 print_liste_field_titre($arrayfields[
'module_position'][
'label'], $_SERVER[
"PHP_SELF"],
"module_position",
"",
"",
"", $sortfield, $sortorder);
299$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
300$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
301print $hookmanager->resPrint;
304 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
309if ($sortfield ==
"name" && $sortorder ==
"asc") {
310 usort($moduleList,
function (stdClass $a, stdClass $b) {
311 return strcasecmp($a->name, $b->name);
313} elseif ($sortfield ==
"name" && $sortorder ==
"desc") {
314 usort($moduleList,
function (stdClass $a, stdClass $b) {
315 return strcasecmp($b->name, $a->name);
317} elseif ($sortfield ==
"version" && $sortorder ==
"asc") {
318 usort($moduleList,
function (stdClass $a, stdClass $b) {
319 return strcasecmp($a->version, $b->version);
321} elseif ($sortfield ==
"version" && $sortorder ==
"desc") {
322 usort($moduleList,
function (stdClass $a, stdClass $b) {
323 return strcasecmp($b->version, $a->version);
325} elseif ($sortfield ==
"id" && $sortorder ==
"asc") {
326 usort($moduleList,
"compareIdAsc");
327} elseif ($sortfield ==
"id" && $sortorder ==
"desc") {
328 usort($moduleList,
"compareIdDesc");
329} elseif ($sortfield ==
"permission" && $sortorder ==
"asc") {
330 usort($moduleList,
"comparePermissionIdsAsc");
331} elseif ($sortfield ==
"permission" && $sortorder ==
"desc") {
332 usort($moduleList,
"comparePermissionIdsDesc");
337foreach ($moduleList as $module) {
338 print
'<tr class="oddeven">';
344 if ($arrayfields[
'name'][
'checked']) {
345 print
'<td width="300" class="nowrap">';
346 print $module->picto;
347 print
' '.$module->name;
351 if ($arrayfields[
'version'][
'checked']) {
352 print
'<td class="nowraponall">'.$module->version.
'</td>';
355 if ($arrayfields[
'id'][
'checked']) {
356 print
'<td class="center">'.$module->id.
'</td>';
359 if ($arrayfields[
'permission'][
'checked']) {
362 foreach ($module->permission as $permission) {
363 $translationKey =
"Permission".$permission;
364 $labelpermission = $langs->trans($translationKey);
365 $labelpermission .=
' : '.$arrayofpermissions[$permission][
'label'];
366 $idperms .= ($idperms ?
", " :
"").
'<span title="'.$labelpermission.
'">'.$permission.
'</a>';
368 if (!empty($conf->global->MAIN_SHOW_PERMISSION)) {
369 if (empty($langs->tab_translate[$translationKey])) {
370 $tooltip =
'Missing translation (key '.$translationkey.
' not found in admin.lang)';
371 $idperms .=
' <img src="../../theme/eldy/img/warning.png" alt="Warning" title="'.$tooltip.
'">';
376 print
'<td><span class="opacitymedium">'.($idperms ? $idperms :
" ").
'</span></td>';
379 if ($arrayfields[
'module_position'][
'checked']) {
380 print
'<td class="center">'.$module->module_position.
'</td>';
398foreach ($rights_ids as $right_id) {
399 if ($old == $right_id) {
400 print
"Warning duplicate id on permission : ".$right_id.
"<br>";
420 if ((
int) $a->id == (
int) $b->id) {
424 return ((
int) $a->id < (
int) $b->id) ? -1 : 1;
436 if ((
int) $a->id == (
int) $b->id) {
440 return ((
int) $b->id < (
int) $a->id) ? -1 : 1;
452 if (empty($a->permission) && empty($b->permission)) {
456 if (empty($a->permission)) {
459 if (empty($b->permission)) {
463 if ($a->permission[0] == $b->permission[0]) {
467 return $a->permission[0] < $b->permission[0] ? -1 : 1;
479 if (empty($a->permission) && empty($b->permission)) {
483 if (empty($a->permission)) {
486 if (empty($b->permission)) {
490 if ($a->permission[0] == $b->permission[0]) {
494 return $b->permission[0] < $a->permission[0] ? -1 : 1;
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
dolGetModulesDirs($subdir='')
Return list of modules directories.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
compareIdDesc(stdClass $a, stdClass $b)
Compare two modules by their ID for a descending order.
compareIdAsc(stdClass $a, stdClass $b)
Compare two modules by their ID for a ascending order.
comparePermissionIdsDesc(stdClass $a, stdClass $b)
Compare two modules by their permissions for a descending order.
comparePermissionIdsAsc(stdClass $a, stdClass $b)
Compare two modules by their ID for a ascending order.