Fix: bug on projects visibility for external users

This commit is contained in:
Laurent Destailleur 2012-05-23 13:09:36 +02:00
parent e1767d1337
commit c6c9861bff
3 changed files with 19 additions and 10 deletions

View File

@ -322,7 +322,7 @@ abstract class CommonObject
$tab=array(); $tab=array();
$sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id"; $sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id"; // This field contains id of llx_socpeople or id of llx_user
if ($source == 'internal') $sql.=", '-1' as socid"; if ($source == 'internal') $sql.=", '-1' as socid";
if ($source == 'external' || $source == 'thirdparty') $sql.=", t.fk_soc as socid"; if ($source == 'external' || $source == 'thirdparty') $sql.=", t.fk_soc as socid";
$sql.= ", t.civilite as civility, t.name as lastname, t.firstname, t.email"; $sql.= ", t.civilite as civility, t.name as lastname, t.firstname, t.email";

View File

@ -785,7 +785,13 @@ class Project extends CommonObject
$nblinks = 0; $nblinks = 0;
while ($nblinks < $num) while ($nblinks < $num)
{ {
if (preg_match('/PROJECT/', $userRole[$nblinks]['code']) && $user->id == $userRole[$nblinks]['id']) if ($source == 'internal' && preg_match('/PROJECT/', $userRole[$nblinks]['code']) && $user->id == $userRole[$nblinks]['id'])
{
if ($mode == 'read' && $user->rights->projet->lire) $userAccess++;
if ($mode == 'write' && $user->rights->projet->creer) $userAccess++;
if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++;
}
if ($source == 'external' && preg_match('/PROJECT/', $userRole[$nblinks]['code']) && $user->contact_id == $userRole[$nblinks]['id'])
{ {
if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; if ($mode == 'read' && $user->rights->projet->lire) $userAccess++;
if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; if ($mode == 'write' && $user->rights->projet->creer) $userAccess++;
@ -838,14 +844,14 @@ class Project extends CommonObject
//$sql.= " OR p.fk_user_creat = ".$user->id; //$sql.= " OR p.fk_user_creat = ".$user->id;
$sql.= " OR ( ctc.rowid = ec.fk_c_type_contact"; $sql.= " OR ( ctc.rowid = ec.fk_c_type_contact";
$sql.= " AND ctc.element = '" . $this->element . "'"; $sql.= " AND ctc.element = '" . $this->element . "'";
$sql.= " AND ec.fk_socpeople = " . $user->id . " ) )"; $sql.= " AND ec.fk_socpeople = " . $user->contact_id . " ) )";
} }
if ($mode == 1) if ($mode == 1)
{ {
$sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ec.element_id = p.rowid";
$sql.= " AND ctc.rowid = ec.fk_c_type_contact"; $sql.= " AND ctc.rowid = ec.fk_c_type_contact";
$sql.= " AND ctc.element = '" . $this->element . "'"; $sql.= " AND ctc.element = '" . $this->element . "'";
$sql.= " AND ec.fk_socpeople = " . $user->id; $sql.= " AND ec.fk_socpeople = " . $user->contact_id;
} }
if ($mode == 2) if ($mode == 2)
{ {

View File

@ -66,8 +66,11 @@ class User extends CommonObject
var $datec; var $datec;
var $datem; var $datem;
//! If this is defined, it is an external user //! If this is defined, it is an external user
var $societe_id; var $societe_id;
var $contact_id;
var $fk_member; var $fk_member;
var $webcal_login; var $webcal_login;