New: Utilisation de niveaux plus fin des droits de compta sur le même modèles que les autres modules (Lire, Modifier...).
Optim: La fonction de chargement des droits n'est réalisée qu'une fois même si appelé plusieurs fois.
This commit is contained in:
parent
e4e996518f
commit
2341e994db
@ -27,7 +27,7 @@ require("../../chargesociales.class.php");
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$user->getrights('compta');
|
$user->getrights('compta');
|
||||||
if (!$user->rights->compta->resultat)
|
if (!$user->rights->compta->resultat->lire)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|||||||
@ -26,7 +26,7 @@ require("./pre.inc.php");
|
|||||||
*/
|
*/
|
||||||
$user->getrights('compta');
|
$user->getrights('compta');
|
||||||
|
|
||||||
if (!$user->rights->compta->resultat)
|
if (!$user->rights->compta->resultat->lire)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|||||||
@ -28,7 +28,7 @@ require("../../chargesociales.class.php");
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$user->getrights('compta');
|
$user->getrights('compta');
|
||||||
if (!$user->rights->compta->resultat)
|
if (!$user->rights->compta->resultat->lire)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|||||||
@ -27,7 +27,7 @@ require("../../chargesociales.class.php");
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$user->getrights('compta');
|
$user->getrights('compta');
|
||||||
if (!$user->rights->compta->resultat)
|
if (!$user->rights->compta->resultat->lire)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
global $PHP_SELF;
|
global $PHP_SELF;
|
||||||
|
|
||||||
|
|
||||||
$nbofentries=0;
|
$nbofentries=0;
|
||||||
if ($conf->commercial->enabled) $nbofentries++;
|
if ($conf->commercial->enabled) $nbofentries++;
|
||||||
if ($conf->adherent->enabled) $nbofentries++;
|
if ($conf->adherent->enabled) $nbofentries++;
|
||||||
@ -45,7 +46,7 @@ else {
|
|||||||
if ($_SESSION["topmenu"] && $_SESSION["topmenu"] == "commercial") { $class="menusel"; }
|
if ($_SESSION["topmenu"] && $_SESSION["topmenu"] == "commercial") { $class="menusel"; }
|
||||||
elseif (ereg("^".DOL_URL_ROOT."\/comm\/",$PHP_SELF)) { $class="menusel"; }
|
elseif (ereg("^".DOL_URL_ROOT."\/comm\/",$PHP_SELF)) { $class="menusel"; }
|
||||||
print '<td class="'.$class.'" width="'.$widthtd.'%" align=center>';
|
print '<td class="'.$class.'" width="'.$widthtd.'%" align=center>';
|
||||||
print '<a class="'.$class.'" href="'.DOL_URL_ROOT.'/comm/index.php">Commercial</A>';
|
print '<a class="'.$class.'" href="'.DOL_URL_ROOT.'/comm/index.php"'.($target?" target=$target":"").'>Commercial</A>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ else {
|
|||||||
if ($_SESSION["topmenu"] && $_SESSION["topmenu"] == "adherent") { $class="menusel"; }
|
if ($_SESSION["topmenu"] && $_SESSION["topmenu"] == "adherent") { $class="menusel"; }
|
||||||
elseif (ereg("^".DOL_URL_ROOT."\/adherents\/",$PHP_SELF)) { $class="menusel"; }
|
elseif (ereg("^".DOL_URL_ROOT."\/adherents\/",$PHP_SELF)) { $class="menusel"; }
|
||||||
print '<td class="'.$class.'" width="'.$widthtd.'%" align=center>';
|
print '<td class="'.$class.'" width="'.$widthtd.'%" align=center>';
|
||||||
print '<a class="'.$class.'" href="'.DOL_URL_ROOT.'/adherents/index.php">Adhérents</A>';
|
print '<a class="'.$class.'" href="'.DOL_URL_ROOT.'/adherents/index.php"'.($target?" target=$target":"").'>Adhérents</A>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ else {
|
|||||||
if ($_SESSION["topmenu"] && $_SESSION["topmenu"] == "compta") { $class="menusel"; }
|
if ($_SESSION["topmenu"] && $_SESSION["topmenu"] == "compta") { $class="menusel"; }
|
||||||
elseif (ereg("^".DOL_URL_ROOT."\/compta\/",$PHP_SELF)) { $class="menusel"; }
|
elseif (ereg("^".DOL_URL_ROOT."\/compta\/",$PHP_SELF)) { $class="menusel"; }
|
||||||
print '<td class="'.$class.'" width="'.$widthtd.'%" align=center>';
|
print '<td class="'.$class.'" width="'.$widthtd.'%" align=center>';
|
||||||
print '<a class="'.$class.'" href="'.DOL_URL_ROOT.'/compta/index.php">Compta</A>';
|
print '<a class="'.$class.'" href="'.DOL_URL_ROOT.'/compta/index.php"'.($target?" target=$target":"").'>Compta</A>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ else {
|
|||||||
if ($conf->produit->enabled && $conf->service->enabled) { $chaine.="/"; }
|
if ($conf->produit->enabled && $conf->service->enabled) { $chaine.="/"; }
|
||||||
if ($conf->service->enabled) { $chaine.="Services"; }
|
if ($conf->service->enabled) { $chaine.="Services"; }
|
||||||
print '<td class="'.$class.'" width="'.$widthtd.'%" align=center>';
|
print '<td class="'.$class.'" width="'.$widthtd.'%" align=center>';
|
||||||
print '<a class="'.$class.'" href="'.DOL_URL_ROOT.'/product/?type=0">'.$chaine.'</a>';
|
print '<a class="'.$class.'" href="'.DOL_URL_ROOT.'/product/?type=0"'.($target?" target=$target":"").'>'.$chaine.'</a>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,9 +88,10 @@ else {
|
|||||||
{
|
{
|
||||||
$class="";
|
$class="";
|
||||||
if ($_SESSION["topmenu"] && $_SESSION["topmenu"] == "webcalendar") { $class="menusel"; }
|
if ($_SESSION["topmenu"] && $_SESSION["topmenu"] == "webcalendar") { $class="menusel"; }
|
||||||
elseif (ereg("^".DOL_URL_ROOT."\/webcalendar\/",$PHP_SELF)) { $class="menusel"; }
|
elseif (ereg("^".DOL_URL_ROOT."\/projet\/",$PHP_SELF) || ereg("^".DOL_URL_ROOT."\/webcalendar\/",$PHP_SELF)) { $class="menusel"; }
|
||||||
print '<td class="'.$class.'" width="'.$widthtd.'%" align=center>';
|
print '<td class="'.$class.'" width="'.$widthtd.'%" align=center>';
|
||||||
print '<a class="'.$class.'" href="'. PHPWEBCALENDAR_URL .'">Calendrier</a>';
|
// print '<a class="'.$class.'" href="'. PHPWEBCALENDAR_URL .'">Calendrier</a>';
|
||||||
|
print '<a class="'.$class.'" href="'.DOL_URL_ROOT.'/projet/webcal.php"'.($target?" target=$target":"").'>Calendrier</a>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -61,9 +61,10 @@ class modBanque extends DolibarrModules
|
|||||||
* Permissions
|
* Permissions
|
||||||
*/
|
*/
|
||||||
$sql = array(
|
$sql = array(
|
||||||
"insert into ".MAIN_DB_PREFIX."rights_def values (111,'Lire les comptes','banque','a',1);",
|
"insert into ".MAIN_DB_PREFIX."rights_def values (110,'Tous les droits sur les comptes bancaires','banque','a',0);",
|
||||||
"insert into ".MAIN_DB_PREFIX."rights_def values (112,'Modifier les comptes','banque','a',0);",
|
"insert into ".MAIN_DB_PREFIX."rights_def values (111,'Lire les comptes','banque','r',1);",
|
||||||
"insert into ".MAIN_DB_PREFIX."rights_def values (113,'Configurer les comptes','banque','a',0);",
|
"insert into ".MAIN_DB_PREFIX."rights_def values (112,'Créer modifier rapprocher écritures','banque','w',0);",
|
||||||
|
"insert into ".MAIN_DB_PREFIX."rights_def values (113,'Configurer les comptes (créer, gérer catégories)','banque','w',0);",
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->_init($sql);
|
return $this->_init($sql);
|
||||||
|
|||||||
@ -64,8 +64,12 @@ class modComptabilite extends DolibarrModules
|
|||||||
* Permissions
|
* Permissions
|
||||||
*/
|
*/
|
||||||
$sql = array(
|
$sql = array(
|
||||||
"insert into ".MAIN_DB_PREFIX."rights_def values (92,'Gestion charges','compta','a',1);",
|
"insert into ".MAIN_DB_PREFIX."rights_def values (90,'Tous les droits sur la compta','compta','a',0);",
|
||||||
"insert into ".MAIN_DB_PREFIX."rights_def values (93,'Gestion resultat','compta','a',1);",
|
"insert into ".MAIN_DB_PREFIX."rights_def values (91,'Lire les charges','compta','r',1);",
|
||||||
|
"insert into ".MAIN_DB_PREFIX."rights_def values (92,'Créer modifier les charges','compta','w',0);",
|
||||||
|
"insert into ".MAIN_DB_PREFIX."rights_def values (93,'Supprimer les charges','compta','d',0);",
|
||||||
|
|
||||||
|
"insert into ".MAIN_DB_PREFIX."rights_def values (95,'Lire CA, bilans, résultats','compta','r',1);",
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->_init($sql);
|
return $this->_init($sql);
|
||||||
|
|||||||
@ -63,21 +63,21 @@ border-right: 1px solid #000000;
|
|||||||
border-bottom: 1px solid #000000;
|
border-bottom: 1px solid #000000;
|
||||||
}
|
}
|
||||||
td.menusel {
|
td.menusel {
|
||||||
border-left: 1px solid #FFFFFF;
|
border-left: 1px solid #333344;
|
||||||
border-right: 1px solid #FFFFFF;
|
border-right: 1px solid #FFFFFF;
|
||||||
border-top: 1px solid #FFFFFF;
|
border-top: 1px solid #333344;
|
||||||
border-bottom: 1px solid #FFFFFF;
|
border-bottom: 1px solid #FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu {
|
.menu {
|
||||||
background: #b3c5cc;
|
background: #b3c5cc;
|
||||||
font-size: 12px; font-weight: bold;
|
font-size: 12px;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
.menusel
|
.menusel
|
||||||
{
|
{
|
||||||
background: #96B9C9;
|
background: #a8bdc0;
|
||||||
font-size: 12px; font-weight: bold;
|
font-size: 12px; font-weight: bold;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@ -259,7 +259,7 @@ font: helvetica, verdana, arial, sans-serif;
|
|||||||
tr.box_titre {
|
tr.box_titre {
|
||||||
background: #7699A9;
|
background: #7699A9;
|
||||||
color: #334444;
|
color: #334444;
|
||||||
font: helvetica, verdana, arial, sans-serif;
|
font: 12px helvetica, verdana, arial, sans-serif;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
border-left: 1px solid #FFFFFF;
|
border-left: 1px solid #FFFFFF;
|
||||||
border-right: 1px solid #FFFFFF;
|
border-right: 1px solid #FFFFFF;
|
||||||
@ -270,12 +270,12 @@ white-space: nowrap;
|
|||||||
|
|
||||||
tr.box_impair {
|
tr.box_impair {
|
||||||
background: #e2ebed;
|
background: #e2ebed;
|
||||||
font: helvetica, verdana, arial, sans-serif;
|
font: 12px helvetica, verdana, arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.box_pair {
|
tr.box_pair {
|
||||||
background: #c0d5dd;
|
background: #c0d5dd;
|
||||||
font: helvetica, verdana, arial, sans-serif;
|
font: 12px helvetica, verdana, arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.fiche {
|
tr.fiche {
|
||||||
|
|||||||
@ -49,15 +49,8 @@ class User
|
|||||||
$this->compta = 1;
|
$this->compta = 1;
|
||||||
$this->limite_liste = 0;
|
$this->limite_liste = 0;
|
||||||
|
|
||||||
$this->rights->facture->lire = 0;
|
$this->permissions_are_loaded = 0;
|
||||||
$this->rights->facture->creer = 0;
|
|
||||||
$this->rights->facture->modifier = 0;
|
|
||||||
$this->rights->facture->supprimer = 0;
|
|
||||||
|
|
||||||
$this->rights->produit->lire = 0;
|
|
||||||
$this->rights->produit->creer = 0;
|
|
||||||
$this->rights->produit->modifier = 0;
|
|
||||||
$this->rights->produit->supprimer = 0;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -192,13 +185,15 @@ class User
|
|||||||
*/
|
*/
|
||||||
Function getrights($module='')
|
Function getrights($module='')
|
||||||
{
|
{
|
||||||
|
if ($this->permissions_are_loaded) {
|
||||||
|
// Si les permissions ont déja été chargé pour ce user, on quitte
|
||||||
|
// Cela évite de faire n fois le select quand la fonction est appelée plusieurs fois
|
||||||
|
// pour charger les droits de différents modules. On les charges tous la
|
||||||
|
// première fois, puis on ne fait plus rien.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT fk_user, fk_id FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user= $this->id";
|
$sql = "SELECT fk_user, fk_id FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user= $this->id";
|
||||||
/*
|
|
||||||
if ($module)
|
|
||||||
{
|
|
||||||
$sql .= " AND module = '$module'";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
$rr=array();
|
$rr=array();
|
||||||
@ -339,12 +334,20 @@ class User
|
|||||||
|
|
||||||
if ($module == 'compta' or $module == '')
|
if ($module == 'compta' or $module == '')
|
||||||
{
|
{
|
||||||
|
if ($obj->fk_id == 91)
|
||||||
|
$this->rights->compta->charges->lire = 1;
|
||||||
|
|
||||||
if ($obj->fk_id == 92)
|
if ($obj->fk_id == 92)
|
||||||
$this->rights->compta->charges = 1;
|
$this->rights->compta->charges->creer = 1;
|
||||||
|
|
||||||
if ($obj->fk_id == 93)
|
if ($obj->fk_id == 93)
|
||||||
$this->rights->compta->resultat = 1;
|
$this->rights->compta->charges->supprimer = 1;
|
||||||
|
|
||||||
|
if ($obj->fk_id == 95)
|
||||||
|
$this->rights->compta->resultat->lire = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($module == 'banque' or $module == '')
|
if ($module == 'banque' or $module == '')
|
||||||
{
|
{
|
||||||
if ($obj->fk_id == 111)
|
if ($obj->fk_id == 111)
|
||||||
@ -359,7 +362,10 @@ class User
|
|||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
// $this->db->free();
|
|
||||||
|
$this->db->free();
|
||||||
|
|
||||||
|
$this->permissions_are_loaded=1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -452,7 +458,6 @@ class User
|
|||||||
*/
|
*/
|
||||||
Function delete()
|
Function delete()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->contact_id)
|
if ($this->contact_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,9 @@ print_titre("Liste des utilisateurs");
|
|||||||
|
|
||||||
$sql = "SELECT u.rowid, u.name, u.firstname, u.code, u.login, u.module_comm, u.module_compta";
|
$sql = "SELECT u.rowid, u.name, u.firstname, u.code, u.login, u.module_comm, u.module_compta";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||||
$sql .= " ORDER BY u.name";
|
$sql .= " ORDER BY ";
|
||||||
|
if ($sortfield) { $sql.="$sortfield $sortorder"; }
|
||||||
|
else { $sql.="u.name"; }
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
@ -35,12 +37,20 @@ if ($result)
|
|||||||
$num = $db->num_rows();
|
$num = $db->num_rows();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
|
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
|
||||||
print '<TR class="liste_titre">';
|
print '<TR class="liste_titre">';
|
||||||
print "<TD>Prenom</TD>";
|
print "<TD>";
|
||||||
print "<TD>Nom</TD>";
|
print_liste_field_titre("Nom",$PHP_SELF,"name");
|
||||||
print '<TD>login</TD>';
|
print "</TD>";
|
||||||
print "<TD>code</TD>";
|
print "<TD>";
|
||||||
|
print_liste_field_titre("Prénom",$PHP_SELF,"firstname");
|
||||||
|
print "</TD>";
|
||||||
|
print "<TD>";
|
||||||
|
print_liste_field_titre("Login",$PHP_SELF,"login");
|
||||||
|
print "</TD>";
|
||||||
|
print "<TD>";
|
||||||
|
print_liste_field_titre("Code",$PHP_SELF,"code");
|
||||||
|
print "</TD>";
|
||||||
print "</TR>\n";
|
print "</TR>\n";
|
||||||
$var=True;
|
$var=True;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
@ -49,9 +59,13 @@ if ($result)
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
print "<TR $bc[$var]>";
|
print "<TR $bc[$var]>";
|
||||||
print '<TD><a href="fiche.php?id='.$obj->rowid.'">'.$obj->firstname.'</a></td>';
|
print '<TD>'.ucfirst($obj->name).'</TD>';
|
||||||
print '<TD>'.$obj->name.'</TD>';
|
print '<TD>'.ucfirst($obj->firstname).'</td>';
|
||||||
print '<TD><a href="fiche.php?id='.$obj->rowid.'">'.$obj->login.'</a></TD>';
|
if ($obj->login) {
|
||||||
|
print '<TD><a href="fiche.php?id='.$obj->rowid.'">'.$obj->login.'</a></TD>';
|
||||||
|
} else {
|
||||||
|
print '<TD><a class="impayee" href="fiche.php?id='.$obj->rowid.'">Inactif</a></TD>';
|
||||||
|
}
|
||||||
print '<TD>'.$obj->code.'</TD>';
|
print '<TD>'.$obj->code.'</TD>';
|
||||||
print "</TR>\n";
|
print "</TR>\n";
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user