2008-10-12 13:41:13 +02:00
< ? php
2011-10-22 11:56:04 +02:00
/* Copyright ( C ) 2005 - 2009 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2010 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2024-03-14 21:59:15 +01:00
* Copyright ( C ) 2024 MDW < mdeweerd @ users . noreply . github . com >
2008-10-12 13:41:13 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2008-10-12 13:41:13 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2008-10-12 13:41:13 +02:00
*/
/**
2011-01-22 10:54:08 +01:00
* \file htdocs / admin / system / modules . php
* \brief File to list all Dolibarr modules
2008-10-12 13:41:13 +02:00
*/
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2008-10-12 13:41:13 +02:00
2021-04-21 18:59:25 +02:00
if ( empty ( $user -> admin )) {
2020-09-08 10:07:34 +02:00
accessforbidden ();
2020-09-09 08:34:13 +02:00
}
2020-09-08 10:07:34 +02:00
2018-09-07 14:58:22 +02:00
// Load translation files required by the page
2020-04-10 10:59:32 +02:00
$langs -> loadLangs ( array ( " install " , " other " , " admin " ));
2008-10-12 13:41:13 +02:00
2020-09-14 04:30:04 +02:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2023-12-04 11:41:14 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'moduleoverview' ;
2020-09-08 10:07:34 +02:00
$search_name = GETPOST ( " search_name " , 'alpha' );
2020-09-14 04:30:04 +02:00
$search_id = GETPOST ( " search_id " , 'alpha' );
$search_version = GETPOST ( " search_version " , 'alpha' );
$search_permission = GETPOST ( " search_permission " , 'alpha' );
2020-09-08 10:07:34 +02:00
2022-01-13 11:09:37 +01:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-09-08 10:07:34 +02:00
2021-02-26 22:04:03 +01:00
if ( ! $sortfield ) {
$sortfield = " id " ;
}
if ( ! $sortorder ) {
$sortorder = " asc " ;
}
2020-09-08 10:07:34 +02:00
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
$hookmanager -> initHooks ( array ( 'moduleoverview' ));
$form = new Form ( $db );
$object = new stdClass ();
2009-05-08 05:53:36 +02:00
2020-09-08 10:07:34 +02:00
// Definition of fields for lists
$arrayfields = array (
2024-03-07 20:16:48 +01:00
'name' => array ( 'label' => $langs -> trans ( " Modules " ), 'checked' => 1 , 'position' => 10 ),
'version' => array ( 'label' => $langs -> trans ( " Version " ), 'checked' => 1 , 'position' => 20 ),
'id' => array ( 'label' => $langs -> trans ( " IdModule " ), 'checked' => 1 , 'position' => 30 ),
'module_position' => array ( 'label' => $langs -> trans ( " Position " ), 'checked' => 1 , 'position' => 35 ),
'permission' => array ( 'label' => $langs -> trans ( " IdPermissions " ), 'checked' => 1 , 'position' => 40 )
2020-09-08 10:07:34 +02:00
);
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2024-03-24 13:44:23 +01:00
'@phan-var-force array<string,array{label:string,checked:int<0,1>,position:int}> $arrayfields' ;
2021-05-18 15:23:29 +02:00
$param = '' ;
2024-02-25 10:06:21 +01:00
$info_admin = '' ;
2020-10-02 16:15:24 +02:00
2008-10-12 13:41:13 +02:00
/*
2020-09-08 10:07:34 +02:00
* Actions
2008-10-12 13:41:13 +02:00
*/
2009-05-08 05:53:36 +02:00
2020-09-08 10:07:34 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 22:04:03 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2008-10-12 13:41:13 +02:00
2020-09-09 08:34:13 +02:00
if ( empty ( $reshook )) {
2020-09-08 10:07:34 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
}
2008-10-12 13:41:13 +02:00
2020-09-08 10:07:34 +02:00
// Load list of modules
$moduleList = array ();
2008-10-12 13:41:13 +02:00
$modules = array ();
$modules_files = array ();
2013-04-09 23:04:59 +02:00
$modules_fullpath = array ();
2012-05-08 22:49:03 +02:00
$modulesdir = dolGetModulesDirs ();
2020-09-08 10:07:34 +02:00
$rights_ids = array ();
2021-10-02 19:45:58 +02:00
$arrayofpermissions = array ();
2011-08-13 11:36:45 +02:00
2020-09-09 08:34:13 +02:00
foreach ( $modulesdir as $dir ) {
2020-04-10 10:59:32 +02:00
$handle = @ opendir ( dol_osencode ( $dir ));
2020-09-09 08:34:13 +02:00
if ( is_resource ( $handle )) {
while (( $file = readdir ( $handle )) !== false ) {
if ( is_readable ( $dir . $file ) && substr ( $file , 0 , 3 ) == 'mod' && substr ( $file , dol_strlen ( $file ) - 10 ) == '.class.php' ) {
2020-03-23 15:54:02 +01:00
$modName = substr ( $file , 0 , dol_strlen ( $file ) - 10 );
2009-07-06 14:46:20 +02:00
2020-09-09 08:34:13 +02:00
if ( $modName ) {
2020-03-23 15:54:02 +01:00
//print 'xx'.$dir.$file.'<br>';
2020-09-09 08:34:13 +02:00
if ( in_array ( $file , $modules_files )) {
2013-04-09 23:04:59 +02:00
// File duplicate
print " Warning duplicate file found : " . $file . " (Found " . $dir . $file . " , already found " . $modules_fullpath [ $file ] . " )<br> " ;
2021-02-26 22:04:03 +01:00
} else {
2013-04-09 23:04:59 +02:00
// File to load
2020-04-10 10:59:32 +02:00
$res = include_once $dir . $file ;
2020-09-09 08:34:13 +02:00
if ( class_exists ( $modName )) {
2013-12-08 02:32:04 +01:00
try {
2020-03-23 15:54:02 +01:00
$objMod = new $modName ( $db );
2024-03-24 21:36:54 +01:00
'@phan-var-force DolibarrModules $objMod' ;
2018-07-26 18:22:16 +02:00
2020-04-10 10:59:32 +02:00
$modules [ $objMod -> numero ] = $objMod ;
$modules_files [ $objMod -> numero ] = $file ;
$modules_fullpath [ $file ] = $dir . $file ;
2021-02-26 22:04:03 +01:00
} catch ( Exception $e ) {
2013-12-08 02:32:04 +01:00
dol_syslog ( " Failed to load " . $dir . $file . " " . $e -> getMessage (), LOG_ERR );
2018-07-26 18:22:16 +02:00
}
2021-02-26 22:04:03 +01:00
} else {
2024-02-25 10:06:21 +01:00
$info_admin .= info_admin ( " Warning bad descriptor file : " . $dir . $file . " (Class " . $modName . " not found into file) " , 0 , 0 , '1' , 'warning' );
2013-12-08 02:32:04 +01:00
}
2013-04-09 23:04:59 +02:00
}
2020-03-23 15:54:02 +01:00
}
}
}
closedir ( $handle );
}
2008-10-12 13:41:13 +02:00
}
2024-03-24 21:36:54 +01:00
'@phan-var-force array<string,DolibarrModules> $modules' ;
2017-01-17 20:04:41 +01:00
2020-09-08 10:07:34 +02:00
// create pre-filtered list for modules
2021-02-26 22:04:03 +01:00
foreach ( $modules as $key => $module ) {
2020-09-08 10:07:34 +02:00
$newModule = new stdClass ();
2020-09-14 04:30:04 +02:00
$newModule -> name = $module -> getName ();
$newModule -> version = $module -> getVersion ();
$newModule -> id = $key ;
2021-05-02 13:13:55 +02:00
$newModule -> module_position = $module -> getModulePosition ();
2020-09-08 10:13:56 +02:00
2020-09-08 10:07:34 +02:00
$alt = $module -> name . ' - ' . $modules_files [ $key ];
2020-09-08 10:13:56 +02:00
2020-09-09 08:34:13 +02:00
if ( ! empty ( $module -> picto )) {
2021-02-26 22:04:03 +01:00
if ( preg_match ( '/^\//' , $module -> picto )) {
2024-03-07 20:16:48 +01:00
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
2021-02-26 22:04:03 +01:00
$newModule -> picto = img_picto ( $alt , $module -> picto , 'width="14px"' , 1 );
} else {
$newModule -> picto = img_object ( $alt , $module -> picto , 'width="14px"' );
}
} else {
2020-09-08 10:07:34 +02:00
$newModule -> picto = img_object ( $alt , 'generic' , 'width="14px"' );
}
$permission = array ();
2020-09-09 08:34:13 +02:00
if ( $module -> rights ) {
foreach ( $module -> rights as $rights ) {
if ( empty ( $rights [ 0 ])) {
2020-09-08 10:07:34 +02:00
continue ;
}
2024-03-07 20:16:48 +01:00
$arrayofpermissions [ $rights [ 0 ]] = array ( 'label' => 'user->hasRight(\'' . $module -> rights_class . '\', \'' . $rights [ 4 ] . '\'' . ( empty ( $rights [ 5 ]) ? '' : ', \'' . $rights [ 5 ] . '\'' ) . ')' );
2020-09-08 10:07:34 +02:00
$permission [] = $rights [ 0 ];
array_push ( $rights_ids , $rights [ 0 ]);
}
}
$newModule -> permission = $permission ;
// pre-filter list
2021-04-21 18:59:25 +02:00
if ( ! empty ( $search_name ) && ! stristr ( $newModule -> name , $search_name )) {
2021-02-26 22:04:03 +01:00
continue ;
}
2021-04-21 18:59:25 +02:00
if ( ! empty ( $search_version ) && ! stristr ( $newModule -> version , $search_version )) {
2021-02-26 22:04:03 +01:00
continue ;
}
2021-04-21 18:59:25 +02:00
if ( ! empty ( $search_id ) && ! stristr ( $newModule -> id , $search_id )) {
2021-02-26 22:04:03 +01:00
continue ;
}
2020-09-08 10:07:34 +02:00
2021-04-21 18:59:25 +02:00
if ( ! empty ( $search_permission )) {
2020-09-08 10:07:34 +02:00
$found = false ;
2020-09-09 08:34:13 +02:00
foreach ( $newModule -> permission as $permission ) {
if ( stristr ( $permission , $search_permission )) {
2020-09-08 10:07:34 +02:00
$found = true ;
break ;
}
}
2021-04-28 17:00:29 +02:00
if ( ! $found ) {
2021-02-26 22:04:03 +01:00
continue ;
}
2020-09-08 10:07:34 +02:00
}
$moduleList [] = $newModule ;
}
/*
* View
*/
llxHeader ();
2024-02-25 10:06:21 +01:00
print $info_admin ;
2020-09-08 10:07:34 +02:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="post" name="formulaire">' ;
2021-02-26 22:04:03 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2020-09-08 10:07:34 +02:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2021-04-21 18:59:25 +02:00
print_barre_liste ( $langs -> trans ( " AvailableModules " ), empty ( $page ) ? 0 : $page , $_SERVER [ " PHP_SELF " ], '' , $sortfield , $sortorder , '' , - 1 , '' , 'title_setup' , 0 , '' , '' , 0 , 1 , 1 );
2020-09-08 10:07:34 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " ToActivateModule " ) . '</span>' ;
print '<br>' ;
print '<br>' ;
2023-08-12 13:08:36 +02:00
$mode = '' ;
$arrayofmassactions = array ();
2020-09-08 10:07:34 +02:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
2024-04-30 09:45:28 +02:00
$htmlofselectarray = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage , getDolGlobalString ( 'MAIN_CHECKBOX_LEFT_COLUMN' )); // This also change content of $arrayfields with user setup
$selectedfields = ( $mode != 'kanban' ? $htmlofselectarray : '' );
2023-08-12 13:08:36 +02:00
$selectedfields .= ( count ( $arrayofmassactions ) ? $form -> showCheckAddButtons ( 'checkforselect' , 1 ) : '' );
$moreforfilter = '' ;
2020-09-08 10:07:34 +02:00
2017-01-17 20:04:41 +01:00
print '<div class="div-table-responsive-no-min">' ;
2023-08-12 13:08:36 +02:00
print '<table class="tagtable nobottomiftotal liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2020-09-08 10:07:34 +02:00
// Lines with input filters
print '<tr class="liste_titre_filter">' ;
2023-08-12 13:08:36 +02:00
// Action column
if ( getDolGlobalString ( 'MAIN_CHECKBOX_LEFT_COLUMN' )) {
print '<td class="liste_titre center maxwidthsearch">' ;
$searchpicto = $form -> showFilterButtons ();
print $searchpicto ;
print '</td>' ;
}
2020-09-09 08:34:13 +02:00
if ( $arrayfields [ 'name' ][ 'checked' ]) {
2020-09-08 10:07:34 +02:00
print '<td class="liste_titre left">' ;
2021-04-05 13:52:19 +02:00
print '<input class="flat" type="text" name="search_name" size="8" value="' . dol_escape_htmltag ( $search_name ) . '">' ;
2020-09-08 10:07:34 +02:00
print '</td>' ;
}
2020-09-09 08:34:13 +02:00
if ( $arrayfields [ 'version' ][ 'checked' ]) {
2020-09-08 10:07:34 +02:00
print '<td class="liste_titre left">' ;
2021-04-05 13:52:19 +02:00
print '<input class="flat" type="text" name="search_version" size="6" value="' . dol_escape_htmltag ( $search_version ) . '">' ;
2020-09-08 10:07:34 +02:00
print '</td>' ;
}
2020-09-09 08:34:13 +02:00
if ( $arrayfields [ 'id' ][ 'checked' ]) {
2020-09-08 10:07:34 +02:00
print '<td class="liste_titre left">' ;
2023-01-19 00:19:57 +01:00
print '<input class="flat" type="text" name="search_id" size="6" value="' . dol_escape_htmltag ( $search_id ) . '">' ;
2020-09-08 10:07:34 +02:00
print '</td>' ;
}
2021-04-05 13:52:19 +02:00
if ( $arrayfields [ 'permission' ][ 'checked' ]) {
2020-10-02 16:15:24 +02:00
print '<td class="liste_titre left">' ;
2021-04-05 13:52:19 +02:00
print '<input class="flat" type="text" name="search_permission" size="8" value="' . dol_escape_htmltag ( $search_permission ) . '">' ;
2020-10-02 16:15:24 +02:00
print '</td>' ;
}
2021-04-05 13:52:19 +02:00
if ( $arrayfields [ 'module_position' ][ 'checked' ]) {
2020-09-08 10:07:34 +02:00
print '<td class="liste_titre left">' ;
print '</td>' ;
}
2023-08-12 13:08:36 +02:00
// Action column
if ( ! getDolGlobalString ( 'MAIN_CHECKBOX_LEFT_COLUMN' )) {
print '<td class="liste_titre center maxwidthsearch">' ;
$searchpicto = $form -> showFilterButtons ();
print $searchpicto ;
print '</td>' ;
}
2020-09-08 10:07:34 +02:00
print '</tr>' ;
2008-10-12 13:41:13 +02:00
print '<tr class="liste_titre">' ;
2023-08-12 13:08:36 +02:00
// Action column
if ( getDolGlobalString ( 'MAIN_CHECKBOX_LEFT_COLUMN' )) {
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch actioncolumn' );
}
2020-09-09 08:34:13 +02:00
if ( $arrayfields [ 'name' ][ 'checked' ]) {
2020-09-08 10:07:34 +02:00
print_liste_field_titre ( $arrayfields [ 'name' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " name " , " " , " " , " " , $sortfield , $sortorder );
}
2020-09-09 08:34:13 +02:00
if ( $arrayfields [ 'version' ][ 'checked' ]) {
2020-09-08 10:07:34 +02:00
print_liste_field_titre ( $arrayfields [ 'version' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " version " , " " , " " , " " , $sortfield , $sortorder );
}
2020-09-09 08:34:13 +02:00
if ( $arrayfields [ 'id' ][ 'checked' ]) {
2021-04-05 13:52:19 +02:00
print_liste_field_titre ( $arrayfields [ 'id' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " id " , " " , " " , " " , $sortfield , $sortorder , 'nowraponall ' );
2020-10-02 16:15:24 +02:00
}
2020-09-09 08:34:13 +02:00
if ( $arrayfields [ 'permission' ][ 'checked' ]) {
2020-09-08 10:07:34 +02:00
print_liste_field_titre ( $arrayfields [ 'permission' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " permission " , " " , " " , " " , $sortfield , $sortorder );
}
2021-04-05 13:52:19 +02:00
if ( $arrayfields [ 'module_position' ][ 'checked' ]) {
print_liste_field_titre ( $arrayfields [ 'module_position' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " module_position " , " " , " " , " " , $sortfield , $sortorder );
}
2020-09-08 10:07:34 +02:00
// Fields from hook
2024-03-07 20:16:48 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
2020-09-08 10:07:34 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2023-08-12 13:08:36 +02:00
// Action column
if ( ! getDolGlobalString ( 'MAIN_CHECKBOX_LEFT_COLUMN' )) {
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' );
}
2008-10-12 13:41:13 +02:00
print '</tr>' ;
2020-09-08 10:07:34 +02:00
// sort list
2021-02-26 22:04:03 +01:00
if ( $sortfield == " name " && $sortorder == " asc " ) {
2024-03-14 21:59:15 +01:00
usort (
$moduleList ,
2024-03-15 16:40:04 +01:00
/** @return int */
2024-03-14 21:59:15 +01:00
function ( stdClass $a , stdClass $b ) {
return strcasecmp ( $a -> name , $b -> name );
}
);
2021-04-05 13:52:19 +02:00
} elseif ( $sortfield == " name " && $sortorder == " desc " ) {
2024-03-14 21:59:15 +01:00
usort (
$moduleList ,
2024-03-15 16:40:04 +01:00
/** @return int */
2024-03-14 21:59:15 +01:00
static function ( stdClass $a , stdClass $b ) {
return strcasecmp ( $b -> name , $a -> name );
}
);
2021-04-05 13:52:19 +02:00
} elseif ( $sortfield == " version " && $sortorder == " asc " ) {
2024-03-14 21:59:15 +01:00
usort (
$moduleList ,
2024-03-15 16:40:04 +01:00
/** @return int */
2024-03-14 21:59:15 +01:00
static function ( stdClass $a , stdClass $b ) {
return strcasecmp ( $a -> version , $b -> version );
}
);
2021-04-05 13:52:19 +02:00
} elseif ( $sortfield == " version " && $sortorder == " desc " ) {
2024-03-14 21:59:15 +01:00
usort (
$moduleList ,
2024-03-15 16:40:04 +01:00
/** @return int */
2024-03-14 21:59:15 +01:00
static function ( stdClass $a , stdClass $b ) {
return strcasecmp ( $b -> version , $a -> version );
}
);
2021-04-05 13:52:19 +02:00
} elseif ( $sortfield == " id " && $sortorder == " asc " ) {
2021-02-26 22:04:03 +01:00
usort ( $moduleList , " compareIdAsc " );
2021-04-05 13:52:19 +02:00
} elseif ( $sortfield == " id " && $sortorder == " desc " ) {
2021-02-26 22:04:03 +01:00
usort ( $moduleList , " compareIdDesc " );
2021-04-05 13:52:19 +02:00
} elseif ( $sortfield == " permission " && $sortorder == " asc " ) {
2021-02-26 22:04:03 +01:00
usort ( $moduleList , " comparePermissionIdsAsc " );
2021-04-05 13:52:19 +02:00
} elseif ( $sortfield == " permission " && $sortorder == " desc " ) {
2021-02-26 22:04:03 +01:00
usort ( $moduleList , " comparePermissionIdsDesc " );
2021-04-05 13:52:19 +02:00
} else {
$moduleList = dol_sort_array ( $moduleList , 'module_position' );
2021-02-26 22:04:03 +01:00
}
2020-09-08 10:07:34 +02:00
2020-09-09 08:34:13 +02:00
foreach ( $moduleList as $module ) {
2020-09-08 10:07:34 +02:00
print '<tr class="oddeven">' ;
2023-08-12 13:08:36 +02:00
// Action column
if ( getDolGlobalString ( 'MAIN_CHECKBOX_LEFT_COLUMN' )) {
print '<td></td>' ;
}
2020-09-08 10:07:34 +02:00
2020-09-09 08:34:13 +02:00
if ( $arrayfields [ 'name' ][ 'checked' ]) {
2020-09-08 10:07:34 +02:00
print '<td width="300" class="nowrap">' ;
print $module -> picto ;
print ' ' . $module -> name ;
print " </td> " ;
}
2020-09-08 10:13:56 +02:00
2020-09-09 08:34:13 +02:00
if ( $arrayfields [ 'version' ][ 'checked' ]) {
2021-04-30 15:22:17 +02:00
print '<td class="nowraponall">' . $module -> version . '</td>' ;
2020-09-08 10:07:34 +02:00
}
2020-09-09 08:34:13 +02:00
if ( $arrayfields [ 'id' ][ 'checked' ]) {
2020-09-08 10:07:34 +02:00
print '<td class="center">' . $module -> id . '</td>' ;
2020-03-23 15:54:02 +01:00
}
2020-09-08 10:07:34 +02:00
2020-09-09 08:34:13 +02:00
if ( $arrayfields [ 'permission' ][ 'checked' ]) {
2020-09-08 10:07:34 +02:00
$idperms = '' ;
2020-09-08 10:13:56 +02:00
2020-09-09 08:34:13 +02:00
foreach ( $module -> permission as $permission ) {
2020-09-08 10:07:34 +02:00
$translationKey = " Permission " . $permission ;
2021-10-02 19:45:58 +02:00
$labelpermission = $langs -> trans ( $translationKey );
$labelpermission .= ' : ' . $arrayofpermissions [ $permission ][ 'label' ];
$idperms .= ( $idperms ? " , " : " " ) . '<span title="' . $labelpermission . '">' . $permission . '</a>' ;
2020-09-09 08:34:13 +02:00
2023-10-24 17:00:13 +02:00
if ( getDolGlobalString ( 'MAIN_SHOW_PERMISSION' )) {
2020-09-09 15:39:47 +02:00
if ( empty ( $langs -> tab_translate [ $translationKey ])) {
$tooltip = 'Missing translation (key ' . $translationkey . ' not found in admin.lang)' ;
$idperms .= ' <img src="../../theme/eldy/img/warning.png" alt="Warning" title="' . $tooltip . '">' ;
}
2020-09-08 10:07:34 +02:00
}
2009-05-08 14:08:54 +02:00
}
2020-09-08 10:07:34 +02:00
2021-04-05 13:52:19 +02:00
print '<td><span class="opacitymedium">' . ( $idperms ? $idperms : " " ) . '</span></td>' ;
}
if ( $arrayfields [ 'module_position' ][ 'checked' ]) {
print '<td class="center">' . $module -> module_position . '</td>' ;
2009-05-08 14:08:54 +02:00
}
2020-09-08 10:07:34 +02:00
2023-08-12 13:08:36 +02:00
// Action column
if ( ! getDolGlobalString ( 'MAIN_CHECKBOX_LEFT_COLUMN' )) {
print '<td></td>' ;
}
2020-09-08 10:07:34 +02:00
print '</tr>' ;
2008-10-12 13:41:13 +02:00
}
2020-09-08 10:07:34 +02:00
2008-10-12 13:41:13 +02:00
print '</table>' ;
2017-01-17 20:04:41 +01:00
print '</div>' ;
2020-09-08 10:07:34 +02:00
print '</form>' ;
2008-10-12 13:41:13 +02:00
print '<br>' ;
2020-09-08 10:07:34 +02:00
2008-10-12 13:41:13 +02:00
sort ( $rights_ids );
2020-04-10 10:59:32 +02:00
$old = '' ;
2020-09-08 10:07:34 +02:00
2020-09-09 08:34:13 +02:00
foreach ( $rights_ids as $right_id ) {
if ( $old == $right_id ) {
2020-09-08 10:07:34 +02:00
print " Warning duplicate id on permission : " . $right_id . " <br> " ;
}
2009-05-08 14:08:54 +02:00
$old = $right_id ;
2008-10-12 13:41:13 +02:00
}
2018-07-28 14:29:28 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-08-02 10:07:55 +02:00
$db -> close ();
2020-09-08 10:07:34 +02:00
2024-03-07 20:16:48 +01:00
/**
* Compare two modules by their ID for a ascending order
*
* @ param stdClass $a First module
* @ param stdClass $b Second module
* @ return int Compare result ( - 1 , 0 , 1 )
*/
2020-09-09 08:34:13 +02:00
function compareIdAsc ( stdClass $a , stdClass $b )
2020-09-08 10:07:34 +02:00
{
2021-04-05 13:52:19 +02:00
if (( int ) $a -> id == ( int ) $b -> id ) {
2021-02-26 22:04:03 +01:00
return 0 ;
}
2020-09-09 08:34:13 +02:00
2021-04-05 13:52:19 +02:00
return (( int ) $a -> id < ( int ) $b -> id ) ? - 1 : 1 ;
2020-09-08 10:07:34 +02:00
}
2024-03-07 20:16:48 +01:00
/**
* Compare two modules by their ID for a descending order
*
* @ param stdClass $a First module
* @ param stdClass $b Second module
* @ return int Compare result ( - 1 , 0 , 1 )
*/
2020-09-09 08:34:13 +02:00
function compareIdDesc ( stdClass $a , stdClass $b )
2020-09-08 10:07:34 +02:00
{
2021-04-05 13:52:19 +02:00
if (( int ) $a -> id == ( int ) $b -> id ) {
2021-02-26 22:04:03 +01:00
return 0 ;
}
2020-09-09 08:34:13 +02:00
2021-04-05 13:52:19 +02:00
return (( int ) $b -> id < ( int ) $a -> id ) ? - 1 : 1 ;
2020-09-08 10:07:34 +02:00
}
2024-03-07 20:16:48 +01:00
/**
* Compare two modules by their ID for a ascending order
*
* @ param stdClass $a First module
* @ param stdClass $b Second module
* @ return int Compare result ( - 1 , 0 , 1 )
*/
2020-09-09 08:34:13 +02:00
function comparePermissionIdsAsc ( stdClass $a , stdClass $b )
2020-09-08 10:07:34 +02:00
{
2021-02-26 22:04:03 +01:00
if ( empty ( $a -> permission ) && empty ( $b -> permission )) {
return compareIdAsc ( $a , $b );
}
2020-09-08 10:07:34 +02:00
2021-02-26 22:04:03 +01:00
if ( empty ( $a -> permission )) {
return 1 ;
}
if ( empty ( $b -> permission )) {
return - 1 ;
}
2020-09-08 10:07:34 +02:00
2021-02-26 22:04:03 +01:00
if ( $a -> permission [ 0 ] == $b -> permission [ 0 ]) {
return 0 ;
}
2020-09-09 08:34:13 +02:00
2021-04-05 13:52:19 +02:00
return $a -> permission [ 0 ] < $b -> permission [ 0 ] ? - 1 : 1 ;
2020-09-08 10:07:34 +02:00
}
2024-03-07 20:16:48 +01:00
/**
* Compare two modules by their permissions for a descending order
*
* @ param stdClass $a First module
* @ param stdClass $b Second module
* @ return int Compare result ( - 1 , 0 , 1 )
*/
2020-09-09 08:34:13 +02:00
function comparePermissionIdsDesc ( stdClass $a , stdClass $b )
2020-09-08 10:07:34 +02:00
{
2021-02-26 22:04:03 +01:00
if ( empty ( $a -> permission ) && empty ( $b -> permission )) {
return compareIdDesc ( $a , $b );
}
2020-09-08 10:07:34 +02:00
2021-02-26 22:04:03 +01:00
if ( empty ( $a -> permission )) {
return - 1 ;
}
if ( empty ( $b -> permission )) {
return 1 ;
}
2020-09-08 10:07:34 +02:00
2021-02-26 22:04:03 +01:00
if ( $a -> permission [ 0 ] == $b -> permission [ 0 ]) {
return 0 ;
}
2020-09-09 08:34:13 +02:00
2021-04-05 13:52:19 +02:00
return $b -> permission [ 0 ] < $a -> permission [ 0 ] ? - 1 : 1 ;
2020-09-08 10:07:34 +02:00
}