aboutsummaryrefslogtreecommitdiff
path: root/mod/tasklist/index.php
blob: d8b9edb6d7e32171805188accaf690cea70f8df7 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
	require_once("../../engine/start.php");
	
	global $CONFIG;
	
	$_SESSION['id'] = 2;
	
	// Get the user
	$owner_id = page_owner();
	$owner = get_user(page_owner());
	
	$description = get_input("task");
	$status = get_input("status");
	$action = get_input("action");
	$guid = get_input("guid");
	$tags = get_input("tags");
	
	$limit = get_input("limit",10);
	$offset = get_input("offset",0);
	
	switch ($action)
	{
		case 'newtask' : 
			$taskid = create_entity("object", "task", $owner_id, 0);

			if ($taskid)
			{ 
				$entity = get_entity($taskid);

				$entity->setMetaData('task', $task, 'text');
				$entity->setMetaData('status', 'notdone', 'text');
				
				if ($tags!="")
				{
					$tags = explode(",",$tags);
					
					foreach ($tags as $tag)
					{
						$tag = sanitise_string($tag);
						$entity->setMetaData($tag, $tag);
					}
				}
				
				$entity->save();
			} else echo "error";
			
		break;
		
		case 'tick' :
			$entity = get_entity($guid);
			
			$entity->setMetaData('status', 'done', 'text');
		break;
	}

	$body = elgg_view("tasklist/main", array(
		"name" => $owner->name,
		"tasklist" => tasklist_drawtasks($owner_id, $limit, $offset),
		"newtask" => tasklist_draw_newtask_form($owner_id)
	));
	page_draw("Tasklist",$body);
	
?>