27require
'../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
30if (empty($user->admin)) {
35$langs->loadLangs(array(
"install",
"other",
"admin"));
37$optioncss =
GETPOST(
'optioncss',
'alpha');
38$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'moduleoverview';
40$search_name =
GETPOST(
"search_name",
'alpha');
41$search_id =
GETPOST(
"search_id",
'alpha');
42$search_version =
GETPOST(
"search_version",
'alpha');
43$search_permission =
GETPOST(
"search_permission",
'alpha');
45$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
46$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
56$hookmanager->initHooks(array(
'moduleoverview'));
62 'name' => array(
'label' => $langs->trans(
"Modules"),
'checked' => 1,
'position' => 10),
63 'version' => array(
'label' => $langs->trans(
"Version"),
'checked' => 1,
'position' => 20),
64 'id' => array(
'label' => $langs->trans(
"IdModule"),
'checked' => 1,
'position' => 30),
65 'module_position' => array(
'label' => $langs->trans(
"Position"),
'checked' => 1,
'position' => 35),
66 'permission' => array(
'label' => $langs->trans(
"IdPermissions"),
'checked' => 1,
'position' => 40)
70'@phan-var-force array<string,array{label:string,checked:int<0,1>,position:int}> $arrayfields';
80$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
87 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
94$modules_files = array();
95$modules_fullpath = array();
98$arrayofpermissions = array();
100foreach ($modulesdir as $dir) {
102 if (is_resource($handle)) {
103 while (($file = readdir($handle)) !==
false) {
104 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
105 $modName = substr($file, 0,
dol_strlen($file) - 10);
109 if (in_array($file, $modules_files)) {
111 print
"Warning duplicate file found : ".$file.
" (Found ".$dir.$file.
", already found ".$modules_fullpath[$file].
")<br>";
114 $res = include_once $dir.$file;
115 if (class_exists($modName)) {
117 $objMod =
new $modName($db);
118 '@phan-var-force DolibarrModules $objMod';
120 $modules[$objMod->numero] = $objMod;
121 $modules_files[$objMod->numero] = $file;
122 $modules_fullpath[$file] = $dir.$file;
124 dol_syslog(
"Failed to load ".$dir.$file.
" ".$e->getMessage(), LOG_ERR);
127 $info_admin .=
info_admin(
"Warning bad descriptor file : ".$dir.$file.
" (Class ".$modName.
" not found into file)", 0, 0,
'1',
'warning');
136'@phan-var-force array<string,DolibarrModules> $modules';
139foreach ($modules as $key => $module) {
142 $newModule->name = $module->getName();
143 $newModule->version = $module->getVersion();
144 $newModule->id = $key;
145 $newModule->module_position = $module->getModulePosition();
147 $alt = $module->name.
' - '.$modules_files[$key];
149 if (!empty($module->picto)) {
150 if (preg_match(
'/^\//', $module->picto)) {
152 $newModule->picto =
img_picto($alt, $module->picto,
'width="14px"', 1);
154 $newModule->picto =
img_object($alt, $module->picto,
'width="14px"');
157 $newModule->picto =
img_object($alt,
'generic',
'width="14px"');
160 $permission = array();
161 if ($module->rights) {
162 foreach ($module->rights as $rights) {
163 if (empty($rights[0])) {
166 $arrayofpermissions[$rights[0]] = array(
'label' =>
'user->hasRight(\''.$module->rights_class.
'\', \
''.$rights[4].
'\''.(empty($rights[5]) ?
'' :
', \''.$rights[5].
'\'').
')');
167 $permission[] = $rights[0];
169 array_push($rights_ids, $rights[0]);
173 $newModule->permission = $permission;
176 if (!empty($search_name) && !stristr($newModule->name, $search_name)) {
179 if (!empty($search_version) && !stristr($newModule->version, $search_version)) {
182 if (!empty($search_id) && !stristr($newModule->id, $search_id)) {
186 if (!empty($search_permission)) {
189 foreach ($newModule->permission as $permission) {
190 if (stristr($permission, $search_permission)) {
201 $moduleList[] = $newModule;
210llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-system_modules');
212print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formulaire">';
213if ($optioncss !=
'') {
214 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
216print
'<input type="hidden" name="token" value="'.newToken().
'">';
217print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
218print
'<input type="hidden" name="action" value="list">';
219print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
220print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
221print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
223print_barre_liste($langs->trans(
"AvailableModules"), empty($page) ? 0 : $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder,
'', -1,
'',
'title_setup', 0,
'',
'', 0, 1, 1);
225print
'<span class="opacitymedium">'.$langs->trans(
"ToActivateModule").
'</span>';
230$arrayofmassactions = array();
232$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
233$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
234$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
235$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
239print
'<div class="div-table-responsive-no-min">';
240print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
243print
'<tr class="liste_titre_filter">';
246 print
'<td class="liste_titre center maxwidthsearch">';
247 $searchpicto = $form->showFilterButtons();
251if ($arrayfields[
'name'][
'checked']) {
252 print
'<td class="liste_titre left">';
253 print
'<input class="flat" type="text" name="search_name" size="8" value="'.dol_escape_htmltag($search_name).
'">';
256if ($arrayfields[
'version'][
'checked']) {
257 print
'<td class="liste_titre left">';
258 print
'<input class="flat" type="text" name="search_version" size="6" value="'.dol_escape_htmltag($search_version).
'">';
261if ($arrayfields[
'id'][
'checked']) {
262 print
'<td class="liste_titre left">';
263 print
'<input class="flat" type="text" name="search_id" size="6" value="'.dol_escape_htmltag($search_id).
'">';
266if ($arrayfields[
'permission'][
'checked']) {
267 print
'<td class="liste_titre left">';
268 print
'<input class="flat" type="text" name="search_permission" size="8" value="'.dol_escape_htmltag($search_permission).
'">';
271if ($arrayfields[
'module_position'][
'checked']) {
272 print
'<td class="liste_titre left">';
277 print
'<td class="liste_titre center maxwidthsearch">';
278 $searchpicto = $form->showFilterButtons();
284print
'<tr class="liste_titre">';
287 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch actioncolumn');
289if ($arrayfields[
'name'][
'checked']) {
290 print_liste_field_titre($arrayfields[
'name'][
'label'], $_SERVER[
"PHP_SELF"],
"name",
"",
"",
"", $sortfield, $sortorder);
292if ($arrayfields[
'version'][
'checked']) {
293 print_liste_field_titre($arrayfields[
'version'][
'label'], $_SERVER[
"PHP_SELF"],
"version",
"",
"",
"", $sortfield, $sortorder);
295if ($arrayfields[
'id'][
'checked']) {
296 print_liste_field_titre($arrayfields[
'id'][
'label'], $_SERVER[
"PHP_SELF"],
"id",
"",
"",
"", $sortfield, $sortorder,
'nowraponall ');
298if ($arrayfields[
'permission'][
'checked']) {
299 print_liste_field_titre($arrayfields[
'permission'][
'label'], $_SERVER[
"PHP_SELF"],
"permission",
"",
"",
"", $sortfield, $sortorder);
301if ($arrayfields[
'module_position'][
'checked']) {
302 print_liste_field_titre($arrayfields[
'module_position'][
'label'], $_SERVER[
"PHP_SELF"],
"module_position",
"",
"",
"", $sortfield, $sortorder);
306$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
307$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
308print $hookmanager->resPrint;
311 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
316if ($sortfield ==
"name" && $sortorder ==
"asc") {
321 return strcasecmp($a->name, $b->name);
324} elseif ($sortfield ==
"name" && $sortorder ==
"desc") {
329 return strcasecmp($b->name, $a->name);
332} elseif ($sortfield ==
"version" && $sortorder ==
"asc") {
337 return strcasecmp($a->version, $b->version);
340} elseif ($sortfield ==
"version" && $sortorder ==
"desc") {
345 return strcasecmp($b->version, $a->version);
348} elseif ($sortfield ==
"id" && $sortorder ==
"asc") {
349 usort($moduleList,
"compareIdAsc");
350} elseif ($sortfield ==
"id" && $sortorder ==
"desc") {
351 usort($moduleList,
"compareIdDesc");
352} elseif ($sortfield ==
"permission" && $sortorder ==
"asc") {
353 usort($moduleList,
"comparePermissionIdsAsc");
354} elseif ($sortfield ==
"permission" && $sortorder ==
"desc") {
355 usort($moduleList,
"comparePermissionIdsDesc");
360foreach ($moduleList as $module) {
361 print
'<tr class="oddeven">';
367 if ($arrayfields[
'name'][
'checked']) {
368 print
'<td width="300" class="nowrap">';
369 print $module->picto;
370 print
' '.$module->name;
374 if ($arrayfields[
'version'][
'checked']) {
375 print
'<td class="nowraponall">'.$module->version.
'</td>';
378 if ($arrayfields[
'id'][
'checked']) {
379 print
'<td class="center">'.$module->id.
'</td>';
382 if ($arrayfields[
'permission'][
'checked']) {
385 foreach ($module->permission as $permission) {
386 $translationKey =
"Permission".$permission;
387 $labelpermission = $langs->trans($translationKey);
388 $labelpermission .=
' : '.$arrayofpermissions[$permission][
'label'];
389 $idperms .= ($idperms ?
", " :
"").
'<span title="'.$labelpermission.
'">'.$permission.
'</a>';
392 if (empty($langs->tab_translate[$translationKey])) {
393 $tooltip =
'Missing translation (key '.$translationkey.
' not found in admin.lang)';
394 $idperms .=
' <img src="../../theme/eldy/img/warning.png" alt="Warning" title="'.$tooltip.
'">';
399 print
'<td><span class="opacitymedium">'.($idperms ? $idperms :
" ").
'</span></td>';
402 if ($arrayfields[
'module_position'][
'checked']) {
403 print
'<td class="center">'.$module->module_position.
'</td>';
421foreach ($rights_ids as $right_id) {
422 if ($old == $right_id) {
423 print
"Warning duplicate id on permission : ".$right_id.
"<br>";
443 if ((
int) $a->id == (
int) $b->id) {
447 return ((
int) $a->id < (
int) $b->id) ? -1 : 1;
459 if ((
int) $a->id == (
int) $b->id) {
463 return ((
int) $b->id < (
int) $a->id) ? -1 : 1;
475 if (empty($a->permission) && empty($b->permission)) {
479 if (empty($a->permission)) {
482 if (empty($b->permission)) {
486 if ($a->permission[0] == $b->permission[0]) {
490 return $a->permission[0] < $b->permission[0] ? -1 : 1;
502 if (empty($a->permission) && empty($b->permission)) {
506 if (empty($a->permission)) {
509 if (empty($b->permission)) {
513 if ($a->permission[0] == $b->permission[0]) {
517 return $b->permission[0] < $a->permission[0] ? -1 : 1;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 directories that contain modules.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $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.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
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.