From ecb4eebfacb2dae39b43f6cd57ca510170f58f78 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 06:58:55 +0200 Subject: [PATCH] Fix filter of project in timespent view --- htdocs/langs/en_US/projects.lang | 2 +- htdocs/projet/activity/perday.php | 28 ++++++++++++++++++---------- htdocs/projet/activity/perweek.php | 28 ++++++++++++++++++---------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index d940555f206..a30768709f9 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -23,7 +23,7 @@ OnlyOpenedProject=Only open projects are visible (projects in draft or closed st ClosedProjectsAreHidden=Closed projects are not visible. 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). -AllTaskVisibleButEditIfYouAreAssigned=All tasks for such project are visible, but you can enter time only for task assigned to you. Assign task to yourself if you need to enter time on it. +AllTaskVisibleButEditIfYouAreAssigned=All tasks for qualified projects are visible, but you can enter time only for task assigned to you. Assign task to yourself if you need to enter time on it. OnlyYourTaskAreVisible=Only tasks assigned to you are visible. Assign task to yourself if it is not visible and you need to enter time on it. ImportDatasetTasks=Tasks of projects ProjectCategories=Project tags/categories diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 7b1f50bb50c..45d7aa237ad 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -82,13 +82,18 @@ else if ($year && $month && $day) $daytoparse=dol_mktime(0, 0, 0, $month, $day, if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { $usertoprocess=$user; + $search_usertoprocessid=$usertoprocess->id; } -else +elseif (search_usertoprocessid > 0) { $usertoprocess=new User($db); $usertoprocess->fetch($search_usertoprocessid); + $search_usertoprocessid=$usertoprocess->id; +} +else +{ + $usertoprocess=new User($db); } -$search_usertoprocessid=$usertoprocess->id; $object=new Task($db); @@ -305,9 +310,9 @@ $next_month = $next['mon']; $next_day = $next['mday']; $title=$langs->trans("TimeSpent"); -if ($mine) $title=$langs->trans("MyTimeSpent"); +if ($mine || ($usertoprocess->id == $user->id)) $title=$langs->trans("MyTimeSpent"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,(empty($usertoprocess->id)?2:0),1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project if ($id) { @@ -320,7 +325,7 @@ $morewherefilter=''; if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); if ($search_task_label) $morewherefilter.=natural_search("t.label", $search_task_label); if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); -$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later. +$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. $projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); //var_dump($tasksarray); @@ -362,13 +367,16 @@ dol_fiche_head($head, 'inputperday', '', -1, 'task'); // Show description of content print '
'; -if ($mine) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; else { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; - else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + if (empty($usertoprocess->id) || $usertoprocess->id < 0) + { + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + } } -if ($mine) +if ($mine || ($usertoprocess->id == $user->id)) { print $langs->trans("OnlyYourTaskAreVisible").'
'; } @@ -413,7 +421,7 @@ $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; $includeonly='hierachyme'; if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:$usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; if (! empty($moreforfilter)) diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 3410ba1d949..b4fcd68a3c9 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -95,13 +95,18 @@ $lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { $usertoprocess=$user; + $search_usertoprocessid=$usertoprocess->id; } -else +elseif (search_usertoprocessid > 0) { $usertoprocess=new User($db); $usertoprocess->fetch($search_usertoprocessid); + $search_usertoprocessid=$usertoprocess->id; +} +else +{ + $usertoprocess=new User($db); } -$search_usertoprocessid=$usertoprocess->id; $object=new Task($db); @@ -300,9 +305,9 @@ $taskstatic = new Task($db); $thirdpartystatic = new Societe($db); $title=$langs->trans("TimeSpent"); -if ($mine) $title=$langs->trans("MyTimeSpent"); +if ($mine || $usertoprocess->id == $user->id) $title=$langs->trans("MyTimeSpent"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,(empty($usertoprocess->id)?2:0),1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project //var_dump($projectsListId); if ($id) { @@ -316,7 +321,7 @@ if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref if ($search_task_label) $morewherefilter.=natural_search("t.label", $search_task_label); if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); -$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later. +$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. $projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); //var_dump($tasksarray); @@ -356,13 +361,16 @@ dol_fiche_head($head, 'inputperweek', '', -1, 'task'); // Show description of content print '
'; -if ($mine) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; else { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; - else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + if (empty($usertoprocess->id) || $usertoprocess->id < 0) + { + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + } } -if ($mine) +if ($mine || ($usertoprocess->id == $user->id)) { print $langs->trans("OnlyYourTaskAreVisible").'
'; } @@ -408,7 +416,7 @@ $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; $includeonly='hierachyme'; if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:$usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; if (! empty($moreforfilter))