diff --git a/htdocs/project.class.php b/htdocs/project.class.php
index 9fafb3a2940..de970751464 100644
--- a/htdocs/project.class.php
+++ b/htdocs/project.class.php
@@ -468,13 +468,13 @@ class Project extends CommonObject
* @param mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists
* @return array Array of tasks
*/
- function getTasksArray($usert=0, $userp=0, $mode=0)
+ function getTasksArray($usert=0, $userp=0, $mode=0, $socid=0)
{
global $conf;
$tasks = array();
- //print $usert.'-'.$userp;
+ //print $usert.'-'.$userp.'
';
// List of tasks
$sql = "SELECT p.rowid as projectid, p.ref, p.title as ptitle,";
@@ -492,6 +492,7 @@ class Project extends CommonObject
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as up on p.fk_user_resp = up.rowid";
$sql.= " WHERE t.fk_projet = p.rowid";
$sql.= " AND p.entity = ".$conf->entity;
+ if ($socid) $sql.= " AND p.fk_soc = ".$socid;
if ($this->id) $sql .= " AND t.fk_projet =".$this->id;
if (is_object($usert)) $sql .= " AND ta.fk_projet_task = t.rowid AND ta.fk_user = ".$usert->id;
if (is_object($userp)) $sql .= " AND (p.fk_user_resp = ".$userp->id." OR p.fk_user_resp IS NULL OR p.fk_user_resp = -1)";
@@ -513,12 +514,13 @@ class Project extends CommonObject
}
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as up on p.fk_user_resp = up.rowid";
$sql.= " WHERE p.entity = ".$conf->entity;
+ if ($socid) $sql.= " AND p.fk_soc = ".$socid;
if ($this->id) $sql .= " AND t.fk_projet =".$this->id;
if (is_object($usert)) $sql .= " AND t.fk_projet = p.rowid AND ta.fk_projet_task = t.rowid AND ta.fk_user = ".$usert->id;
if (is_object($userp)) $sql .= " AND (p.fk_user_resp = ".$userp->id." OR p.fk_user_resp IS NULL OR p.fk_user_resp = -1)";
$sql.= " ORDER BY p.ref, t.title";
}
-
+
dol_syslog("Project::getTasksArray sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php
index 5d88989c4e2..32dc8b2d5a1 100644
--- a/htdocs/projet/tasks/index.php
+++ b/htdocs/projet/tasks/index.php
@@ -1,6 +1,7 @@
* Copyright (C) 2006-2009 Laurent Destailleur
+ * Copyright (C) 2006-2009 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,7 +21,7 @@
/**
* \file htdocs/projet/tasks/index.php
* \ingroup project
- * \brief Fiche t�ches d'un projet
+ * \brief Fiche taches d'un projet
* \version $Id$
*/
@@ -78,15 +79,15 @@ llxHeader("",$title,"Projet");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
-$projet = new Project($db);
+$project = new Project($db);
// 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).
-$tasksarray=$projet->getTasksArray(0, 0, 0);
+$tasksarray=$project->getTasksArray(0, 0, 0, $socid);
// We load also tasks limited to a particular user
-$tasksrole=($_REQUEST["mode"]=='mine' ? $projet->getTasksRoleForUser($user) : '');
+$tasksrole=($_REQUEST["mode"]=='mine' ? $project->getTasksRoleForUser($user) : '');
print '';
print '';
@@ -107,11 +108,12 @@ print '';
/*
* Actions
*/
-print '';
-
-
+if ($user->rights->projet->creer)
+{
+ print '';
+}
$db->close();