From 3e767382e8864292f7696ca4efcb9805585c1816 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Jun 2010 21:10:43 +0000 Subject: [PATCH] Fix: Removed not translated combo box. --- htdocs/langs/en_US/projects.lang | 1 + htdocs/langs/fr_FR/projects.lang | 1 + htdocs/lib/project.lib.php | 46 +++++++++++++++++++-------- htdocs/projet/class/project.class.php | 4 ++- htdocs/projet/liste.php | 9 +++--- htdocs/projet/tasks/index.php | 2 +- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 0554acf806d..330505bee02 100755 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -79,6 +79,7 @@ ShowMyTasksOnly=View only tasks i am affected to TaskRessourceLinks=Ressources ProjectsDedicatedToThisThirdParty=Projects dedicated to this third party NoTasks=No tasks for this project +LinkedToAnotherCompany=Linked to other third party ##### Types de contacts ##### TypeContact_project_internal_PROJECTLEADER=Project leader TypeContact_project_external_PROJECTLEADER=Project leader diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 024bed96a48..777efe6e006 100755 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -79,6 +79,7 @@ ShowMyTasksOnly=Ne voir que les tâches qui me sont affectées TaskRessourceLinks=Affectation ressources ProjectsDedicatedToThisThirdParty=Projets dédiés à ce tiers NoTasks=Aucune tâche pour ce projet +LinkedToAnotherCompany=Liés à autre société ##### Types de contacts ##### TypeContact_project_internal_PROJECTLEADER=Chef de projet TypeContact_project_external_PROJECTLEADER=Chef de projet diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php index 5a5678b857e..15e0ff8e64c 100644 --- a/htdocs/lib/project.lib.php +++ b/htdocs/lib/project.lib.php @@ -190,9 +190,11 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid') $sql.= " WHERE p.entity = ".$conf->entity; if ($projectsListId) $sql.= " AND p.rowid in (".$projectsListId.")"; if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; - if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc='0' OR p.fk_soc IS NULL)"; + //if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc='0' OR p.fk_soc IS NULL)"; // We will filter later $sql.= " ORDER BY p.title ASC"; + //print $sql; + //var_dump($user->rights); dol_syslog("project.lib::select_projects sql=".$sql); $resql=$db->query($sql); if ($resql) @@ -206,24 +208,40 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid') while ($i < $num) { $obj = $db->fetch_object($resql); - $labeltoshow=dol_trunc($obj->ref,12).' - '.dol_trunc($obj->title,12); - //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; - //else $labeltoshow.=' ('.$langs->trans("Private").')'; - if (!empty($selected) && $selected == $obj->rowid && $obj->fk_statut > 0) + // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire) { - print ''; + // Do nothing } else { - print ''; + if (!empty($selected) && $selected == $obj->rowid && $obj->fk_statut > 0) + { + print ''; + } + else + { + $disabled=0; + print ''; + } } $i++; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index b2214687a20..bc5d49110f9 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -761,9 +761,10 @@ class Project extends CommonObject * @param user User object * @param mode 0=All project I have permission on, 1=Affected to me only, 2=Will return list of all projects * @param list 0=Return array,1=Return string list + * @param socid 0=No filter on third party, id of third party * @return array or string */ - function getProjectsAuthorizedForUser($user,$mode=0,$list=0) + function getProjectsAuthorizedForUser($user,$mode=0,$list=0,$socid=0) { global $conf; @@ -775,6 +776,7 @@ class Project extends CommonObject $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; $sql.= " WHERE p.entity = ".$conf->entity; + if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($mode == 2) { diff --git a/htdocs/projet/liste.php b/htdocs/projet/liste.php index 5b79afdaf76..c1432340b54 100644 --- a/htdocs/projet/liste.php +++ b/htdocs/projet/liste.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005 Marc Bariley / Ocebo * Copyright (C) 2005-2010 Regis Houssin * @@ -72,7 +72,7 @@ $projectstatic = new Project($db); $socstatic = new Societe($db); $mine = $_REQUEST['mode']=='mine' ? 1 : 0; -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1); +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); $sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_statut, p.public, p.fk_user_creat"; $sql.= ", p.datec as date_create, p.dateo as date_start, p.datee as date_end"; @@ -81,8 +81,8 @@ $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql.= " WHERE p.entity = ".$conf->entity; if ($mine) $sql.= " AND p.rowid IN (".$projectsListId.")"; -if ($socid) $sql.= " AND s.rowid = ".$socid; - +//var_dump($user->rights->societe); +if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($_GET["search_ref"]) { $sql.= " AND p.ref LIKE '%".addslashes($_GET["search_ref"])."%'"; @@ -98,6 +98,7 @@ if ($_GET["search_societe"]) $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($conf->liste_limit+1, $offset); +//print $sql; $var=true; $resql = $db->query($sql); if ($resql) diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index 93065e1fc8e..f64ff40fadf 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -78,7 +78,7 @@ else } // Get list of project id allowed to user -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1); +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user // can have a parent that is not affected to him).