diff --git a/htdocs/html.formother.class.php b/htdocs/html.formother.class.php
index 2b4abbe6a21..0b1faa03aa2 100644
--- a/htdocs/html.formother.class.php
+++ b/htdocs/html.formother.class.php
@@ -366,11 +366,11 @@ function PLineSelect(&$inc, $parent, $lines, $level=0, $selected=0)
print $langs->trans("Project").' '.$lines[$i]->projectref;
if (empty($lines[$i]->public))
{
- print ' ('.$langs->trans("PrivateProject").')';
+ print ' ('.$langs->trans("Visibility").': '.$langs->trans("PrivateProject").')';
}
else
{
- print ' ('.$langs->trans("SharedProject").')';
+ print ' ('.$langs->trans("Visibility").': '.$langs->trans("SharedProject").')';
}
//print '-'.$parent.'-'.$lines[$i]->projectid.'-'.$lastprojectid;
print "\n";
diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang
index 8c71ee8c278..18d179a7a83 100755
--- a/htdocs/langs/en_US/projects.lang
+++ b/htdocs/langs/en_US/projects.lang
@@ -4,10 +4,12 @@ Project=Project
Projects=Projects
SharedProject=Everybody
PrivateProject=Contacts of project
-MyProjectsDesc=Cette vue projet est restreinte aux projets pour lesquels vous êtes un contact affecté (quelqu'en soit le type).
-ProjectsDesc=Cette vue présente tous les projets ayant pour visibilité "Tout le monde".
-MyTasksDesc=Cette vue est restreinte aux projets et taches pour lesquels vous êtes un contact affecté à au moins une tache (quelqu'en soit le type).
-TasksDesc=Cette vue présente tous les projets ayant pour visibilité "Tout le monde".
+MyProjectsDesc=This view is limited to projects you are a contact for (whatever is the type).
+ProjectsPublicDesc=This view presents all projects you are allowed to read.
+ProjectsDesc=This view presents all projects (your user permissions grant you permission to view everything).
+MyTasksDesc=This view is limited to projects or tasks you are a contact for (whatever is the type).
+TasksPublicDesc=This view presents all projects and tasks you are allowed to read.
+TasksDesc=This view presents all projects and tasks (your user permissions grant you permission to view everything).
Myprojects=My projects
ProjectsArea=Projects area
NewProject=New project
diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php
index 34731a4535a..34c76408037 100644
--- a/htdocs/lib/project.lib.php
+++ b/htdocs/lib/project.lib.php
@@ -217,6 +217,7 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole)
global $form;
$projectstatic = new Project($db);
+ $taskstatic = new Task($db);
$var=true;
@@ -230,8 +231,19 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole)
$var = !$var;
print "
';
- }
+ $disabled=1;
+ // If at least one role for project
+ if (! empty($tasksrole[$lines[$i]->id])
+ && sizeof($tasksrole[$lines[$i]->id]) > 0) $disabled=0;
+
+ print '
';
- if ($user->rights->projet->creer)
+ if ($user->rights->projet->all->creer || $user->rights->projet->creer)
{
- if ($userAccess)
+ if ($project->public || $userAccess)
{
print ''.$langs->trans('AddTask').'';
}
diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php
index 4c25650311e..f95f406eecf 100644
--- a/htdocs/projet/tasks/index.php
+++ b/htdocs/projet/tasks/index.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2006-2009 Laurent Destailleur
+ * Copyright (C) 2006-2010 Laurent Destailleur
* Copyright (C) 2006-2010 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
@@ -21,12 +21,14 @@
/**
* \file htdocs/projet/tasks/index.php
* \ingroup project
- * \brief Fiche taches d'un projet
+ * \brief List all task of a project
* \version $Id$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/projet/project.class.php");
+require_once(DOL_DOCUMENT_ROOT."/projet/tasks/task.class.php");
$langs->load('projects');
@@ -68,15 +70,15 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorde
// 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=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid);
+$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
// We load also tasks limited to a particular user
$tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : '');
print '
';
print '
';
+print '
'.$langs->trans("Project").'
';
print '
'.$langs->trans("RefTask").'
';
print '
'.$langs->trans("LabelTask").'
';
-print '
'.$langs->trans("Project").'
';
print '
'.$langs->trans("TimeSpent").'
';
print "
\n";
// Show all lines in taskarray (recursive function to go down on tree)
diff --git a/htdocs/projet/tasks/task.class.php b/htdocs/projet/tasks/task.class.php
index e77a59cf2a6..9544d573f83 100644
--- a/htdocs/projet/tasks/task.class.php
+++ b/htdocs/projet/tasks/task.class.php
@@ -495,6 +495,7 @@ class Task extends CommonObject
$tasks[$i]->description = $obj->description;
$tasks[$i]->fk_parent = $obj->fk_task_parent;
$tasks[$i]->duration = $obj->duration_effective;
+ $tasks[$i]->public = $obj->public;
}
$i++;
@@ -510,17 +511,19 @@ class Task extends CommonObject
}
/**
- * Return Array of role of user for each projects or each tasks
+ * Return list of roles for a user for each projects or each tasks (or a particular project or task)
* @param userp
- * @param usert
- * @param projectid
- * @param taskid
- * @return array Array of role of user for each projects or each tasks
+ * @param usert Deprecated. Permissions are on project.
+ * @param projectid Project id to filter on a project
+ * @param taskid Task id to filter on a task
+ * @return array Array (projectid => 'list of roles for project')
*/
function getUserRolesForProjectsOrTasks($userp,$usert,$projectid=0,$taskid=0)
{
$tasksrole = array();
+ dol_syslog("Task::getUserRolesForProjectsOrTasks userp=".is_object($userp)." usert=".is_object($usert)." projectid=".$projectid." taskid=".$taskid);
+
// We want role of user for projet or role of user for task. Both are not possible.
if (empty($userp) && empty($usert))
{
@@ -552,7 +555,8 @@ class Task extends CommonObject
if ($usert) $sql.= " AND pt.rowid = ".$taskid;
}
- dol_syslog("Task::getTasksForProjectOwnedByAUser sql=".$sql);
+ //print $sql;
+ dol_syslog("Task::getUserRolesForProjectsOrTasks sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
@@ -561,7 +565,8 @@ class Task extends CommonObject
while ($i < $num)
{
$row = $this->db->fetch_row($resql);
- $tasksrole[$row[0]] = $row[1];
+ if (empty($tasksrole[$row[0]])) $tasksrole[$row[0]] = $row[1];
+ else $tasksrole[$row[0]].=','.$row[1];
$i++;
}
$this->db->free($resql);