NEW possibility to add all rights of all modules in one time

This commit is contained in:
Regis Houssin 2018-07-03 21:46:20 +02:00
parent d4d9a8d75a
commit ca13d7b560
4 changed files with 78 additions and 19 deletions

View File

@ -135,7 +135,7 @@ class User extends CommonObject
public $default_c_exp_tax_cat;
public $default_range;
public $fields=array(
'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'),
@ -484,8 +484,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)."'";
}
}
}
@ -495,8 +502,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)
@ -597,8 +606,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
@ -607,8 +626,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";