Merge branch '6.0' of git@github.com:Dolibarr/dolibarr.git into 7.0
This commit is contained in:
commit
62b2981e42
@ -639,9 +639,8 @@ class Project extends CommonObject
|
|||||||
$this->getLinesArray($user);
|
$this->getLinesArray($user);
|
||||||
|
|
||||||
// Delete tasks
|
// Delete tasks
|
||||||
foreach($this->lines as &$task) {
|
$ret = $this->deleteTasks($user);
|
||||||
$task->delete($user);
|
if ($ret < 0) $error++;
|
||||||
}
|
|
||||||
|
|
||||||
// Delete project
|
// Delete project
|
||||||
if (! $error)
|
if (! $error)
|
||||||
@ -718,6 +717,40 @@ class Project extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete tasks with no children first, then task with children recursively
|
||||||
|
*
|
||||||
|
* @param User $user User
|
||||||
|
* @return int <0 if KO, 1 if OK
|
||||||
|
*/
|
||||||
|
function deleteTasks($user)
|
||||||
|
{
|
||||||
|
$countTasks = count($this->lines);
|
||||||
|
$deleted = false;
|
||||||
|
if ($countTasks)
|
||||||
|
{
|
||||||
|
foreach($this->lines as $task)
|
||||||
|
{
|
||||||
|
if ($task->hasChildren() <= 0) { // If there is no children (or error to detect them)
|
||||||
|
$deleted = true;
|
||||||
|
$ret = $task->delete($user);
|
||||||
|
if ($ret <= 0)
|
||||||
|
{
|
||||||
|
$this->errors[] = $this->db->lasterror();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->getLinesArray($user);
|
||||||
|
if ($deleted && count($this->lines) < $countTasks)
|
||||||
|
{
|
||||||
|
if (count($this->lines)) $this->deleteTasks($this->lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate a project
|
* Validate a project
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user