FIX #30362 Fix an user with user->rights->projet->lire can see task
time from other user on all project (#30363) Conflicts: htdocs/projet/tasks/time.php
This commit is contained in:
parent
f91c96842f
commit
23eeabe476
2 changed files with 11 additions and 2 deletions
|
|
@ -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 = '')
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@
|
|||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2019-2021 Christophe Battarel <christophe@altairis.fr>
|
||||
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Vincent de Grandpré <vincent@de-grandpre.quebec>
|
||||
* Copyright (C) 2024 Solution Libre SAS <contact@solution-libre.fr>
|
||||
*
|
||||
* 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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue