Completed
Branch FVSv2 (bb4b20)
by Patrick
03:23
created

api/v1/shift_api.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
function shiftGroup()
4
{
5
    global $app;
6
    $app->get('(/)', 'getCurrentShiftList');
7
}
8
9
function getCurrentShiftList()
10
{
11
    global $app;
12
    if(!$app->user)
13
    {
14
        throw new Exception('Must be logged in', ACCESS_DENIED);
15
    }
16
    $dataSet = DataSetFactory::get_data_set('fvs');
0 ignored issues
show
Deprecated Code introduced by
The method DataSetFactory::get_data_set() has been deprecated with message: 2.0.0 Utilize the getDataSetByName() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
17
    $dataTable = $dataSet['shifts'];
18
    $ret = false;
19
    if($app->user->isInGroupNamed('VolunteerAdmins'))
20
    {
21
        $ret = $dataTable->read($app->odata->filter, $app->odata->select, $app->odata->top, $app->odata->skip, $app->odata->orderby);
22
    }
23
    else
24
    {
25
        $myDept = false;
26
        if($app->user->isInGroupNamed('Lead'))
27
        {
28
            $myDept = \Volunteer\Shifts::getShiftsForLead($app->user, $app->odata->select);
29
        }
30
        $depts = \Volunteer\Shifts::getPublicShifts($app->odata->select);
31
        if($myDept)
32
        {
33
            $depts = array_merge($depts, $myDept);
34
        }
35
        $ret = $depts;
36
    }
37
    echo json_encode($ret);
38
}
39
40
?>
41