summaryrefslogtreecommitdiff
path: root/tasks_api.php
blob: e65b0e95b5a40ef4a11bed4a1fcf0d7a7793a6cd (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
<?php
namespace mcoop;
require_once("common/config.php");

function get_all_tasks_simple($db) {
	$tasks = SimpleTask::get_all_simple($db);
	foreach ($tasks as $k => $task) {
		$task->load_admin($db);
		$task->load_tdcs($db, false);
	}
	header("Content-Type: application/json");
	// TODO: this should probably use tasks->to_json instead so as to not serialize more than needed
	echo json_encode($tasks);
	//var_dump($tasks);
}

$mapping = array(
	"get_all_tasks_simple" => "\mcoop\get_all_tasks_simple"
);

if (isset($_GET["action"])) {
	$action = $_GET["action"];
	if (array_key_exists($action, $mapping)) {
		$funcname = $mapping[$action];
		$funcname($db);
	}
}
?>