Skip to content

Commit

Permalink
Always check for children before deletion.
Browse files Browse the repository at this point in the history
Prevents orphaning tasks via the API or Kronolith.
  • Loading branch information
mrubinsk committed Oct 28, 2015
1 parent 5e9d38a commit 6e8e64b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 0 additions & 3 deletions nag/app/controllers/SaveTask.php
Expand Up @@ -35,9 +35,6 @@ public function processRequest(Horde_Controller_Request $request, Horde_Controll
if (!$share->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
$notification->push(_("Access denied deleting task"), 'horde.error');
Horde::url('list.php', true)->redirect();
} elseif ($task->hasSubTasks()) {
$notification->push(_("Sub tasks exist, delete them first"), 'horde.error');
Horde::url('list.php', true)->redirect();
} else {
$storage = $this->getInjector()
->getInstance('Nag_Factory_Driver')
Expand Down
5 changes: 5 additions & 0 deletions nag/lib/Driver.php
Expand Up @@ -378,6 +378,11 @@ public function delete($taskId)
{
/* Get the task's details for use later. */
$task = $this->get($taskId);
$task->loadChildren();
if ($task->hasSubTasks()) {
throw new Nag_Exception(_("Sub tasks exist, delete them first"));
}

$delete = $this->_delete($taskId);

/* Remove tags */
Expand Down
2 changes: 0 additions & 2 deletions nag/task.php
Expand Up @@ -24,8 +24,6 @@ function _delete($task_id, $tasklist_id)
}
if (!$share->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
$notification->push(_("Access denied deleting task."), 'horde.error');
} elseif ($task->hasSubTasks()) {
$notification->push(_("Sub tasks exist, delete them first"), 'horde.error');
} else {
$storage = $injector->getInstance('Nag_Factory_Driver')->create($tasklist_id);
try {
Expand Down

0 comments on commit 6e8e64b

Please sign in to comment.