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