Page of permissions is cleaner now
This commit is contained in:
parent
f5129c87d2
commit
8ab96447c7
@ -35,6 +35,8 @@ $action = GETPOST('action', 'aZ09');
|
|||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) accessforbidden();
|
||||||
|
|
||||||
|
$entity=$conf->entity;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
@ -70,14 +72,12 @@ print '<span class="opacitymedium">'.$langs->trans("DefaultRightsDesc")." ".$lan
|
|||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
// Charge les modules soumis a permissions
|
// Search all modules with permission and reload permissions def.
|
||||||
$modules = array();
|
$modules = array();
|
||||||
$modulesdir = dolGetModulesDirs();
|
$modulesdir = dolGetModulesDirs();
|
||||||
|
|
||||||
foreach ($modulesdir as $dir)
|
foreach ($modulesdir as $dir)
|
||||||
{
|
{
|
||||||
// Load modules attributes in arrays (name, numero, orders) from dir directory
|
|
||||||
//print $dir."\n<br>";
|
|
||||||
$handle = @opendir(dol_osencode($dir));
|
$handle = @opendir(dol_osencode($dir));
|
||||||
if (is_resource($handle))
|
if (is_resource($handle))
|
||||||
{
|
{
|
||||||
@ -102,7 +102,7 @@ foreach ($modulesdir as $dir)
|
|||||||
// Load all permissions
|
// Load all permissions
|
||||||
if ($objMod->rights_class)
|
if ($objMod->rights_class)
|
||||||
{
|
{
|
||||||
$ret = $objMod->insert_permissions(0);
|
$ret = $objMod->insert_permissions(0, $entity);
|
||||||
$modules[$objMod->rights_class] = $objMod;
|
$modules[$objMod->rights_class] = $objMod;
|
||||||
//print "modules[".$objMod->rights_class."]=$objMod;";
|
//print "modules[".$objMod->rights_class."]=$objMod;";
|
||||||
}
|
}
|
||||||
@ -122,35 +122,58 @@ dol_fiche_head($head, 'default', $langs->trans("Security"), -1);
|
|||||||
// Show warning about external users
|
// Show warning about external users
|
||||||
print info_admin(showModulesExludedForExternal($modules)).'<br>'."\n";
|
print info_admin(showModulesExludedForExternal($modules)).'<br>'."\n";
|
||||||
|
|
||||||
|
print "\n";
|
||||||
print '<div class="div-table-responsive-no-min">';
|
print '<div class="div-table-responsive-no-min">';
|
||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
|
|
||||||
// Show permissions lines
|
print '<tr class="liste_titre">';
|
||||||
$sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault";
|
print '<td>'.$langs->trans("Module").'</td>';
|
||||||
|
print '<td class="center"> </td>';
|
||||||
|
print '<td class="center">'.$langs->trans("Default").'</td>';
|
||||||
|
print '<td>'.$langs->trans("Permissions").'</td>';
|
||||||
|
print '</tr>'."\n";
|
||||||
|
|
||||||
|
//print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS;
|
||||||
|
$sql = "SELECT r.id, r.libelle as label, r.module, r.module_position, r.perms, r.subperms, r.bydefault";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
||||||
$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
|
$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
|
||||||
$sql .= " AND entity = ".$conf->entity;
|
$sql .= " AND r.entity = ".$entity;
|
||||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
|
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
|
||||||
$sql .= " ORDER BY r.module, r.id";
|
$sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id";
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$oldmod = "";
|
$oldmod = '';
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
|
|
||||||
// Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore
|
// If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it
|
||||||
if (!$modules[$obj->module])
|
if (empty($modules[$obj->module]))
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save field module_position in database if value is still zero
|
||||||
|
if (empty($obj->module_position))
|
||||||
|
{
|
||||||
|
if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0))
|
||||||
|
{
|
||||||
|
// TODO Define familyposition
|
||||||
|
$family = $modules[$obj->module]->family_position;
|
||||||
|
$familyposition = 0;
|
||||||
|
$sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".$modules[$obj->module]->module_position.",";
|
||||||
|
$sqlupdate.= " family_position = ".$familyposition;
|
||||||
|
$sqlupdate.= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'";
|
||||||
|
$db->query($sqlupdate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if permission we found is inside a module definition. If not, we discard it.
|
// Check if permission we found is inside a module definition. If not, we discard it.
|
||||||
$found = false;
|
$found = false;
|
||||||
foreach ($modules[$obj->module]->rights as $key => $val)
|
foreach ($modules[$obj->module]->rights as $key => $val)
|
||||||
@ -169,49 +192,65 @@ if ($result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Break found, it's a new module to catch
|
// Break found, it's a new module to catch
|
||||||
if ($oldmod <> $obj->module)
|
if (isset($obj->module) && ($oldmod <> $obj->module))
|
||||||
{
|
{
|
||||||
$oldmod = $obj->module;
|
$oldmod = $obj->module;
|
||||||
|
|
||||||
|
// Break detected, we get objMod
|
||||||
$objMod = $modules[$obj->module];
|
$objMod = $modules[$obj->module];
|
||||||
$picto = ($objMod->picto ? $objMod->picto : 'generic');
|
$picto = ($objMod->picto ? $objMod->picto : 'generic');
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
// Show break line
|
||||||
print '<td>'.$langs->trans("Module").'</td>';
|
print '<tr class="oddeven trforbreak">';
|
||||||
print '<td>'.$langs->trans("Permission").'</td>';
|
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
|
||||||
print '<td class="center">'.$langs->trans("Default").'</td>';
|
print img_object('', $picto, 'class="pictoobjectwidth"').' '.$objMod->getName();
|
||||||
print '<td align="center"> </td>';
|
print '<a name="'.$objMod->getName().'"></a>';
|
||||||
print "</tr>\n";
|
print '</td>';
|
||||||
|
print '<td> </td>';
|
||||||
|
print '<td> </td>';
|
||||||
|
print '<td> </td>';
|
||||||
|
print '</tr>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$perm_libelle = ($conf->global->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) : $obj->label));
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td>';
|
|
||||||
print img_object('', $picto, 'class="pictoobjectwidth"').' '.$objMod->getName();
|
// Picto and label of module
|
||||||
print '<a name="'.$objMod->getName().'"> </a>';
|
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
|
||||||
|
//print img_object('', $picto, 'class="pictoobjectwidth"').' '.$objMod->getName();
|
||||||
|
//print '<a name="'.$objMod->getName().'"> </a>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
$perm_libelle = ($conf->global->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) : $obj->libelle));
|
// Tick
|
||||||
|
if ($obj->bydefault == 1)
|
||||||
|
{
|
||||||
|
print '<td>';
|
||||||
|
print '<a class="reposition" href="perms.php?pid='.$obj->id.'&action=remove">'.img_edit_remove().'</a>';
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="center">';
|
||||||
|
print img_picto($langs->trans("Active"), 'tick');
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<td>';
|
||||||
|
print '<a class="reposition" href="perms.php?pid='.$obj->id.'&action=add">'.img_edit_add().'</a>';
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="center">';
|
||||||
|
print ' ';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Permission and tick
|
||||||
print '<td>'.$perm_libelle.'</td>';
|
print '<td>'.$perm_libelle.'</td>';
|
||||||
|
|
||||||
print '<td class="center">';
|
print '</tr>'."\n";
|
||||||
if ($obj->bydefault == 1)
|
|
||||||
{
|
|
||||||
print img_picto($langs->trans("Active"), 'tick');
|
|
||||||
print '</td><td>';
|
|
||||||
print '<a class="reposition" href="perms.php?pid='.$obj->id.'&action=remove">'.img_edit_remove().'</a>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print ' ';
|
|
||||||
print '</td><td>';
|
|
||||||
print '<a class="reposition" href="perms.php?pid='.$obj->id.'&action=add">'.img_edit_add().'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</td></tr>';
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else dol_print_error($db);
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|||||||
@ -77,7 +77,7 @@ $entity=$conf->entity;
|
|||||||
$hookmanager->initHooks(array('usercard','userperms','globalcard'));
|
$hookmanager->initHooks(array('usercard','userperms','globalcard'));
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ foreach($modulesdir as $dir)
|
|||||||
// Load all permissions
|
// Load all permissions
|
||||||
if ($objMod->rights_class)
|
if ($objMod->rights_class)
|
||||||
{
|
{
|
||||||
$ret=$objMod->insert_permissions(0, $entity);
|
$ret = $objMod->insert_permissions(0, $entity);
|
||||||
$modules[$objMod->rights_class]=$objMod;
|
$modules[$objMod->rights_class]=$objMod;
|
||||||
//print "modules[".$objMod->rights_class."]=$objMod;";
|
//print "modules[".$objMod->rights_class."]=$objMod;";
|
||||||
}
|
}
|
||||||
@ -271,8 +271,9 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
|
|||||||
|
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive-no-min">';
|
||||||
print '<table width="100%" class="noborder">';
|
print '<table class="noborder centpercent">';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>'.$langs->trans("Module").'</td>';
|
print '<td>'.$langs->trans("Module").'</td>';
|
||||||
if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin))
|
if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin))
|
||||||
@ -295,7 +296,7 @@ $sql = "SELECT r.id, r.libelle as label, r.module, r.module_position";
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
||||||
$sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
|
$sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
|
||||||
$sql.= " AND r.entity = " . $entity;
|
$sql.= " AND r.entity = " . $entity;
|
||||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable
|
if (empty($conf->global->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";
|
$sql.= " ORDER BY r.family_position, r.module_position, r.module, r.id";
|
||||||
|
|
||||||
$result=$db->query($sql);
|
$result=$db->query($sql);
|
||||||
@ -370,7 +371,9 @@ if ($result)
|
|||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
|
|
||||||
// Picto and label of module
|
// Picto and label of module
|
||||||
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">'.img_object('', $picto, 'class="pictoobjectwidth"').' '.$objMod->getName().'</td>';
|
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
|
||||||
|
//print img_object('', $picto, 'class="pictoobjectwidth"').' '.$objMod->getName();
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
// Permission and tick
|
// Permission and tick
|
||||||
if (! empty($object->admin) && ! empty($objMod->rights_admin_allowed)) // Permission granted because admin
|
if (! empty($object->admin) && ! empty($objMod->rights_admin_allowed)) // Permission granted because admin
|
||||||
@ -393,7 +396,6 @@ if ($result)
|
|||||||
print img_picto($langs->trans("Active"), 'tick');
|
print img_picto($langs->trans("Active"), 'tick');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif (is_array($permsgroupbyentity[$entity]))
|
elseif (is_array($permsgroupbyentity[$entity]))
|
||||||
{
|
{
|
||||||
if (in_array($obj->id, $permsgroupbyentity[$entity])) // Permission granted by group
|
if (in_array($obj->id, $permsgroupbyentity[$entity])) // Permission granted by group
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user