| Conditions | 5 |
| Paths | 6 |
| Total Lines | 29 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 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'); |
||
| 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 |
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state