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);
|
||||
|
||||
// Delete tasks
|
||||
foreach($this->lines as &$task) {
|
||||
$task->delete($user);
|
||||
}
|
||||
$ret = $this->deleteTasks($user);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
// Delete project
|
||||
if (! $error)
|
||||
@ -717,6 +716,40 @@ class Project extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user