diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php index 34c7640803785a9e160d5bffffa932196ae19abf..de698849b296d4009840321fa95a4eaad54a34f4 100644 --- a/htdocs/lib/project.lib.php +++ b/htdocs/lib/project.lib.php @@ -211,7 +211,7 @@ function select_projects($socid, $selected='', $htmlname='projectid') * @param unknown_type $tasksrole * @return unknown */ -function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole) +function PLinesb(&$inc, $parent, $lines, &$level, &$projectsrole) { global $user, $bc, $langs; global $form; @@ -235,6 +235,8 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole) print "<td>"; $projectstatic->id=$lines[$i]->projectid; $projectstatic->ref=$lines[$i]->projectref; + $projectstatic->public=$lines[$i]->public; + $projectstatic->label=$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->projectid]; print $projectstatic->getNomUrl(1); print "</td>"; @@ -262,14 +264,17 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole) print '<td align="right">'.$heure." h ".$minutes."</td>\n"; $disabled=1; + //print "x".$lines[$i]->projectid; + //var_dump($lines[$i]); + //var_dump($projectsrole[$lines[$i]->projectid]); // If at least one role for project - if (! empty($tasksrole[$lines[$i]->id]) - && sizeof($tasksrole[$lines[$i]->id]) > 0) $disabled=0; + if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->projectid])) $disabled=0; print '<td nowrap="nowrap">'; print $form->select_date('',$lines[$i]->id,'','','',"addtime"); print ' <input size="4" type="text" class="flat"'.($disabled?' disabled="true"':'').' name="task'.$lines[$i]->id.'" value="">'; print ' <input type="submit" class="button"'.($disabled?' disabled="true"':'').' value="'.$langs->trans("Add").'">'; + if ((! $lines[$i]->public) && $disabled) print '('.$langs->trans("YouAreNotContactOfProject").')'; print '</td>'; print "<td> "; print '</td>'; @@ -277,7 +282,7 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole) print "</tr>\n"; $inc++; $level++; - if ($lines[$i]->id) PLinesb($inc, $lines[$i]->id, $lines, $level, $tasksrole); + if ($lines[$i]->id) PLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole); $level--; } else @@ -298,7 +303,7 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole) * @param $level Level of task * @param $var Color * @param $showproject Show project columns - * @param $taskrole Array of tasks filtered on a particular user + * @param $taskrole Array of roles of user for each tasks */ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole) { @@ -358,9 +363,11 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole if ($showproject) { print "<td>"; + //var_dump($taskrole); if ($showlineingray) print '<i>'; $projectstatic->id=$lines[$i]->projectid; $projectstatic->ref=$lines[$i]->projectref; + $projectstatic->public=$lines[$i]->public; print $projectstatic->getNomUrl(1); if ($showlineingray) print '</i>'; print "</td>"; @@ -376,6 +383,7 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole { $taskstatic->id=$lines[$i]->id; $taskstatic->ref=$lines[$i]->id; + $taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:''); print $taskstatic->getNomUrl(1); } print '</td>'; diff --git a/htdocs/projet/activity/list.php b/htdocs/projet/activity/list.php index 1696239a0be9c96eb43c398120c2a9dad861ca66..94a634403962acb7b9f56ff151a3efe4e3d1a6f5 100644 --- a/htdocs/projet/activity/list.php +++ b/htdocs/projet/activity/list.php @@ -112,9 +112,9 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorde if ($mesg) print $mesg; $tasksarray=$task->getTasksArray(0,0,$project->id,$socid); -$tasksrole=$task->getUserRolesForProjectsOrTasks($user,0,$project->id,0); +$projectsrole=$task->getUserRolesForProjectsOrTasks($user,0,$project->id,0); //var_dump($tasksarray); -//var_dump($tasksrole); +//var_dump($projectsrole); print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$project->id.'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; @@ -128,7 +128,7 @@ print '<td>'.$langs->trans("LabelTask").'</td>'; print '<td align="right">'.$langs->trans("TimeSpent").'</td>'; print '<td colspan="2">'.$langs->trans("AddDuration").'</td>'; print "</tr>\n"; -PLinesb($j, 0, $tasksarray, $level, $tasksrole); +PLinesb($j, 0, $tasksarray, $level, $projectsrole); print '</form>'; diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index 9fbfaa989eb6d16b412b8a9900409628bbb104a7..9c782ff0d10ded475c68ec03d8bedda92cd78fa0 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -179,7 +179,7 @@ if ($id > 0 || ! empty($ref)) $userAccess = $project->restrictedProjectArea($user); $head = project_prepare_head($project); - dol_fiche_head($head, 'contact', $langs->trans("Project"), 0, 'project'); + dol_fiche_head($head, 'contact', $langs->trans("Project"), 0, ($project->public?'projectpub':'project')); /* diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index b27905d3a939ce11e75ba9e2e035929d5014e486..18d4104a38dbbdfda2715f451cda7cb86b3a1ac6 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -73,7 +73,7 @@ $project->societe->fetch($project->societe->id); $userAccess = $project->restrictedProjectArea($user); $head=project_prepare_head($project); -dol_fiche_head($head, 'element', $langs->trans("Project"),0,'project'); +dol_fiche_head($head, 'element', $langs->trans("Project"),0,($project->public?'projectpub':'project')); print '<table class="border" width="100%">'; diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index 9cd02792d22b0716e46ef8b7767bd45c2a9a891e..19a58c6f2c387b992ce4d97d4ada1b978f1f8658 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -318,7 +318,7 @@ else $userAccess = $project->restrictedProjectArea($user); $head=project_prepare_head($project); - dol_fiche_head($head, 'project', $langs->trans("Project"),0,'project'); + dol_fiche_head($head, 'project', $langs->trans("Project"),0,($project->public?'projectpub':'project')); // Confirmation validation if ($_GET['action'] == 'validate') diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 988113536b76c9357aac86dda0be2cb724c71154..b9cee76ca511ed7df6a8e7e822fdf1d576be0921 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -109,7 +109,7 @@ if ($id > 0 || ! empty($ref)) $userAccess = $project->restrictedProjectArea($user); $head = project_prepare_head($project); - dol_fiche_head($head, 'note', $langs->trans('Project'), 0, 'project'); + dol_fiche_head($head, 'note', $langs->trans('Project'), 0, ($project->public?'projectpub':'project')); print '<table class="border" width="100%">'; diff --git a/htdocs/projet/project.class.php b/htdocs/projet/project.class.php index f1028b002d3be473bfeb87f7e403076416c5330c..72e25a765060048069212e3c7bd19a97eb6e2217 100644 --- a/htdocs/projet/project.class.php +++ b/htdocs/projet/project.class.php @@ -519,9 +519,10 @@ class Project extends CommonObject $lien = '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$this->id.'">'; $lienfin='</a>'; - $picto='project'; + $picto='projectpub'; + if (! $this->public) $picto='project'; - $label=$langs->trans("ShowProject").': '.$this->ref; + $label=$langs->trans("ShowProject").': '.$this->ref.($this->label?' - '.$this->label:''); if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; @@ -604,7 +605,7 @@ class Project extends CommonObject $xnbp++; } } - + /** * \brief Check permissions */ @@ -622,7 +623,7 @@ class Project extends CommonObject { $userRole = $this->liste_contact(4,$source); $num=sizeof($userRole); - + $i = 0; while ($i < $num) { @@ -634,7 +635,7 @@ class Project extends CommonObject } } } - + if (!$userAccess && !$this->public) { if (!$list) @@ -645,12 +646,12 @@ class Project extends CommonObject { return -1; } - + } - + return $userAccess; } - + /** * Return array of projects authorized for a user * @@ -669,7 +670,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 ($mine) { $sql.= " AND ec.element_id = p.rowid"; @@ -699,9 +700,9 @@ class Project extends CommonObject $temp[] = $row[0]; $i++; } - + $this->db->free($resql); - + if ($list) { if (empty($temp)) return 0; diff --git a/htdocs/projet/tasks/fiche.php b/htdocs/projet/tasks/fiche.php index 526566153b18512345401aac8352c9cb1cfaa170..3af5bbc634136ed504c35c133d6aed8a7969ee8f 100644 --- a/htdocs/projet/tasks/fiche.php +++ b/htdocs/projet/tasks/fiche.php @@ -206,7 +206,7 @@ else if ($_REQUEST["mode"]=='mine') $tab='mytasks'; $head=project_prepare_head($project); - dol_fiche_head($head, $tab, $langs->trans("Project"),0,'project'); + dol_fiche_head($head, $tab, $langs->trans("Project"),0,($project->public?'projectpub':'project')); $param=($_REQUEST["mode"]=='mine'?'&mode=mine':''); diff --git a/htdocs/projet/tasks/task.class.php b/htdocs/projet/tasks/task.class.php index 9544d573f832a6c031dd5a67dd280329c244ba43..92c203bab60fa01c516bf233cfe26bec141ba996 100644 --- a/htdocs/projet/tasks/task.class.php +++ b/htdocs/projet/tasks/task.class.php @@ -398,7 +398,7 @@ class Task extends CommonObject $picto='projecttask'; - $label=$langs->trans("ShowTask").': '.$this->ref; + $label=$langs->trans("ShowTask").': '.$this->ref.($this->label?' - '.$this->label:''); if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; @@ -520,6 +520,7 @@ class Task extends CommonObject */ function getUserRolesForProjectsOrTasks($userp,$usert,$projectid=0,$taskid=0) { + $projectsrole = array(); $tasksrole = array(); dol_syslog("Task::getUserRolesForProjectsOrTasks userp=".is_object($userp)." usert=".is_object($usert)." projectid=".$projectid." taskid=".$taskid); @@ -531,8 +532,8 @@ class Task extends CommonObject return -1; } - /* Liste des taches et role sur la tache du user courant dans $tasksrole */ - $sql = "SELECT ec.element_id, ctc.code"; + /* Liste des taches et role sur les projets ou taches */ + $sql = "SELECT pt.rowid as pid, ec.element_id, ctc.code"; if ($userp) $sql.= " FROM ".MAIN_DB_PREFIX."projet as pt"; if ($usert) $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; @@ -546,8 +547,8 @@ class Task extends CommonObject $sql.= " AND ec.statut = 4"; if ($projectid) { - if ($userp || $usert) $sql.= " AND pt.fk_projet = ".$projectid; - //if ($usert) $sql.= " AND pt.rowid = ".$taskid; + if ($userp) $sql.= " AND pt.rowid = ".$projectid; + //if ($usert) $sql.= " AND pt.fk_projet = ".$projectid; } if ($taskid) { @@ -564,9 +565,9 @@ class Task extends CommonObject $i = 0; while ($i < $num) { - $row = $this->db->fetch_row($resql); - if (empty($tasksrole[$row[0]])) $tasksrole[$row[0]] = $row[1]; - else $tasksrole[$row[0]].=','.$row[1]; + $obj = $this->db->fetch_object($resql); + if (empty($projectsrole[$obj->pid])) $projectsrole[$obj->pid] = $obj->code; + else $projectsrole[$obj->pid].=','.$obj->code; $i++; } $this->db->free($resql); @@ -576,7 +577,7 @@ class Task extends CommonObject dol_print_error($this->db); } - return $tasksrole; + return $projectsrole; } /**