| Conditions | 5 |
| Paths | 6 |
| Total Lines | 30 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 | $dataSet = DataSetFactory::get_data_set('fvs'); |
||
| 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 | |||
| 41 |
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