Completed
Branch FVSv2 (febeab)
by Patrick
03:27
created

api/v1/shift_api.php (1 issue)

Labels
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
    $dataTable = DataSetFactory::getDataTableByNames('fvs', 'shifts');
0 ignored issues
show
The method getDataTableByNames() does not seem to exist on object<DataSetFactory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

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