Fix: visible task into area "time" for "My task" must limit task to

tasks i am assigned to.
This commit is contained in:
Laurent Destailleur 2014-08-07 11:48:19 +02:00
parent ebc11a7a9c
commit 1016e05fc6
2 changed files with 115 additions and 103 deletions

View File

@ -449,10 +449,11 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
* @param int &$level ? * @param int &$level ?
* @param string &$projectsrole ? * @param string &$projectsrole ?
* @param string &$tasksrole ? * @param string &$tasksrole ?
* @param int $mytask 0 or 1 to enable only if task is a task i am affected to * @param string $mine Show only task lines I am assigned to
* @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to
* @return $inc * @return $inc
*/ */
function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mytask=0) function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask=0)
{ {
global $user, $bc, $langs; global $user, $bc, $langs;
global $form, $projectstatic, $taskstatic; global $form, $projectstatic, $taskstatic;
@ -475,6 +476,9 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr
$lastprojectid=$lines[$i]->fk_project; $lastprojectid=$lines[$i]->fk_project;
} }
// If we want all or we have a role on task, we show it
if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
{
print "<tr ".$bc[$var].">\n"; print "<tr ".$bc[$var].">\n";
// Project // Project
@ -546,8 +550,8 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr
$disabledproject=0; $disabledproject=0;
$disabledtask=0; $disabledtask=0;
} }
// If mytask and no role on task // If $restricteditformytask is on and I have no role on task, i disable edit
if ($mytask && empty($tasksrole[$lines[$i]->id])) if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
{ {
$disabledtask=1; $disabledtask=1;
} }
@ -565,9 +569,11 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
}
$inc++; $inc++;
$level++; $level++;
if ($lines[$i]->id) projectLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mytask); if ($lines[$i]->id) projectLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask);
$level--; $level--;
} }
else else

View File

@ -137,11 +137,14 @@ llxHeader("",$title,"");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
// Filter on user // Filter on user
dol_fiche_head(''); /* dol_fiche_head('');
print '<table class="border" width="100%"><tr><td width="25%">'.$langs->trans("User").'</td>'; print '<table class="border" width="100%"><tr><td width="25%">'.$langs->trans("User").'</td>';
print '<td>'.$user->getLoginUrl(1).'</td>'; print '<td>';
if ($mine) print $user->getLoginUrl(1);
print '</td>';
print '</tr></table>'; print '</tr></table>';
dol_fiche_end(); dol_fiche_end();
*/
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
@ -165,9 +168,12 @@ print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print '<td colspan="2">'.$langs->trans("AddDuration").'</td>'; print '<td colspan="2">'.$langs->trans("AddDuration").'</td>';
print "</tr>\n"; print "</tr>\n";
// By default, we can edit only tasks we are assigned to
$restricteditformytask=(empty($conf->global->PROJECT_TIME_ON_ALL_TASKS_MY_PROJECTS)?1:0);
if (count($tasksarray) > 0) if (count($tasksarray) > 0)
{ {
projectLinesb($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine); projectLinesb($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask);
} }
else else
{ {