diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 12c6aa82cf9..27044699600 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -14186,12 +14186,14 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
$class = "dropdown-item";
} else {
$class = 'butAction';
- if ($actionType == 'email') {
+ if ($actionType == 'edit') {
+ $class = 'butAction butActionEdit';
+ } elseif ($actionType == 'email') {
$class = 'butAction butActionEmail';
} elseif ($actionType == 'clone') {
$class = 'butAction butActionClone';
} elseif ($actionType == 'danger' || $actionType == 'delete') {
- $class = 'butActionDelete';
+ $class = 'butAction butActionDelete';
if (!empty($url) && strpos($url, 'token=') === false) {
$url .= '&token=' . newToken();
}
diff --git a/htdocs/theme/md/btn.inc.php b/htdocs/theme/md/btn.inc.php
index fd3bf91c046..4913900ee3f 100644
--- a/htdocs/theme/md/btn.inc.php
+++ b/htdocs/theme/md/btn.inc.php
@@ -247,9 +247,7 @@ span.butActionNewRefused>span.fa, span.butActionNewRefused>span.fa:hover
.butActionDelete, .butActionDelete:link, .butActionDelete:visited, .butActionDelete:hover, .butActionDelete:active, .buttonDelete {
background: var(--butactiondeletebg);
- /* border: 1px solid #633; */
- color: #633;
- /* vertical-align: middle; */
+ color: #633 !important;
}
.butActionDelete:hover {
diff --git a/htdocs/theme/md/dropdown.inc.php b/htdocs/theme/md/dropdown.inc.php
index 9351c2fb972..9d228c4573e 100644
--- a/htdocs/theme/md/dropdown.inc.php
+++ b/htdocs/theme/md/dropdown.inc.php
@@ -302,9 +302,10 @@ a.top-menu-dropdown-link {
text-align: start;
}
-
+.dropdown-menu > .user-body {
+ padding: 15px;
+}
.dropdown-menu > .user-body, .dropdown-body{
- /* padding: 15px; */
border-bottom: 1px solid #f4f4f4;
border-top: 1px solid #f0f0f0;
white-space: normal;
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 4535bee9b99..e3c1b3eb5e8 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -2233,7 +2233,7 @@ tr.nobottom td {
.maxwidth40 { max-width: 40px; }
.maxwidth50 { max-width: 50px; }
.maxwidth75 { max-width: 75px; }
-.maxwidthdate { max-width: 105px; }
+.maxwidthdate { max-width: 90px; }
.maxwidth100 { max-width: 100px; }
.maxwidth125 { max-width: 125px; }
.maxwidth150 { max-width: 150px; }
diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php
index 4f8a6e56c9c..922f8b4f744 100644
--- a/htdocs/user/group/perms.php
+++ b/htdocs/user/group/perms.php
@@ -150,452 +150,531 @@ $title = $object->name." - ".$langs->trans('Permissions');
$help_url = '';
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-user page-group_perms');
-if ($object->id > 0) {
- $head = group_prepare_head($object);
- $title = $langs->trans("Group");
- print dol_get_fiche_head($head, 'rights', $title, -1, 'group');
+if ($object->id <= 0) {
+ accessforbidden('Group not found');
+}
- // Charge les modules soumis a permissions
- $modules = array();
- $modulesdir = dolGetModulesDirs();
+$head = group_prepare_head($object);
+$title = $langs->trans("Group");
+print dol_get_fiche_head($head, 'rights', $title, -1, 'group');
- $db->begin();
+// Charge les modules soumis a permissions
+$modules = array();
+$modulesdir = dolGetModulesDirs();
- foreach ($modulesdir as $dir) {
- $handle = @opendir(dol_osencode($dir));
- 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') {
- $modName = substr($file, 0, dol_strlen($file) - 10);
+$db->begin();
- if ($modName) {
- include_once $dir.$file;
- $objMod = new $modName($db);
- '@phan-var-force DolibarrModules $objMod';
- // Load all lang files of module
- if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
- foreach ($objMod->langfiles as $domain) {
- $langs->load($domain);
- }
- }
- // Load all permissions
- if ($objMod->rights_class) {
- $ret = $objMod->insert_permissions(0, $entity);
- $modules[$objMod->rights_class] = $objMod;
+foreach ($modulesdir as $dir) {
+ $handle = @opendir(dol_osencode($dir));
+ 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') {
+ $modName = substr($file, 0, dol_strlen($file) - 10);
+
+ if ($modName) {
+ include_once $dir.$file;
+ $objMod = new $modName($db);
+ '@phan-var-force DolibarrModules $objMod';
+ /** @var DolibarrModules $objMod */
+
+ // Load all lang files of module
+ if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
+ foreach ($objMod->langfiles as $domain) {
+ $langs->load($domain);
}
}
+ // Load all permissions
+ if ($objMod->rights_class) {
+ $objMod->insert_permissions(0, $entity);
+ $modules[$objMod->rights_class] = $objMod;
+ }
}
}
}
}
+}
- $db->commit();
+$db->commit();
- // Read permissions of group
- $permsgroupbyentity = array();
+// Read permissions of group
+$permsgroupbyentity = array();
- $sql = "SELECT DISTINCT r.id, r.libelle, r.module, gr.entity";
- $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r,";
- $sql .= " ".MAIN_DB_PREFIX."usergroup_rights as gr";
- $sql .= " WHERE gr.fk_id = r.id";
- $sql .= " AND gr.entity = ".((int) $entity);
- $sql .= " AND gr.fk_usergroup = ".((int) $object->id);
+$sql = "SELECT DISTINCT r.id, r.libelle, r.module, r.perms, r.subperms, r.module_position, r.family, r.family_position, gr.entity";
+$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r,";
+$sql .= " ".MAIN_DB_PREFIX."usergroup_rights as gr";
+$sql .= " WHERE gr.fk_id = r.id";
+$sql .= " AND gr.entity = ".((int) $entity);
+$sql .= " AND gr.fk_usergroup = ".((int) $object->id);
- dol_syslog("get user perms", LOG_DEBUG);
- $result = $db->query($sql);
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- while ($i < $num) {
- $obj = $db->fetch_object($result);
- if (!isset($permsgroupbyentity[$obj->entity])) {
- $permsgroupbyentity[$obj->entity] = array();
- }
- array_push($permsgroupbyentity[$obj->entity], $obj->id);
- $i++;
+dol_syslog("get user perms", LOG_DEBUG);
+$result = $db->query($sql);
+if ($result) {
+ $num = $db->num_rows($result);
+ $i = 0;
+ while ($i < $num) {
+ $obj = $db->fetch_object($result);
+ if (!isset($permsgroupbyentity[$obj->entity])) {
+ $permsgroupbyentity[$obj->entity] = array();
}
- $db->free($result);
+ array_push($permsgroupbyentity[$obj->entity], $obj->id);
+ $i++;
+ }
+ $db->free($result);
+} else {
+ dol_print_error($db);
+}
+
+/*
+ * Part to add/remove permissions
+ */
+
+$linkback = ''.$langs->trans("BackToList").' ';
+
+dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin);
+
+
+print '
';
+print '
';
+
+print '
';
+print '
';
+
+// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)
+if (isModEnabled('multicompany')) {
+ print ''.$langs->trans("Name").' ';
+ print ''.dol_escape_htmltag($object->name);
+ if (empty($object->entity)) {
+ print img_picto($langs->trans("GlobalGroup"), 'superadmin');
+ }
+ print " \n";
+}
+
+// Multicompany
+if (isModEnabled('multicompany') && is_object($mc) && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && $user->admin && !$user->entity) {
+ $mc->getInfo($object->entity);
+ print "".''.$langs->trans("Entity").' ';
+ print ''.dol_escape_htmltag($mc->label);
+ print " \n";
+}
+
+unset($object->fields['nom']); // Name already displayed in banner
+unset($object->fields['color']);
+
+// Common attributes
+$keyforbreak = '';
+include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
+
+print ''.$langs->trans("ColorGroup").' ';
+print '';
+print $formother->showColor($object->color, '');
+print ' ';
+
+// Other attributes
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
+
+print '
';
+
+print '
';
+print '
';
+
+print '
';
+
+print ' ';
+
+
+if ($user->admin) {
+ $s = $langs->trans("WarningOnlyPermissionOfActivatedModules")." ".$langs->trans("YouCanEnableModulesFrom");
+ if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
+ $s .= ' ';
+ $s .= img_picto($langs->trans('InfoAdmin'), 'info-circle').' ';
+ $s .= $langs->trans("YouAreUsingTheAdvancedPermissionsMode");
} else {
- dol_print_error($db);
+ $s .= ' ';
+ $s .= img_picto($langs->trans('InfoAdmin'), 'info-circle').' ';
+ $s .= $langs->trans("YouAreUsingTheSimplePermissionsMode");
}
-
- /*
- * Part to add/remove permissions
- */
-
- $linkback = ''.$langs->trans("BackToList").' ';
-
- dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin);
-
-
- print '';
- print '
';
-
- print '
';
- print '
';
-
- // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)
- if (isModEnabled('multicompany')) {
- print ''.$langs->trans("Name").' ';
- print ''.dol_escape_htmltag($object->name);
- if (empty($object->entity)) {
- print img_picto($langs->trans("GlobalGroup"), 'superadmin');
- }
- print " \n";
- }
-
- // Multicompany
- if (isModEnabled('multicompany') && is_object($mc) && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && $user->admin && !$user->entity) {
- $mc->getInfo($object->entity);
- print "".''.$langs->trans("Entity").' ';
- print ''.dol_escape_htmltag($mc->label);
- print " \n";
- }
-
- unset($object->fields['nom']); // Name already displayed in banner
- unset($object->fields['color']);
-
- // Common attributes
- $keyforbreak = '';
- include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
-
- print ''.$langs->trans("ColorGroup").' ';
- print '';
- print $formother->showColor($object->color, '');
- print ' ';
-
- // Other attributes
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
-
- print '
';
-
- print '
';
- print '
';
-
- print '
';
+ print info_admin($s);
print ' ';
+}
+$parameters = array();
+$reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
- if ($user->admin) {
- $s = $langs->trans("WarningOnlyPermissionOfActivatedModules")." ".$langs->trans("YouCanEnableModulesFrom");
- if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
- $s .= ' ';
- $s .= img_picto($langs->trans('InfoAdmin'), 'info-circle').' ';
- $s .= $langs->trans("YouAreUsingTheAdvancedPermissionsMode");
- } else {
- $s .= ' ';
- $s .= img_picto($langs->trans('InfoAdmin'), 'info-circle').' ';
- $s .= $langs->trans("YouAreUsingTheSimplePermissionsMode");
+print "\n";
+print '';
+print '
';
+print '';
+print ''.$langs->trans("Module").' ';
+if ($permissiontoedit) {
+ print '';
+ print 'id.'&action=addrights&token='.newToken().'&entity='.$entity.'&module=allmodules&confirm=yes">'.$langs->trans("All")." ";
+ print '/';
+ print 'id.'&action=delrights&&token='.newToken().'&entity='.$entity.'&module=allmodules&confirm=yes">'.$langs->trans("None")." ";
+ print ' ';
+} else {
+ print ' ';
+}
+print ' ';
+print '';
+print ''.img_picto('', 'folder-open', 'class="paddingright"').''.$langs->trans("ExpandAll").' ';
+print ' | ';
+print ''.img_picto('', 'folder', 'class="paddingright"').''.$langs->trans("UndoExpandAll").' ';
+print ' ';
+print ' '."\n";
+
+// Get list of all permissions
+$sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault, r.family, r.family_position";
+$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
+$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // We ignore permission "tous les tiers". Why ?
+$sql .= " AND r.entity = ".((int) $entity);
+if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
+ $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
+}
+$sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id";
+
+$familyinfo = array(
+ 'hr' => array('position' => '001', 'label' => $langs->trans("ModuleFamilyHr")),
+ 'crm' => array('position' => '006', 'label' => $langs->trans("ModuleFamilyCrm")),
+ 'srm' => array('position' => '007', 'label' => $langs->trans("ModuleFamilySrm")),
+ 'financial' => array('position' => '009', 'label' => $langs->trans("ModuleFamilyFinancial")),
+ 'products' => array('position' => '012', 'label' => $langs->trans("ModuleFamilyProducts")),
+ 'projects' => array('position' => '015', 'label' => $langs->trans("ModuleFamilyProjects")),
+ 'ecm' => array('position' => '018', 'label' => $langs->trans("ModuleFamilyECM")),
+ 'technic' => array('position' => '021', 'label' => $langs->trans("ModuleFamilyTechnic")),
+ 'portal' => array('position' => '040', 'label' => $langs->trans("ModuleFamilyPortal")),
+ 'interface' => array('position' => '050', 'label' => $langs->trans("ModuleFamilyInterface")),
+ 'base' => array('position' => '060', 'label' => $langs->trans("ModuleFamilyBase")),
+ 'other' => array('position' => '100', 'label' => $langs->trans("ModuleFamilyOther")),
+);
+
+$arrayofpermission = array();
+$cookietohidegroup = (empty($_COOKIE["DOLUSER_PERMS_HIDE_GRP"]) ? '' : preg_replace('/^,/', '', $_COOKIE["DOLUSER_PERMS_HIDE_GRP"]));
+$cookietohidegrouparray = explode(',', $cookietohidegroup);
+
+$result = $db->query($sql);
+if ($result) {
+ $num = $db->num_rows($result);
+ $i = 0;
+
+ //var_dump($cookietohidegrouparray);
+
+ while ($i < $num) {
+ $obj = $db->fetch_object($result);
+
+ if (empty($obj->family)) {
+ $obj->family = 'other';
}
- print info_admin($s);
- print ' ';
+ if (empty($obj->family_position)) {
+ $obj->family_position = $familyinfo[$obj->family]['position'];
+ if ($obj->module_position < 100000) {
+ $obj->module_position = intval($obj->module_position) + 100000;
+ } else {
+ $obj->module_position = intval($obj->module_position);
+ }
+ }
+
+ $obj->position = $obj->family_position.'_'.$obj->module_position.'_'.$obj->id;
+
+ $arrayofpermission[$i] = $obj;
+ $i++;
+ }
+} else {
+ dol_print_error($db);
+}
+
+$arrayofpermission = dol_sort_array($arrayofpermission, 'position');
+
+$j = 0;
+$oldmod = '';
+
+foreach ($arrayofpermission as $i => $obj) {
+ // If line is for a module that does not exist anymore (absent of includes/module), we ignore it
+ if (empty($modules[$obj->module])) {
+ $i++;
+ continue;
}
- $parameters = array();
- $reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ // Special cases
+ if (isModEnabled("reception")) {
+ // The 2 permission in fournisseur modules has been replaced by permissions into reception module
+ if ($obj->module == 'fournisseur' && $obj->perms == 'commande' && $obj->subperms == 'receptionner') {
+ $i++;
+ continue;
+ }
+ if ($obj->module == 'fournisseur' && $obj->perms == 'commande_advance' && $obj->subperms == 'check') {
+ $i++;
+ continue;
+ }
}
- print "\n";
- print '';
- print '
';
- print '';
- print ''.$langs->trans("Module").' ';
- if ($permissiontoedit) {
- print '';
- print 'id.'&action=addrights&token='.newToken().'&entity='.$entity.'&module=allmodules&confirm=yes">'.$langs->trans("All")." ";
- print '/';
- print 'id.'&action=delrights&&token='.newToken().'&entity='.$entity.'&module=allmodules&confirm=yes">'.$langs->trans("None")." ";
+ $objMod = $modules[$obj->module];
+
+ if (GETPOSTISSET('forbreakperms_'.$obj->module)) {
+ $ishidden = GETPOSTINT('forbreakperms_'.$obj->module);
+ } elseif (in_array($j, $cookietohidegrouparray)) { // If j is among list of hidden group
+ $ishidden = 1;
+ } else {
+ $ishidden = 0;
+ }
+ $isexpanded = ! $ishidden;
+ //var_dump("isexpanded=".$isexpanded);
+
+ $permsgroupbyentitypluszero = array();
+ if (!empty($permsgroupbyentity[0])) {
+ $permsgroupbyentitypluszero = array_merge($permsgroupbyentitypluszero, $permsgroupbyentity[0]);
+ }
+ if (!empty($permsgroupbyentity[$entity])) {
+ $permsgroupbyentitypluszero = array_merge($permsgroupbyentitypluszero, $permsgroupbyentity[$entity]);
+ }
+ //var_dump($permsgroupbyentitypluszero);
+
+ // Break found, it's a new module to catch
+ if (isset($obj->module) && ($oldmod != $obj->module)) {
+ $oldmod = $obj->module;
+
+ $j++;
+ if (GETPOSTISSET('forbreakperms_'.$obj->module)) {
+ $ishidden = GETPOSTINT('forbreakperms_'.$obj->module);
+ } elseif (in_array($j, $cookietohidegrouparray)) { // If j is among list of hidden group
+ $ishidden = 1;
+ } else {
+ $ishidden = 0;
+ }
+ $isexpanded = ! $ishidden;
+ //var_dump('$obj->module='.$obj->module.' isexpanded='.$isexpanded);
+
+ // Break detected, we get objMod
+ $objMod = $modules[$obj->module];
+ $picto = ($objMod->picto ? $objMod->picto : 'generic');
+
+ // Show break line
+ print ' ';
+ // Picto and label of module
+ print '';
+ print ' ';
+ print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName();
+ print ' ';
+ print ' ';
+
+ // Permission and tick (2 columns)
+ if ($permissiontoedit) {
+ print '';
+ print '';
+ print 'id.'&action=addrights&token='.newToken().'&entity='.$entity.'&module='.$obj->module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("All")." ";
+ print ' / ';
+ print 'id.'&action=delrights&token='.newToken().'&entity='.$entity.'&module='.$obj->module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("None")." ";
+ print ' ';
+ print ' ';
+ print '';
+ print ' ';
+ } else {
+ print ' ';
+ print ' ';
+ }
+ // Description of permission (2 columns)
+ print ' ';
+ print '';
+ print '';
+ print img_picto('', 'folder', 'class="marginright"');
+ print '
';
+ print '';
+ print img_picto('', 'folder-open', 'class="marginright"');
+ print '
';
+ print ' '; //Add picto + / - when open en closed
+ print ' '."\n";
+ }
+
+ $permlabel = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && ($langs->trans("PermissionAdvanced".$obj->id) != "PermissionAdvanced".$obj->id) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != "Permission".$obj->id) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label)));
+
+ print ''."\n";
+ print '';
+
+
+ // Picto and label of module
+ print '';
+ print ' ';
+
+ // Permission and tick (2 columns)
+ if (isset($permsgroupbyentitypluszero) && is_array($permsgroupbyentitypluszero)) {
+ print '';
+ if (in_array($obj->id, $permsgroupbyentitypluszero)) {
+ // Own permission by group
+ if ($permissiontoedit) {
+ print '';
+ print 'id.'&action=delrights&token='.newToken().'&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&updatedmodulename='.$obj->module.'">';
+ //print img_edit_remove($langs->trans("Remove"));
+ print img_picto($langs->trans("Remove"), 'switch_on');
+ print ' ';
+ print ' ';
+ } else {
+ print ' ';
+ }
+ print '';
+ print img_picto($langs->trans("Active"), 'tick');
+ print ' ';
+ } else {
+ // Do not own permission
+ if ($permissiontoedit) {
+ print '';
+ print 'id.'&action=addrights&token='.newToken().'&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&updatedmodulename='.$obj->module.'">';
+ //print img_edit_add($langs->trans("Add"));
+ print img_picto($langs->trans("Add"), 'switch_off');
+ print ' ';
+ print ' ';
+ } else {
+ print ' ';
+ }
+ print '';
+ print ' ';
+ }
+ } else {
+ // Do not own permission
+ print '';
+ if ($permissiontoedit) {
+ print '';
+ print 'id.'&action=addrights&token='.newToken().'&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&updatedmodulename='.$obj->module.'">';
+ //print img_edit_add($langs->trans("Add"));
+ print img_picto($langs->trans("Add"), 'switch_off');
+ print ' ';
+ } else {
+ print ' ';
+ }
+ print '';
+ print ' ';
+ }
+
+ // Description of permission (1 or 2 columns)
+ print '';
+ print $permlabel;
+ $idtouse = $obj->id;
+ if (in_array($idtouse, array(121, 122, 125, 126))) { // Force message for the 3 permission on third parties
+ $idtouse = 122;
+ }
+ if ($langs->trans("Permission".$idtouse.'b') != "Permission".$idtouse.'b') {
+ print ''.$langs->trans("Permission".$idtouse.'b').' ';
+ }
+ if ($langs->trans("Permission".$obj->id.'c') != "Permission".$obj->id.'c') {
+ print ''.$langs->trans("Permission".$obj->id.'c').' ';
+ }
+ if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
+ if (preg_match('/_advance$/', $obj->perms)) {
+ print ' ('.$langs->trans("AdvancedModeOnly").') ';
+ }
+ }
+ print ' ';
+
+ // Permission id
+ if ($user->admin) {
+ print '';
+ $htmltext = $langs->trans("ID").': '.$obj->id;
+ $htmltext .= ' '.$langs->trans("Permission").': user->hasRight(\''.dol_escape_htmltag($obj->module).'\', \''.dol_escape_htmltag($obj->perms).'\''.($obj->subperms ? ', \''.dol_escape_htmltag($obj->subperms).'\'' : '').')';
+ print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block marginrightonly');
+ //print ''.$obj->id.' ';
print ' ';
} else {
print ' ';
}
- print ' ';
- print '';
- print ''.img_picto('', 'folder-open', 'class="paddingright"').''.$langs->trans("ExpandAll").' ';
- print ' | ';
- print ''.img_picto('', 'folder', 'class="paddingright"').''.$langs->trans("UndoExpandAll").' ';
- print ' ';
+
print ' '."\n";
- $sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";
- $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
- $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
- $sql .= " AND r.entity = ".((int) $entity);
- if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
- $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
- }
- $sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id";
-
- $result = $db->query($sql);
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- $j = 0;
- $oldmod = '';
-
- $cookietohidegroup = (empty($_COOKIE["DOLUSER_PERMS_HIDE_GRP"]) ? '' : preg_replace('/^,/', '', $_COOKIE["DOLUSER_PERMS_HIDE_GRP"]));
- $cookietohidegrouparray = explode(',', $cookietohidegroup);
-
- while ($i < $num) {
- $obj = $db->fetch_object($result);
-
- // If line is for a module that does not exist anymore (absent of includes/module), we ignore it
- if (empty($modules[$obj->module])) {
- $i++;
- continue;
- }
-
- $objMod = $modules[$obj->module];
-
- if (GETPOSTISSET('forbreakperms_'.$obj->module)) {
- $ishidden = GETPOSTINT('forbreakperms_'.$obj->module);
- } elseif (in_array($j, $cookietohidegrouparray)) { // If j is among list of hidden group
- $ishidden = 1;
- } else {
- $ishidden = 0;
- }
- $isexpanded = ! $ishidden;
-
- // Break found, it's a new module to catch
- if (isset($obj->module) && ($oldmod != $obj->module)) {
- $oldmod = $obj->module;
-
- $j++;
- if (GETPOSTISSET('forbreakperms_'.$obj->module)) {
- $ishidden = GETPOSTINT('forbreakperms_'.$obj->module);
- } elseif (in_array($j, $cookietohidegrouparray)) { // If j is among list of hidden group
- $ishidden = 1;
- } else {
- $ishidden = 0;
- }
- $isexpanded = ! $ishidden;
- // Break detected, we get objMod
- $objMod = $modules[$obj->module];
- $picto = ($objMod->picto ? $objMod->picto : 'generic');
-
- // Show break line
- print '';
- // Picto and label of module
- print '';
- print ' ';
- print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName();
- print ' ';
- print ' ';
-
- // Permission and tick (2 columns)
- if ($permissiontoedit) {
- print '';
- print '';
- print 'id.'&action=addrights&token='.newToken().'&entity='.$entity.'&module='.$obj->module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("All")." ";
- print ' / ';
- print 'id.'&action=delrights&token='.newToken().'&entity='.$entity.'&module='.$obj->module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("None")." ";
- print ' ';
- print ' ';
- print '';
- print ' ';
- } else {
- print ' ';
- print ' ';
- }
- // Description of permission (2 columns)
- print ' ';
- print '';
- print '';
- print img_picto('', 'folder', 'class="marginright"');
- print '
';
- print '';
- print img_picto('', 'folder-open', 'class="marginright"');
- print '
';
- print ' '; //Add picto + / - when open en closed
- print ' '."\n";
- }
-
- $permlabel = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && ($langs->trans("PermissionAdvanced".$obj->id) != "PermissionAdvanced".$obj->id) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != "Permission".$obj->id) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label)));
-
- print ''."\n";
- print '';
-
-
- // Picto and label of module
- print '';
- print ' ';
-
- // Permission and tick (2 columns)
- if (!empty($permsgroupbyentity[$entity]) && is_array($permsgroupbyentity[$entity])) {
- if (in_array($obj->id, $permsgroupbyentity[$entity])) {
- // Own permission by group
- if ($permissiontoedit) {
- print '';
- print 'id.'&action=delrights&token='.newToken().'&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&updatedmodulename='.$obj->module.'">';
- //print img_edit_remove($langs->trans("Remove"));
- print img_picto($langs->trans("Remove"), 'switch_on');
- print ' ';
- print ' ';
- } else {
- print ' ';
- }
- print '';
- print img_picto($langs->trans("Active"), 'tick');
- print ' ';
- } else {
- // Do not own permission
- if ($permissiontoedit) {
- print '';
- print 'id.'&action=addrights&token='.newToken().'&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&updatedmodulename='.$obj->module.'">';
- //print img_edit_add($langs->trans("Add"));
- print img_picto($langs->trans("Add"), 'switch_off');
- print ' ';
- print ' ';
- } else {
- print ' ';
- }
- print ' ';
- }
- } else {
- // Do not own permission
- if ($permissiontoedit) {
- print '';
- print 'id.'&action=addrights&token='.newToken().'&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&updatedmodulename='.$obj->module.'">';
- //print img_edit_add($langs->trans("Add"));
- print img_picto($langs->trans("Add"), 'switch_off');
- print ' ';
- } else {
- print ' ';
- }
- print ' ';
- }
-
- // Description of permission (1 column)
- print '';
- print $permlabel;
- $idtouse = $obj->id;
- if (in_array($idtouse, array(121, 122, 125, 126))) { // Force message for the 3 permission on third parties
- $idtouse = 122;
- }
- if ($langs->trans("Permission".$idtouse.'b') != "Permission".$idtouse.'b') {
- print ''.$langs->trans("Permission".$idtouse.'b').' ';
- }
- if ($langs->trans("Permission".$obj->id.'c') != "Permission".$obj->id.'c') {
- print ''.$langs->trans("Permission".$obj->id.'c').' ';
- }
- if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
- if (preg_match('/_advance$/', $obj->perms)) {
- print ' ('.$langs->trans("AdvancedModeOnly").') ';
- }
- }
- print ' ';
-
- // Permission id
- if ($user->admin) {
- print '';
- $htmltext = $langs->trans("ID").': '.$obj->id;
- $htmltext .= ' '.$langs->trans("Permission").': user->hasRight(\''.dol_escape_htmltag($obj->module).'\', \''.dol_escape_htmltag($obj->perms).'\''.($obj->subperms ? ', \''.dol_escape_htmltag($obj->subperms).'\'' : '').')';
- print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block marginrightonly');
- //print ''.$obj->id.' ';
- print ' ';
- } else {
- print ' ';
- }
-
- print ' '."\n";
-
- $i++;
- }
- }
- print '
';
- print '
';
-
- print '';
-
- print '';
-
- $parameters = array();
- $reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
-
- print dol_get_fiche_end();
+ $i++;
}
+print '
';
+print '
';
+
+print '';
+
+print '';
+
+$parameters = array();
+$reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
+
+print dol_get_fiche_end();
+
+
// End of page
llxFooter();
$db->close();