28require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
38if (empty($user->admin)) {
43$langs->loadLangs(array(
"install",
"other",
"admin"));
45$action =
GETPOST(
'action',
'aZ09');
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');
55$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
56$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
66$hookmanager->initHooks(array(
'moduleoverview'));
72 'name' => array(
'label' => $langs->trans(
"Modules"),
'checked' =>
'1',
'position' => 10),
73 'version' => array(
'label' => $langs->trans(
"Version"),
'checked' =>
'1',
'position' => 20),
74 'id' => array(
'label' => $langs->trans(
"IdModule"),
'checked' =>
'1',
'position' => 30),
75 'module_position' => array(
'label' => $langs->trans(
"Position"),
'checked' =>
'1',
'position' => 35),
76 'permission' => array(
'label' => $langs->trans(
"IdPermissions"),
'checked' =>
'1',
'position' => 40)
90$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
97 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);
137 $silentModules = array(
'modSupplierOrder',
'modSupplierInvoice',
'modFournisseur');
138 if (!in_array($modName, $silentModules)) {
139 $info_admin .=
info_admin(
"admin/modules.php Warning bad descriptor file : ".$dir.$file.
" (Class ".$modName.
" not found into file)", 0, 0,
'1',
'warning');
149'@phan-var-force array<string,DolibarrModules> $modules';
152foreach ($modules as $key => $module) {
155 $newModule->name = $module->getName();
156 $newModule->version = $module->getVersion();
157 $newModule->id = $key;
158 $newModule->module_position = $module->getModulePosition();
160 $alt = $module->name.
' - '.$modules_files[$key];
162 if (!empty($module->picto)) {
163 if (preg_match(
'/^\//', $module->picto)) {
165 $newModule->picto =
img_picto($alt, $module->picto,
'width="14px"', 1);
167 $newModule->picto =
img_object($alt, $module->picto,
'width="14px"');
170 $newModule->picto =
img_object($alt,
'generic',
'width="14px"');
173 $permission = array();
174 if ($module->rights) {
175 foreach ($module->rights as $rights) {
176 if (empty($rights[0])) {
179 $arrayofpermissions[$rights[0]] = array(
'label' =>
'user->hasRight(\''.$module->rights_class.
'\', \
''.$rights[4].
'\''.(empty($rights[5]) ?
'' :
', \''.$rights[5].
'\'').
')');
180 $permission[] = $rights[0];
182 array_push($rights_ids, $rights[0]);
186 $newModule->permission = $permission;
189 if (!empty($search_name) && !stristr($newModule->name, $search_name)) {
192 if (!empty($search_version) && !stristr($newModule->version, $search_version)) {
195 if (!empty($search_id) && !stristr($newModule->id, $search_id)) {
199 if (!empty($search_permission)) {
202 foreach ($newModule->permission as $permission) {
203 if (stristr($permission, $search_permission)) {
214 $moduleList[] = $newModule;
223llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-system_modules');
225print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formulaire">';
226if ($optioncss !=
'') {
227 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
229print
'<input type="hidden" name="token" value="'.newToken().
'">';
230print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
231print
'<input type="hidden" name="action" value="list">';
232print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
233print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
234print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
237 print_barre_liste($langs->trans(
"AvailableModules"), empty($page) ? 0 : $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder,
'', -1,
'',
'title_setup', 0,
'',
'', 0, 1, 1);
239 print
'<span class="opacitymedium">'.$langs->trans(
"ToActivateModule").
'</span>';
245$arrayofmassactions = array();
247$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
248$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
249$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
250$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
254print
'<div class="div-table-responsive-no-min">';
255print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
258print
'<tr class="liste_titre_filter">';
260if (
$conf->main_checkbox_left_column) {
261 print
'<td class="liste_titre center maxwidthsearch">';
262 $searchpicto = $form->showFilterButtons();
266if ($arrayfields[
'name'][
'checked']) {
267 print
'<td class="liste_titre">';
268 print
'<input class="flat width100" type="text" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
271if ($arrayfields[
'version'][
'checked']) {
272 print
'<td class="liste_titre">';
273 print
'<input class="flat width50" type="text" name="search_version" value="'.dol_escape_htmltag($search_version).
'">';
276if ($arrayfields[
'id'][
'checked']) {
277 print
'<td class="liste_titre center">';
278 print
'<input class="flat width50" type="text" name="search_id" value="'.dol_escape_htmltag($search_id).
'">';
281if ($arrayfields[
'permission'][
'checked']) {
282 print
'<td class="liste_titre">';
283 print
'<input class="flat width100" type="text" name="search_permission" value="'.dol_escape_htmltag($search_permission).
'">';
286if ($arrayfields[
'module_position'][
'checked']) {
287 print
'<td class="liste_titre">';
291if (!
$conf->main_checkbox_left_column) {
292 print
'<td class="liste_titre center maxwidthsearch">';
293 $searchpicto = $form->showFilterButtons();
299print
'<tr class="liste_titre">';
301if (
$conf->main_checkbox_left_column) {
302 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch actioncolumn');
304if ($arrayfields[
'name'][
'checked']) {
305 print_liste_field_titre($arrayfields[
'name'][
'label'], $_SERVER[
"PHP_SELF"],
"name",
"",
"",
"", $sortfield, $sortorder);
307if ($arrayfields[
'version'][
'checked']) {
308 print_liste_field_titre($arrayfields[
'version'][
'label'], $_SERVER[
"PHP_SELF"],
"version",
"",
"",
"", $sortfield, $sortorder);
310if ($arrayfields[
'id'][
'checked']) {
311 print_liste_field_titre($arrayfields[
'id'][
'label'], $_SERVER[
"PHP_SELF"],
"id",
"",
"",
"", $sortfield, $sortorder,
'nowraponall center ');
313if ($arrayfields[
'permission'][
'checked']) {
314 print_liste_field_titre($arrayfields[
'permission'][
'label'], $_SERVER[
"PHP_SELF"],
"permission",
"",
"",
"", $sortfield, $sortorder);
316if ($arrayfields[
'module_position'][
'checked']) {
317 print_liste_field_titre($arrayfields[
'module_position'][
'label'], $_SERVER[
"PHP_SELF"],
"module_position",
"",
"",
"", $sortfield, $sortorder,
"right ");
321$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
322$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
323print $hookmanager->resPrint;
325if (!
$conf->main_checkbox_left_column) {
326 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
331if ($sortfield ==
"name" && $sortorder ==
"asc") {
336 return strcasecmp($a->name, $b->name);
339} elseif ($sortfield ==
"name" && $sortorder ==
"desc") {
344 return strcasecmp($b->name, $a->name);
347} elseif ($sortfield ==
"version" && $sortorder ==
"asc") {
352 return strcasecmp($a->version, $b->version);
355} elseif ($sortfield ==
"version" && $sortorder ==
"desc") {
360 return strcasecmp($b->version, $a->version);
363} elseif ($sortfield ==
"id" && $sortorder ==
"asc") {
364 usort($moduleList,
"compareIdAsc");
365} elseif ($sortfield ==
"id" && $sortorder ==
"desc") {
366 usort($moduleList,
"compareIdDesc");
367} elseif ($sortfield ==
"permission" && $sortorder ==
"asc") {
368 usort($moduleList,
"comparePermissionIdsAsc");
369} elseif ($sortfield ==
"permission" && $sortorder ==
"desc") {
370 usort($moduleList,
"comparePermissionIdsDesc");
372 $moduleList =
dol_sort_array($moduleList,
'module_position', $sortorder);
375foreach ($moduleList as $module) {
376 print
'<tr class="oddeven">';
378 if (
$conf->main_checkbox_left_column) {
382 if ($arrayfields[
'name'][
'checked']) {
383 print
'<td width="300" class="nowrap">';
384 print $module->picto;
385 print
' '.dolPrintHTML($module->name);
389 if ($arrayfields[
'version'][
'checked']) {
390 print
'<td class="nowraponall">'.dolPrintHTML($module->version).
'</td>';
393 if ($arrayfields[
'id'][
'checked']) {
394 print
'<td class="center">'.dolPrintHTML($module->id).
'</td>';
397 if ($arrayfields[
'permission'][
'checked']) {
400 foreach ($module->permission as $permission) {
401 $translationKey =
"Permission".$permission;
402 $labelpermission = $langs->trans($translationKey);
403 $labelpermission .=
' : '.$arrayofpermissions[$permission][
'label'];
404 $idperms .= ($idperms ?
", " :
"").
'<span title="'.$labelpermission.
'">'.$permission.
'</a>';
407 if (empty($langs->tab_translate[$translationKey])) {
408 $tooltip =
'Missing translation (key '.$translationKey.
' not found in admin.lang)';
409 $idperms .=
' <img src="../../theme/eldy/img/warning.png" alt="Warning" title="'.$tooltip.
'">';
414 print
'<td><span class="opacitymedium">'.($idperms ? $idperms :
" ").
'</span></td>';
417 if ($arrayfields[
'module_position'][
'checked']) {
418 print
'<td class="right">'.dolPrintHTML($module->module_position).
'</td>';
422 if (!
$conf->main_checkbox_left_column) {
436foreach ($rights_ids as $right_id) {
437 if ($old == $right_id) {
438 print
"Warning duplicate id on permission : ".$right_id.
"<br>";
458 if ((
int) $a->id == (
int) $b->id) {
462 return ((
int) $a->id < (
int) $b->id) ? -1 : 1;
474 if ((
int) $a->id == (
int) $b->id) {
478 return ((
int) $b->id < (
int) $a->id) ? -1 : 1;
490 if (empty($a->permission) && empty($b->permission)) {
494 if (empty($a->permission)) {
497 if (empty($b->permission)) {
501 if ($a->permission[0] == $b->permission[0]) {
505 return $a->permission[0] < $b->permission[0] ? -1 : 1;
517 if (empty($a->permission) && empty($b->permission)) {
521 if (empty($a->permission)) {
524 if (empty($b->permission)) {
528 if ($a->permission[0] == $b->permission[0]) {
532 return $b->permission[0] < $a->permission[0] ? -1 : 1;
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $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, $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, $allowothertags=array())
Show picto whatever it's its name (generic function)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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...
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.
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.