forked from anuko/timetracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_route_projects.php
More file actions
31 lines (26 loc) · 939 Bytes
/
api_route_projects.php
File metadata and controls
31 lines (26 loc) · 939 Bytes
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
<?php
import('ttConfigHelper');
function handle_req_projects($params,$body,$user) {
$action = "list";
if(count($params)>0) {
$action = $params[0];
}
switch($action) {
case 'list':
echo json_encode(list_projects($user));
break;
}
}
function list_projects($user) {
$config = new ttConfigHelper($user->getConfig());
if ($user->can('track_time')) {
$rank = $user->getMaxRankForGroup($group_id);
if ($user->can('track_own_time'))
$options = array('status'=>ACTIVE,'max_rank'=>$rank,'include_self'=>true,'self_first'=>true);
else
$options = array('status'=>ACTIVE,'max_rank'=>$rank);
$user_list = $user->getUsers($options);
}
$options['include_templates'] = $user->isPluginEnabled('tp') && $config->getDefinedValue('bind_templates_with_projects');
return $user->getAssignedProjects($options);
}