BurningFlipside /
VolunteerSystem
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 deptGroup() |
||
| 4 | { |
||
| 5 | global $app; |
||
| 6 | $app->get('(/)', 'getDepartmentList'); |
||
| 7 | $app->post('(/)', 'createDepartment'); |
||
| 8 | $app->get('/:id(/)', 'getDepartment'); |
||
| 9 | } |
||
| 10 | |||
| 11 | function getDepartmentList() |
||
| 12 | { |
||
| 13 | global $app; |
||
| 14 | if(!$app->user) |
||
| 15 | { |
||
| 16 | throw new Exception('Must be logged in', ACCESS_DENIED); |
||
| 17 | } |
||
| 18 | $dataTable = DataSetFactory::getDataTableByNames('fvs', 'departments'); |
||
|
0 ignored issues
–
show
|
|||
| 19 | $ret = false; |
||
| 20 | if($app->user->isInGroupNamed('VolunteerAdmins')) |
||
| 21 | { |
||
| 22 | if($app->odata->filter !== false && $app->odata->filter->contains('lead eq me')) |
||
| 23 | { |
||
| 24 | $app->odata->filter = false; |
||
| 25 | } |
||
| 26 | $ret = $dataTable->read($app->odata->filter, $app->odata->select, $app->odata->top, $app->odata->skip, $app->odata->orderby); |
||
| 27 | } |
||
| 28 | else |
||
| 29 | { |
||
| 30 | if($app->user->isInGroupNamed('Lead')) |
||
| 31 | { |
||
| 32 | $filter = false; |
||
| 33 | if($app->odata->filter !== false && $app->odata->filter->contains('lead eq me')) |
||
| 34 | { |
||
| 35 | $filter = new \Data\Filter('lead eq '.$app->getUID()); |
||
| 36 | } |
||
| 37 | else |
||
| 38 | { |
||
| 39 | $filter = new \Data\Filter('lead eq '.$app->getUID().' or public eq true'); |
||
| 40 | } |
||
| 41 | $ret = $dataTable->read($filter, $app->odata->select, $app->odata->top, $app->odata->skip, $app->odata->orderby); |
||
| 42 | } |
||
| 43 | else |
||
| 44 | { |
||
| 45 | $filter = new \Data\Filter('public eq true'); |
||
| 46 | $ret = $dataTable->read($filter, $app->odata->select, $app->odata->top, $app->odata->skip, $app->odata->orderby); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | echo json_encode($ret); |
||
| 50 | } |
||
| 51 | |||
| 52 | function createDepartment() |
||
| 53 | { |
||
| 54 | global $app; |
||
| 55 | if(!$app->user) |
||
| 56 | { |
||
| 57 | throw new Exception('Must be logged in', ACCESS_DENIED); |
||
| 58 | } |
||
| 59 | else if(!$app->user->isInGroupNamed('VolunteerAdmins')) |
||
| 60 | { |
||
| 61 | throw new Exception('Must be a volunteer admin to create a department', ACCESS_DENIED); |
||
| 62 | } |
||
| 63 | $obj = $app->getJSONBody(); |
||
| 64 | $dataSet = DataSetFactory::get_data_set('fvs'); |
||
| 65 | $dataTable = $dataSet['departments']; |
||
| 66 | echo json_encode($dataTable->create($obj)); |
||
| 67 | } |
||
| 68 | |||
| 69 | function getDepartment($id) |
||
| 70 | { |
||
| 71 | global $app; |
||
| 72 | if(!$app->user) |
||
| 73 | { |
||
| 74 | throw new Exception('Must be logged in', ACCESS_DENIED); |
||
| 75 | } |
||
| 76 | $dataTable = DataSetFactory::getDataTableByNames('fvs', 'departments'); |
||
|
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...
|
|||
| 77 | $filter = new \Data\Filter("departmentID eq '$id'"); |
||
| 78 | $ret = $dataTable->read($filter, $app->odata->select); |
||
| 79 | if($ret === false || !isset($ret[0])) |
||
| 80 | { |
||
| 81 | $app->notFound(); |
||
| 82 | } |
||
| 83 | echo json_encode($ret[0]); |
||
| 84 | } |
||
| 85 | |||
| 86 |
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.