28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
31if (empty($user->admin)) {
44$langs->loadLangs(array(
"install",
"other",
"admin"));
46$optioncss =
GETPOST(
'optioncss',
'alpha');
47$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'moduleoverview';
49$search_name =
GETPOST(
"search_name",
'alpha');
50$search_id =
GETPOST(
"search_id",
'alpha');
51$search_version =
GETPOST(
"search_version",
'alpha');
52$search_permission =
GETPOST(
"search_permission",
'alpha');
54$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
55$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
65$hookmanager->initHooks(array(
'moduleoverview'));
71 'name' => array(
'label' => $langs->trans(
"Modules"),
'checked' => 1,
'position' => 10),
72 'version' => array(
'label' => $langs->trans(
"Version"),
'checked' => 1,
'position' => 20),
73 'id' => array(
'label' => $langs->trans(
"IdModule"),
'checked' => 1,
'position' => 30),
74 'module_position' => array(
'label' => $langs->trans(
"Position"),
'checked' => 1,
'position' => 35),
75 'permission' => array(
'label' => $langs->trans(
"IdPermissions"),
'checked' => 1,
'position' => 40)
79'@phan-var-force array<string,array{label:string,checked:int<0,1>,position:int}> $arrayfields';
89$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
96 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
101$moduleList = array();
103$modules_files = array();
104$modules_fullpath = array();
106$rights_ids = array();
107$arrayofpermissions = array();
109foreach ($modulesdir as $dir) {
111 if (is_resource($handle)) {
112 while (($file = readdir($handle)) !==
false) {
113 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
114 $modName = substr($file, 0,
dol_strlen($file) - 10);
118 if (in_array($file, $modules_files)) {
120 print
"Warning duplicate file found : ".$file.
" (Found ".$dir.$file.
", already found ".$modules_fullpath[$file].
")<br>";
123 $res = include_once $dir.$file;
124 if (class_exists($modName)) {
126 $objMod =
new $modName($db);
127 '@phan-var-force DolibarrModules $objMod';
129 $modules[$objMod->numero] = $objMod;
130 $modules_files[$objMod->numero] = $file;
131 $modules_fullpath[$file] = $dir.$file;
133 dol_syslog(
"Failed to load ".$dir.$file.
" ".$e->getMessage(), LOG_ERR);
136 $info_admin .=
info_admin(
"Warning bad descriptor file : ".$dir.$file.
" (Class ".$modName.
" not found into file)", 0, 0,
'1',
'warning');
145'@phan-var-force array<string,DolibarrModules> $modules';
148foreach ($modules as $key => $module) {
151 $newModule->name = $module->getName();
152 $newModule->version = $module->getVersion();
153 $newModule->id = $key;
154 $newModule->module_position = $module->getModulePosition();
156 $alt = $module->name.
' - '.$modules_files[$key];
158 if (!empty($module->picto)) {
159 if (preg_match(
'/^\//', $module->picto)) {
161 $newModule->picto =
img_picto($alt, $module->picto,
'width="14px"', 1);
163 $newModule->picto =
img_object($alt, $module->picto,
'width="14px"');
166 $newModule->picto =
img_object($alt,
'generic',
'width="14px"');
169 $permission = array();
170 if ($module->rights) {
171 foreach ($module->rights as $rights) {
172 if (empty($rights[0])) {
175 $arrayofpermissions[$rights[0]] = array(
'label' =>
'user->hasRight(\''.$module->rights_class.
'\', \
''.$rights[4].
'\''.(empty($rights[5]) ?
'' :
', \''.$rights[5].
'\'').
')');
176 $permission[] = $rights[0];
178 array_push($rights_ids, $rights[0]);
182 $newModule->permission = $permission;
185 if (!empty($search_name) && !stristr($newModule->name, $search_name)) {
188 if (!empty($search_version) && !stristr($newModule->version, $search_version)) {
191 if (!empty($search_id) && !stristr($newModule->id, $search_id)) {
195 if (!empty($search_permission)) {
198 foreach ($newModule->permission as $permission) {
199 if (stristr($permission, $search_permission)) {
210 $moduleList[] = $newModule;
219llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-system_modules');
221print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formulaire">';
222if ($optioncss !=
'') {
223 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
225print
'<input type="hidden" name="token" value="'.newToken().
'">';
226print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
227print
'<input type="hidden" name="action" value="list">';
228print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
229print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
230print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
232print_barre_liste($langs->trans(
"AvailableModules"), empty($page) ? 0 : $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder,
'', -1,
'',
'title_setup', 0,
'',
'', 0, 1, 1);
234print
'<span class="opacitymedium">'.$langs->trans(
"ToActivateModule").
'</span>';
239$arrayofmassactions = array();
241$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
242$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
243$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
244$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
248print
'<div class="div-table-responsive-no-min">';
249print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
252print
'<tr class="liste_titre_filter">';
255 print
'<td class="liste_titre center maxwidthsearch">';
256 $searchpicto = $form->showFilterButtons();
260if ($arrayfields[
'name'][
'checked']) {
261 print
'<td class="liste_titre left">';
262 print
'<input class="flat" type="text" name="search_name" size="8" value="'.dol_escape_htmltag($search_name).
'">';
265if ($arrayfields[
'version'][
'checked']) {
266 print
'<td class="liste_titre left">';
267 print
'<input class="flat" type="text" name="search_version" size="6" value="'.dol_escape_htmltag($search_version).
'">';
270if ($arrayfields[
'id'][
'checked']) {
271 print
'<td class="liste_titre left">';
272 print
'<input class="flat" type="text" name="search_id" size="6" value="'.dol_escape_htmltag($search_id).
'">';
275if ($arrayfields[
'permission'][
'checked']) {
276 print
'<td class="liste_titre left">';
277 print
'<input class="flat" type="text" name="search_permission" size="8" value="'.dol_escape_htmltag($search_permission).
'">';
280if ($arrayfields[
'module_position'][
'checked']) {
281 print
'<td class="liste_titre left">';
286 print
'<td class="liste_titre center maxwidthsearch">';
287 $searchpicto = $form->showFilterButtons();
293print
'<tr class="liste_titre">';
296 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch actioncolumn');
298if ($arrayfields[
'name'][
'checked']) {
299 print_liste_field_titre($arrayfields[
'name'][
'label'], $_SERVER[
"PHP_SELF"],
"name",
"",
"",
"", $sortfield, $sortorder);
301if ($arrayfields[
'version'][
'checked']) {
302 print_liste_field_titre($arrayfields[
'version'][
'label'], $_SERVER[
"PHP_SELF"],
"version",
"",
"",
"", $sortfield, $sortorder);
304if ($arrayfields[
'id'][
'checked']) {
305 print_liste_field_titre($arrayfields[
'id'][
'label'], $_SERVER[
"PHP_SELF"],
"id",
"",
"",
"", $sortfield, $sortorder,
'nowraponall ');
307if ($arrayfields[
'permission'][
'checked']) {
308 print_liste_field_titre($arrayfields[
'permission'][
'label'], $_SERVER[
"PHP_SELF"],
"permission",
"",
"",
"", $sortfield, $sortorder);
310if ($arrayfields[
'module_position'][
'checked']) {
311 print_liste_field_titre($arrayfields[
'module_position'][
'label'], $_SERVER[
"PHP_SELF"],
"module_position",
"",
"",
"", $sortfield, $sortorder);
315$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
316$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
317print $hookmanager->resPrint;
320 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
325if ($sortfield ==
"name" && $sortorder ==
"asc") {
330 return strcasecmp($a->name, $b->name);
333} elseif ($sortfield ==
"name" && $sortorder ==
"desc") {
338 return strcasecmp($b->name, $a->name);
341} elseif ($sortfield ==
"version" && $sortorder ==
"asc") {
346 return strcasecmp($a->version, $b->version);
349} elseif ($sortfield ==
"version" && $sortorder ==
"desc") {
354 return strcasecmp($b->version, $a->version);
357} elseif ($sortfield ==
"id" && $sortorder ==
"asc") {
358 usort($moduleList,
"compareIdAsc");
359} elseif ($sortfield ==
"id" && $sortorder ==
"desc") {
360 usort($moduleList,
"compareIdDesc");
361} elseif ($sortfield ==
"permission" && $sortorder ==
"asc") {
362 usort($moduleList,
"comparePermissionIdsAsc");
363} elseif ($sortfield ==
"permission" && $sortorder ==
"desc") {
364 usort($moduleList,
"comparePermissionIdsDesc");
369foreach ($moduleList as $module) {
370 print
'<tr class="oddeven">';
376 if ($arrayfields[
'name'][
'checked']) {
377 print
'<td width="300" class="nowrap">';
378 print $module->picto;
379 print
' '.$module->name;
383 if ($arrayfields[
'version'][
'checked']) {
384 print
'<td class="nowraponall">'.$module->version.
'</td>';
387 if ($arrayfields[
'id'][
'checked']) {
388 print
'<td class="center">'.$module->id.
'</td>';
391 if ($arrayfields[
'permission'][
'checked']) {
394 foreach ($module->permission as $permission) {
395 $translationKey =
"Permission".$permission;
396 $labelpermission = $langs->trans($translationKey);
397 $labelpermission .=
' : '.$arrayofpermissions[$permission][
'label'];
398 $idperms .= ($idperms ?
", " :
"").
'<span title="'.$labelpermission.
'">'.$permission.
'</a>';
401 if (empty($langs->tab_translate[$translationKey])) {
402 $tooltip =
'Missing translation (key '.$translationKey.
' not found in admin.lang)';
403 $idperms .=
' <img src="../../theme/eldy/img/warning.png" alt="Warning" title="'.$tooltip.
'">';
408 print
'<td><span class="opacitymedium">'.($idperms ? $idperms :
" ").
'</span></td>';
411 if ($arrayfields[
'module_position'][
'checked']) {
412 print
'<td class="center">'.$module->module_position.
'</td>';
430foreach ($rights_ids as $right_id) {
431 if ($old == $right_id) {
432 print
"Warning duplicate id on permission : ".$right_id.
"<br>";
452 if ((
int) $a->id == (
int) $b->id) {
456 return ((
int) $a->id < (
int) $b->id) ? -1 : 1;
468 if ((
int) $a->id == (
int) $b->id) {
472 return ((
int) $b->id < (
int) $a->id) ? -1 : 1;
484 if (empty($a->permission) && empty($b->permission)) {
488 if (empty($a->permission)) {
491 if (empty($b->permission)) {
495 if ($a->permission[0] == $b->permission[0]) {
499 return $a->permission[0] < $b->permission[0] ? -1 : 1;
511 if (empty($a->permission) && empty($b->permission)) {
515 if (empty($a->permission)) {
518 if (empty($b->permission)) {
522 if ($a->permission[0] == $b->permission[0]) {
526 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a 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.