summaryrefslogtreecommitdiff
path: root/includes/controller/angeltypes_controller.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-11-12 14:41:23 +0100
committermsquare <msquare@notrademark.de>2018-12-02 12:53:31 +0100
commitc33940f64a1e5b59afd700010247382f5b7b2df3 (patch)
tree453b8810c90cd78e75a1425a4f4f002e585d121a /includes/controller/angeltypes_controller.php
parent951828a4f1175f99666a48629ea125640cc7c598 (diff)
Moved permission checks to Authenticator class
Diffstat (limited to 'includes/controller/angeltypes_controller.php')
-rw-r--r--includes/controller/angeltypes_controller.php26
1 files changed, 9 insertions, 17 deletions
diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php
index 821d101a..6e78db45 100644
--- a/includes/controller/angeltypes_controller.php
+++ b/includes/controller/angeltypes_controller.php
@@ -78,9 +78,7 @@ function angeltypes_about_controller()
*/
function angeltype_delete_controller()
{
- global $privileges;
-
- if (!in_array('admin_angel_types', $privileges)) {
+ if (!auth()->can('admin_angel_types')) {
redirect(page_link_to('angeltypes'));
}
@@ -105,10 +103,8 @@ function angeltype_delete_controller()
*/
function angeltype_edit_controller()
{
- global $privileges;
-
// In supporter mode only allow to modify description
- $supporter_mode = !in_array('admin_angel_types', $privileges);
+ $supporter_mode = !auth()->can('admin_angel_types');
$request = request();
if ($request->has('angeltype_id')) {
@@ -178,10 +174,9 @@ function angeltype_edit_controller()
*/
function angeltype_controller()
{
- global $privileges;
$user = auth()->user();
- if (!in_array('angeltypes', $privileges)) {
+ if (!auth()->can('angeltypes')) {
redirect(page_link_to('/'));
}
@@ -210,8 +205,8 @@ function angeltype_controller()
$angeltype,
$members,
$user_angeltype,
- in_array('admin_user_angeltypes', $privileges) || $user_angeltype['supporter'],
- in_array('admin_angel_types', $privileges),
+ auth()->can('admin_user_angeltypes') || $user_angeltype['supporter'],
+ auth()->can('admin_angel_types'),
$user_angeltype['supporter'],
$user_driver_license,
$user,
@@ -250,11 +245,9 @@ function angeltype_controller_shiftsFilterDays($angeltype)
*/
function angeltype_controller_shiftsFilter($angeltype, $days)
{
- global $privileges;
-
$request = request();
$shiftsFilter = new ShiftsFilter(
- in_array('user_shifts_admin', $privileges),
+ auth()->can('user_shifts_admin'),
Room_ids(),
[$angeltype['id']]
);
@@ -278,10 +271,9 @@ function angeltype_controller_shiftsFilter($angeltype, $days)
*/
function angeltypes_list_controller()
{
- global $privileges;
$user = auth()->user();
- if (!in_array('angeltypes', $privileges)) {
+ if (!auth()->can('angeltypes')) {
redirect(page_link_to('/'));
}
@@ -296,7 +288,7 @@ function angeltypes_list_controller()
)
];
- if (in_array('admin_angel_types', $privileges)) {
+ if (auth()->can('admin_angel_types')) {
$actions[] = button(
page_link_to('angeltypes', ['action' => 'edit', 'angeltype_id' => $angeltype['id']]),
__('edit'),
@@ -340,7 +332,7 @@ function angeltypes_list_controller()
return [
angeltypes_title(),
- AngelTypes_list_view($angeltypes, in_array('admin_angel_types', $privileges))
+ AngelTypes_list_view($angeltypes, auth()->can('admin_angel_types'))
];
}