Merge pull request #22617 from atm-jpb/FIX_task_never_deleted_in_bdd_on_deleted_project
FIX : add loadRoleMode on getlinearray
This commit is contained in:
commit
f0c257f62e
@ -838,7 +838,7 @@ class Project extends CommonObject
|
||||
}
|
||||
|
||||
// Fetch tasks
|
||||
$this->getLinesArray($user);
|
||||
$this->getLinesArray($user, 0);
|
||||
|
||||
// Delete tasks
|
||||
$ret = $this->deleteTasks($user);
|
||||
@ -2204,14 +2204,15 @@ class Project extends CommonObject
|
||||
/**
|
||||
* Create an array of tasks of current project
|
||||
*
|
||||
* @param User $user Object user we want project allowed to
|
||||
* @return int >0 if OK, <0 if KO
|
||||
* @param User $user Object user we want project allowed to
|
||||
* @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*/
|
||||
public function getLinesArray($user)
|
||||
public function getLinesArray($user, $loadRoleMode = 1)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||
$taskstatic = new Task($this->db);
|
||||
|
||||
$this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0);
|
||||
$this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0, '', '-1', '', 0, 0, array(), 0, array(), 0, $loadRoleMode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -772,9 +772,10 @@ class Task extends CommonObject
|
||||
* @param array $extrafields Show additional column from project or task
|
||||
* @param int $includebilltime Calculate also the time to bill and billed
|
||||
* @param array $search_array_options Array of search
|
||||
* @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action
|
||||
* @return array Array of tasks
|
||||
*/
|
||||
public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array())
|
||||
public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadRoleMode = 1)
|
||||
{
|
||||
global $conf, $hookmanager;
|
||||
|
||||
@ -925,18 +926,18 @@ class Task extends CommonObject
|
||||
$error = 0;
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
if ((!$obj->public) && (is_object($userp))) { // If not public project and we ask a filter on project owned by a user
|
||||
if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) {
|
||||
$error++;
|
||||
if ($loadRoleMode) {
|
||||
if ((!$obj->public) && (is_object($userp))) { // If not public project and we ask a filter on project owned by a user
|
||||
if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
if (is_object($usert)) { // If we ask a filter on a user affected to a task
|
||||
if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_object($usert)) { // If we ask a filter on a user affected to a task
|
||||
if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$tasks[$i] = new Task($this->db);
|
||||
$tasks[$i]->id = $obj->taskid;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user