Merge pull request #9048 from hregis/8.0_rights

NEW possibility to add all rights of all modules in one time
This commit is contained in:
Laurent Destailleur 2018-07-10 10:38:17 +02:00 committed by GitHub
commit 31d5b739e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 82 additions and 20 deletions

View File

@ -1203,8 +1203,11 @@ else
$res=$object->fetch_optionals();
// Check if user has rights
$object->getrights();
if (empty($object->nb_rights) && $object->statut != 0) setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings');
if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{
$object->getrights();
if (empty($object->nb_rights) && $object->statut != 0) setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings');
}
// Connexion ldap
// pour recuperer passDoNotExpire et userChangePassNextLogon

View File

@ -487,8 +487,15 @@ class User extends CommonObject
// Where pour la liste des droits a ajouter
if (! empty($allmodule))
{
$whereforadd="module='".$this->db->escape($allmodule)."'";
if (! empty($allperms)) $whereforadd.=" AND perms='".$this->db->escape($allperms)."'";
if ($allmodule == 'allmodules')
{
$whereforadd='allmodules';
}
else
{
$whereforadd="module='".$this->db->escape($allmodule)."'";
if (! empty($allperms)) $whereforadd.=" AND perms='".$this->db->escape($allperms)."'";
}
}
}
@ -498,8 +505,10 @@ class User extends CommonObject
//print "$module-$perms-$subperms";
$sql = "SELECT id";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE ".$whereforadd;
$sql.= " AND entity = ".$entity;
$sql.= " WHERE entity = ".$entity;
if (! empty($whereforadd) && $whereforadd != 'allmodules') {
$sql.= " AND ".$whereforadd;
}
$result=$this->db->query($sql);
if ($result)
@ -600,8 +609,18 @@ class User extends CommonObject
else {
// On a demande suppression d'un droit sur la base d'un nom de module ou perms
// Where pour la liste des droits a supprimer
if (! empty($allmodule)) $wherefordel="module='".$this->db->escape($allmodule)."'";
if (! empty($allperms)) $wherefordel=" AND perms='".$this->db->escape($allperms)."'";
if (! empty($allmodule))
{
if ($allmodule == 'allmodules')
{
$wherefordel='allmodules';
}
else
{
$wherefordel="module='".$this->db->escape($allmodule)."'";
if (! empty($allperms)) $whereforadd.=" AND perms='".$this->db->escape($allperms)."'";
}
}
}
// Suppression des droits selon critere defini dans wherefordel
@ -610,8 +629,10 @@ class User extends CommonObject
//print "$module-$perms-$subperms";
$sql = "SELECT id";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE $wherefordel";
$sql.= " AND entity = ".$entity;
$sql.= " WHERE entity = ".$entity;
if (! empty($wherefordel) && $wherefordel != 'allmodules') {
$sql.= " AND ".$wherefordel;
}
$result=$this->db->query($sql);
if ($result)

View File

@ -308,8 +308,18 @@ class UserGroup extends CommonObject
}
else {
// Where pour la liste des droits a ajouter
if (! empty($allmodule)) $whereforadd="module='".$this->db->escape($allmodule)."'";
if (! empty($allperms)) $whereforadd=" AND perms='".$this->db->escape($allperms)."'";
if (! empty($allmodule))
{
if ($allmodule == 'allmodules')
{
$whereforadd='allmodules';
}
else
{
$whereforadd="module='".$this->db->escape($allmodule)."'";
if (! empty($allperms)) $whereforadd.=" AND perms='".$this->db->escape($allperms)."'";
}
}
}
// Ajout des droits de la liste whereforadd
@ -318,8 +328,10 @@ class UserGroup extends CommonObject
//print "$module-$perms-$subperms";
$sql = "SELECT id";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE $whereforadd";
$sql.= " AND entity = ".$entity;
$sql.= " WHERE entity = ".$entity;
if (! empty($whereforadd) && $whereforadd != 'allmodules') {
$sql.= " AND ".$whereforadd;
}
$result=$this->db->query($sql);
if ($result)
@ -422,8 +434,18 @@ class UserGroup extends CommonObject
}
else {
// Where pour la liste des droits a supprimer
if (! empty($allmodule)) $wherefordel="module='".$this->db->escape($allmodule)."'";
if (! empty($allperms)) $wherefordel=" AND perms='".$this->db->escape($allperms)."'";
if (! empty($allmodule))
{
if ($allmodule == 'allmodules')
{
$wherefordel='allmodules';
}
else
{
$wherefordel="module='".$this->db->escape($allmodule)."'";
if (! empty($allperms)) $whereforadd.=" AND perms='".$this->db->escape($allperms)."'";
}
}
}
// Suppression des droits de la liste wherefordel
@ -432,8 +454,10 @@ class UserGroup extends CommonObject
//print "$module-$perms-$subperms";
$sql = "SELECT id";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE $wherefordel";
$sql.= " AND entity = ".$entity;
$sql.= " WHERE entity = ".$entity;
if (! empty($wherefordel) && $wherefordel != 'allmodules') {
$sql.= " AND ".$wherefordel;
}
$result=$this->db->query($sql);
if ($result)

View File

@ -231,7 +231,14 @@ if ($object->id > 0)
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>';
if ($caneditperms) print '<td width="24">&nbsp</td>';
if ($caneditperms)
{
print '<td align="center" class="nowrap">';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("All")."</a>";
print '/';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("None")."</a>";
print '</td>';
}
print '<td align="center" width="24">&nbsp;</td>';
print '<td>'.$langs->trans("Permissions").'</td>';
print '</tr>';

View File

@ -260,7 +260,14 @@ print "\n";
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>';
if ($caneditperms) print '<td>&nbsp</td>';
if ($caneditperms && empty($objMod->rights_admin_allowed) || empty($object->admin))
{
print '<td align="center" class="nowrap">';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("All")."</a>";
print '/';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("None")."</a>";
print '</td>';
}
print '<td align="center" width="24">&nbsp;</td>';
print '<td>'.$langs->trans("Permissions").'</td>';
print '</tr>'."\n";