diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 6ac789ff314..9201fdd4ddc 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1595,7 +1595,7 @@ class Project extends CommonObject * @param int $mode 0=All project I have permission on (assigned to me or public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts * @param int $list 0=Return array, 1=Return string list * @param int $socid 0=No filter on third party, id of third party - * @param string $filter additional filter on project (statut, ref, ...) + * @param string $filter additional filter on project (statut, ref, ...). TODO Use USF syntax here. * @return array|string Array of projects id, or string with projects id separated with "," if list is 1 */ public function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid = 0, $filter = '') diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index ff04c97ef49..3a2309d26b2 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -7,7 +7,9 @@ * Copyright (C) 2018 Frédéric France * Copyright (C) 2019-2021 Christophe Battarel * Copyright (C) 2023 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Vincent de Grandpré + * Copyright (C) 2024 Solution Libre SAS * * 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 @@ -1597,6 +1599,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $sql .= $hookmanager->resPrint; $sql .= " WHERE elementtype = 'task'"; $sql .= " AND p.entity IN (".getEntity('project').")"; + if (!$user->hasRight('projet', 'all', 'lire')) { + // Get list of project id allowed to user (in a string list separated by comma) + // TODO This may generate performance trouble when list of project is very large. Solution can be to complete $filterproj with filters on project. + $filterproj = ''; + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj); + $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users + } if (empty($projectidforalltimes) && empty($allprojectforuser)) { // Limit on one task $sql .= " AND t.fk_element =".((int) $object->id);