Fix: mise en fonction de la vrification des droits d'accs users, clients et commerciaux
This commit is contained in:
parent
ade11f5a69
commit
537cd574f2
@ -38,7 +38,10 @@ require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php");
|
||||
$langs->load("categories");
|
||||
$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 = '';
|
||||
|
||||
|
||||
@ -54,47 +54,22 @@ if (isset($_GET["msg"])) { $mesg=urldecode($_GET["mesg"]); }
|
||||
$year=isset($_GET["year"])?$_GET["year"]:"";
|
||||
$month=isset($_GET["month"])?$_GET["month"]:"";
|
||||
|
||||
// Sécurité accés client
|
||||
$socid='';
|
||||
if ($_GET["socid"]) { $socid=$_GET["socid"]; }
|
||||
if ($user->societe_id > 0)
|
||||
if (isset($_GET["socid"]))
|
||||
{
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
$objectid=$_GET["socid"];
|
||||
$module='societe';
|
||||
$dbtable='';
|
||||
}
|
||||
if (!$user->rights->propale->lire) accessforbidden();
|
||||
if ($_GET['propalid'] > 0)
|
||||
else if (isset($_GET["propalid"]) && $_GET["propalid"] > 0)
|
||||
{
|
||||
$propal = new Propal($db);
|
||||
$result=$propal->fetch($_GET['propalid']);
|
||||
if (! $result > 0)
|
||||
{
|
||||
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
|
||||
$objectid=$_GET["propalid"];
|
||||
$module='propale';
|
||||
$dbtable='propal';
|
||||
}
|
||||
|
||||
// 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
|
||||
$NBLINES=4;
|
||||
|
||||
@ -749,6 +724,9 @@ if ($_GET['propalid'] > 0)
|
||||
*/
|
||||
|
||||
if ($mesg) print "$mesg<br>";
|
||||
|
||||
$propal = new Propal($db);
|
||||
$propal->fetch($_GET['propalid']);
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($propal->socid);
|
||||
|
||||
@ -1247,6 +1247,12 @@ function dol_loginfunction($notused,$pearstatus)
|
||||
function restrictedArea($user, $modulename, $objectid='', $dbtablename='', $list=0)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!$modulename)
|
||||
{
|
||||
$modulename = 'societe';
|
||||
$list = 1;
|
||||
}
|
||||
|
||||
$user->getrights($modulename);
|
||||
$user->getrights('commercial');
|
||||
@ -1255,7 +1261,7 @@ function dol_loginfunction($notused,$pearstatus)
|
||||
$nocreate = 0;
|
||||
|
||||
//si dbtable non défini, même nom que le module
|
||||
if (!$dbtable) $dbtablename = $modulename;
|
||||
if (!$dbtablename) $dbtablename = $modulename;
|
||||
|
||||
if (!$user->rights->$modulename->lire)
|
||||
{
|
||||
@ -1275,6 +1281,8 @@ function dol_loginfunction($notused,$pearstatus)
|
||||
$_GET["action"] = '';
|
||||
$_POST["action"] = '';
|
||||
$socid = $user->societe_id;
|
||||
if (!$objectid) $objectid = $socid;
|
||||
if ($modulename == 'societe' && $socid <> $objectid) accessforbidden();
|
||||
}
|
||||
|
||||
if ($objectid)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user