Fix: add function to sort project authorized for a user
This commit is contained in:
parent
0ded40ad3e
commit
e6b06fd6b4
@ -109,7 +109,8 @@ print "</table>";
|
|||||||
print '</td><td width="70%" valign="top" class="notopnoleft">';
|
print '</td><td width="70%" valign="top" class="notopnoleft">';
|
||||||
|
|
||||||
$projectsIdArray=array();
|
$projectsIdArray=array();
|
||||||
$projectsListArray = $projectstatic->getProjectsAuthorizedForUser($user);
|
$mine = $_GET['mode']=='mine'?1:0;
|
||||||
|
$projectsListArray = $projectstatic->getProjectsAuthorizedForUser($user,$mine);
|
||||||
foreach ($projectsListArray as $key => $value)
|
foreach ($projectsListArray as $key => $value)
|
||||||
{
|
{
|
||||||
$projectsIdArray[] = $key;
|
$projectsIdArray[] = $key;
|
||||||
@ -126,7 +127,7 @@ $sql.= ", s.nom, s.rowid as socid";
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
|
||||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||||
$sql.= " AND p.rowid IN (".implode(',',$projectsIdArray).")";
|
$sql.= " AND p.rowid IN (".(!empty($projectsIdArray) ? implode(',',$projectsIdArray) : 0).")";
|
||||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||||
$sql.= " GROUP BY s.nom, s.rowid";
|
$sql.= " GROUP BY s.nom, s.rowid";
|
||||||
|
|
||||||
|
|||||||
@ -657,7 +657,7 @@ class Project extends CommonObject
|
|||||||
* @param unknown_type $user
|
* @param unknown_type $user
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function getProjectsAuthorizedForUser($user)
|
function getProjectsAuthorizedForUser($user,$mine=0)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -668,12 +668,23 @@ class Project extends CommonObject
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."element_contact as ec";
|
$sql.= ", ".MAIN_DB_PREFIX."element_contact as ec";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
|
$sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
|
||||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||||
$sql.= " AND ( p.public = 1";
|
|
||||||
$sql.= " OR p.fk_user_creat = ".$user->id;
|
if ($mine)
|
||||||
$sql.= " OR ( ec.element_id = p.rowid";
|
{
|
||||||
$sql.= " AND ctc.rowid = ec.fk_c_type_contact";
|
$sql.= " AND ec.element_id = p.rowid";
|
||||||
$sql.= " AND ctc.element = '".$this->element."'";
|
$sql.= " AND ctc.rowid = ec.fk_c_type_contact";
|
||||||
$sql.= " AND ec.fk_socpeople = ".$user->id." ) )";
|
$sql.= " AND ctc.element = '".$this->element."'";
|
||||||
|
$sql.= " AND ec.fk_socpeople = ".$user->id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql.= " AND ( p.public = 1";
|
||||||
|
$sql.= " OR p.fk_user_creat = ".$user->id;
|
||||||
|
$sql.= " OR ( ec.element_id = p.rowid";
|
||||||
|
$sql.= " AND ctc.rowid = ec.fk_c_type_contact";
|
||||||
|
$sql.= " AND ctc.element = '".$this->element."'";
|
||||||
|
$sql.= " AND ec.fk_socpeople = ".$user->id." ) )";
|
||||||
|
}
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user