Skip to content

Commit

Permalink
Don't allow deletion of tasks with children (Bug #13809).
Browse files Browse the repository at this point in the history
This needs to be done in the controller. Couldn't find anywhere
in existing code that would use the _delete() function implemented
on tasks.php - maybe it's there for BC? Probably should be removed.
  • Loading branch information
mrubinsk committed Mar 27, 2015
1 parent a8aae56 commit fd868dc
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions nag/app/controllers/SaveTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,27 @@ public function processRequest(Horde_Controller_Request $request, Horde_Controll
$notification->push(sprintf(_("Access denied deleting task: %s"), $e->getMessage()), 'horde.error');
Horde::url('list.php', true)->redirect();
}
$task = Nag::getTask($info['old_tasklist'], $info['task_id']);
$task->loadChildren();
if (!$share->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
$notification->push(_("Access denied deleting task"), 'horde.error');
Horde::url('list.php', true)->redirect();
}
$storage = $this->getInjector()
->getInstance('Nag_Factory_Driver')
->create($info['old_tasklist']);
try {
$storage->delete($info['task_id']);
} catch (Nag_Exception $e) {
$notification->push(sprintf(_("Error deleting task: %s"), $e->getMessage()), 'horde.error');
} 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')
->create($info['old_tasklist']);
try {
$storage->delete($info['task_id']);
$notification->push(_("Task successfully deleted"), 'horde.success');
Horde::url('list.php', true)->redirect();
} catch (Nag_Exception $e) {
$notification->push(sprintf(_("Error deleting task: %s"), $e->getMessage()), 'horde.error');
Horde::url('list.php', true)->redirect();
}
}
$notification->push(_("Task successfully deleted"), 'horde.success');
Horde::url('list.php', true)->redirect();
}

if ($prefs->isLocked('default_tasklist') ||
Expand Down

0 comments on commit fd868dc

Please sign in to comment.