Fix: mise en fonction de la vrification des droits d'accs users, clients et commerciaux

This commit is contained in:
Regis Houssin 2007-06-21 17:28:38 +00:00
parent ade11f5a69
commit 537cd574f2
3 changed files with 27 additions and 38 deletions

View File

@ -38,7 +38,10 @@ require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php");
$langs->load("categories"); $langs->load("categories");
$langs->load("companies"); $langs->load("companies");
if (!$user->rights->societe->lire) accessforbidden(); $socid = isset($_GET["socid"])?$_GET["socid"]:'';
// Sécurité d'accès client et commerciaux
$socid = restrictedArea($user, 'societe', $socid);
$mesg = ''; $mesg = '';

View File

@ -54,47 +54,22 @@ if (isset($_GET["msg"])) { $mesg=urldecode($_GET["mesg"]); }
$year=isset($_GET["year"])?$_GET["year"]:""; $year=isset($_GET["year"])?$_GET["year"]:"";
$month=isset($_GET["month"])?$_GET["month"]:""; $month=isset($_GET["month"])?$_GET["month"]:"";
// Sécurité accés client if (isset($_GET["socid"]))
$socid='';
if ($_GET["socid"]) { $socid=$_GET["socid"]; }
if ($user->societe_id > 0)
{ {
$action = ''; $objectid=$_GET["socid"];
$socid = $user->societe_id; $module='societe';
$dbtable='';
} }
if (!$user->rights->propale->lire) accessforbidden(); else if (isset($_GET["propalid"]) && $_GET["propalid"] > 0)
if ($_GET['propalid'] > 0)
{ {
$propal = new Propal($db); $objectid=$_GET["propalid"];
$result=$propal->fetch($_GET['propalid']); $module='propale';
if (! $result > 0) $dbtable='propal';
{
dolibarr_print_error($db,$propal->error);
exit;
}
// Protection restriction commercial
if ($user->societe_id > 0)
{
// Si externe, on autorise que ses propres infos
if ($propal->socid <> $user->societe_id) accessforbidden();
}
else if (!$user->rights->commercial->client->voir)
{
// Si interne et pas les droits de voir tous les clients, on autorise que si liés
$sql = "SELECT sc.fk_soc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE sc.fk_soc = ".$propal->socid." AND sc.fk_user = ".$user->id;
if ( $db->query($sql) )
{
if ( $db->num_rows() == 0)
{
accessforbidden();
}
}
}
// Fin de Protection restriction commercial
} }
// Sécurité d'accès client et commerciaux
$socid = restrictedArea($user, $module, $objectid, $dbtable);
// Nombre de ligne pour choix de produit/service prédéfinis // Nombre de ligne pour choix de produit/service prédéfinis
$NBLINES=4; $NBLINES=4;
@ -750,6 +725,9 @@ if ($_GET['propalid'] > 0)
if ($mesg) print "$mesg<br>"; if ($mesg) print "$mesg<br>";
$propal = new Propal($db);
$propal->fetch($_GET['propalid']);
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($propal->socid); $societe->fetch($propal->socid);

View File

@ -1248,6 +1248,12 @@ function dol_loginfunction($notused,$pearstatus)
{ {
global $db; global $db;
if (!$modulename)
{
$modulename = 'societe';
$list = 1;
}
$user->getrights($modulename); $user->getrights($modulename);
$user->getrights('commercial'); $user->getrights('commercial');
@ -1255,7 +1261,7 @@ function dol_loginfunction($notused,$pearstatus)
$nocreate = 0; $nocreate = 0;
//si dbtable non défini, même nom que le module //si dbtable non défini, même nom que le module
if (!$dbtable) $dbtablename = $modulename; if (!$dbtablename) $dbtablename = $modulename;
if (!$user->rights->$modulename->lire) if (!$user->rights->$modulename->lire)
{ {
@ -1275,6 +1281,8 @@ function dol_loginfunction($notused,$pearstatus)
$_GET["action"] = ''; $_GET["action"] = '';
$_POST["action"] = ''; $_POST["action"] = '';
$socid = $user->societe_id; $socid = $user->societe_id;
if (!$objectid) $objectid = $socid;
if ($modulename == 'societe' && $socid <> $objectid) accessforbidden();
} }
if ($objectid) if ($objectid)