From 06477b40a093f57a3e41d180f97604a7e4bb1b9e Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 15 Oct 2018 12:34:14 +0200 Subject: [PATCH] modify parenting before task deletion --- htdocs/core/actions_massactions.inc.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 32d80bef672..b7bbc402b09 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -598,6 +598,17 @@ if (! $error && $massaction == 'delete' && $permtodelete) $result=$objecttmp->fetch($toselectid); if ($result > 0) { + if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) { + $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id; + $res = $db->query($sql); + + if (!$res) + { + setEventMessage('ErrorRecordParentingNotModified', 'errors'); + $error++; + } + } + if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); else $result = $objecttmp->delete($user); if ($result <= 0)