forked from temperatio/collabtive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
80 lines (75 loc) · 1.87 KB
/
api.php
File metadata and controls
80 lines (75 loc) · 1.87 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
require("./init.php");
// variables
$action = getArrayVal($_GET, "action");
$id = getArrayVal($_GET, "id");
$user = getArrayVal($_GET, "user");
// output in xml or json
$mode = getArrayVal($_GET, "mode");
// create new array to xml converter
$xml = new toXml();
// Projects
if ($action == "project.get")
{
$obj = (object) new project();
$theData = $obj->getProject($id);
$theRootNode = "project";
} elseif ($action == "myprojects.get")
{
$obj = (object) new project();
$theData = $obj->getMyProjects($id);
$theRootNode = "myprojects";
} elseif ($action == "project.members.get")
{
$obj = (object) new project();
$theData = $obj->getProjectMembers($id);
$theRootNode = "members";
}
// Users
elseif ($action == "user.profile.get")
{
$obj = (object) new user();
$theData = $obj->getProfile($id);
$theRootNode = "user";
} elseif ($action == "user.id.get")
{
$obj = (object) new user();
$theData = $obj->getId($id);
$theRootNode = "user";
} elseif ($action == "user.list.get")
{
$obj = (object) new user();
$theData = $obj->getAllUsers(100000);
$theRootNode = "userlist";
} elseif ($action == "user.tasks.get")
{
$obj = (object) new task();
$project = new project();
$myprojects = $project->getMyProjects($user);
$theData = array();
foreach($myprojects as $proj)
{
$theArr = $obj->getAllMyProjectTasks($proj["ID"], 10000, $user);
array_push($theData, $theArr);
}
$theData = reduceArray($theData);
$sort = array();
foreach($theData as $data)
{
array_push($sort, $data["ID"]);
}
array_multisort($sort, SORT_NUMERIC, SORT_ASC, $theData);
$theRootNode = "tasks";
}
// convert to XML or JSON
if ($mode == "json")
{
$theXml = $xml->arrToJSON($theData);
}
else
{
$theXml = $xml->arrToXml($theData, $theRootNode);
}
// output to the user
echo $theXml;
?>