Skip to content

Commit

Permalink
Update project.class.php
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Aug 21, 2018
1 parent ba6f7d4 commit 3523c2b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions htdocs/projet/class/project.class.php
Expand Up @@ -712,21 +712,22 @@ function delete($user, $notrigger=0)
}

/**
* Reoder tasks to delete children tasks first
* Delete tasks with no children first, then task with children recursively
*
* @param array $arr Array of tasks
* @param int <0 if KO, 1 if OK
*/
function deleteTasks($user)
{
$countTasks = count($this->lines);
$deleted = false;
if ($countTasks){
if ($countTasks)
{
foreach($this->lines as $task)
{
if($task->hasChildren() <= 0) {
if ($task->hasChildren() <= 0) { // If there is no children (or error to detect them)
$deleted = true;
$ret = $task->delete($user);
if ($ret < 1)
if ($ret <= 0)
{
$this->errors[] = $this->db->lasterror();
return -1;
Expand All @@ -735,7 +736,7 @@ function deleteTasks($user)
}
}
$this->getLinesArray($user);
if($deleted && count($this->lines) < $countTasks)
if ($deleted && count($this->lines) < $countTasks)
{
if (count($this->lines)) $this->deleteTasks($this->lines);
}
Expand Down

0 comments on commit 3523c2b

Please sign in to comment.