aboutsummaryrefslogtreecommitdiff
path: root/actions/tasks/delete.php
blob: 9e15831f49637d8a984d4633fdb31382e1e9d2b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/**
 * Remove a task
 *
 * @package ElggTasks
 */

$guid = get_input('guid');
$task = get_entity($guid);
if ($task) {
	if ($task->canEdit()) {
		$container = get_entity($task->container_guid);
		$list = $task->list_guid;
		
		if ($task->delete()) {
			system_message(elgg_echo('tasks:delete:success'));
			if ($list) {
				if ($list = get_entity($list)) {
					forward($list->getURL());
				}
			}
			if (elgg_instanceof($container, 'group')) {
				forward("tasks/group/$container->guid/all");
			} else {
				forward("tasks/owner/$container->username");
			}
		}
	}
}

register_error(elgg_echo('tasks:delete:failure'));
forward(REFERER);