Update project.class.php
This commit is contained in:
parent
ba6f7d4b0a
commit
3523c2b3d2
@ -712,21 +712,22 @@ class Project extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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)
|
function deleteTasks($user)
|
||||||
{
|
{
|
||||||
$countTasks = count($this->lines);
|
$countTasks = count($this->lines);
|
||||||
$deleted = false;
|
$deleted = false;
|
||||||
if ($countTasks){
|
if ($countTasks)
|
||||||
|
{
|
||||||
foreach($this->lines as $task)
|
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;
|
$deleted = true;
|
||||||
$ret = $task->delete($user);
|
$ret = $task->delete($user);
|
||||||
if ($ret < 1)
|
if ($ret <= 0)
|
||||||
{
|
{
|
||||||
$this->errors[] = $this->db->lasterror();
|
$this->errors[] = $this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
@ -735,7 +736,7 @@ class Project extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->getLinesArray($user);
|
$this->getLinesArray($user);
|
||||||
if($deleted && count($this->lines) < $countTasks)
|
if ($deleted && count($this->lines) < $countTasks)
|
||||||
{
|
{
|
||||||
if (count($this->lines)) $this->deleteTasks($this->lines);
|
if (count($this->lines)) $this->deleteTasks($this->lines);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user