summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/AngelTypes_view.php4
-rw-r--r--includes/view/Rooms_view.php4
-rw-r--r--includes/view/ShiftCalendarShiftRenderer.php8
-rw-r--r--includes/view/ShiftTypes_view.php3
-rw-r--r--includes/view/Shifts_view.php10
-rw-r--r--includes/view/User_view.php6
6 files changed, 11 insertions, 24 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index ab4ce517..f4e83758 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -564,14 +564,12 @@ function AngelTypes_about_view_angeltype($angeltype)
*/
function AngelTypes_about_view($angeltypes, $user_logged_in)
{
- global $privileges;
-
$buttons = [];
if ($user_logged_in) {
$buttons[] = button(page_link_to('angeltypes'), angeltypes_title(), 'back');
} else {
- if (in_array('register', $privileges) && config('registration_enabled')) {
+ if (auth()->can('register') && config('registration_enabled')) {
$buttons[] = button(page_link_to('register'), register_title());
}
diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php
index 93351e28..4ea78e86 100644
--- a/includes/view/Rooms_view.php
+++ b/includes/view/Rooms_view.php
@@ -64,9 +64,7 @@ function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalen
*/
function Room_name_render($room)
{
- global $privileges;
-
- if (in_array('view_rooms', $privileges)) {
+ if (auth()->can('view_rooms')) {
return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
}
diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php
index 6a01949e..3f427ea0 100644
--- a/includes/view/ShiftCalendarShiftRenderer.php
+++ b/includes/view/ShiftCalendarShiftRenderer.php
@@ -97,8 +97,6 @@ class ShiftCalendarShiftRenderer
*/
private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user)
{
- global $privileges;
-
$shift_entries_filtered = [];
foreach ($needed_angeltypes as $needed_angeltype) {
$shift_entries_filtered[$needed_angeltype['id']] = [];
@@ -130,7 +128,7 @@ class ShiftCalendarShiftRenderer
$shift_signup_state = new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, 0);
}
- if (in_array('user_shifts_admin', $privileges)) {
+ if (auth()->can('user_shifts_admin')) {
$html .= '<li class="list-group-item">';
$html .= button(shift_entry_create_link_admin($shift),
glyph('plus') . __('Add more angels'),
@@ -253,10 +251,8 @@ class ShiftCalendarShiftRenderer
*/
private function renderShiftHead($shift, $class)
{
- global $privileges;
-
$header_buttons = '';
- if (in_array('admin_shifts', $privileges)) {
+ if (auth()->can('admin_shifts')) {
$header_buttons = '<div class="pull-right">' . table_buttons([
button(
page_link_to('user_shifts', ['edit_shift' => $shift['SID']]),
diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php
index 72d119ff..634f9760 100644
--- a/includes/view/ShiftTypes_view.php
+++ b/includes/view/ShiftTypes_view.php
@@ -6,8 +6,7 @@
*/
function ShiftType_name_render($shifttype)
{
- global $privileges;
- if (in_array('shifttypes', $privileges)) {
+ if (auth()->can('shifttypes')) {
return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>';
}
return $shifttype['name'];
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index 4c329f1b..4daaec8e 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -102,12 +102,10 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
*/
function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state)
{
- global $privileges;
-
- $shift_admin = in_array('admin_shifts', $privileges);
- $user_shift_admin = in_array('user_shifts_admin', $privileges);
- $admin_rooms = in_array('admin_rooms', $privileges);
- $admin_shifttypes = in_array('shifttypes', $privileges);
+ $shift_admin = auth()->can('admin_shifts');
+ $user_shift_admin = auth()->can('user_shifts_admin');
+ $admin_rooms = auth()->can('admin_rooms');
+ $admin_shifttypes = auth()->can('shifttypes');
$parsedown = new Parsedown();
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 2b4154b4..275a31ca 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -352,8 +352,6 @@ function User_view_shiftentries($needed_angel_type)
*/
function User_view_myshift($shift, $user_source, $its_me)
{
- global $privileges;
-
$shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
if ($shift['title']) {
$shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>';
@@ -382,7 +380,7 @@ function User_view_myshift($shift, $user_source, $its_me)
$myshift['duration'] = '<p class="text-danger">'
. round(-($shift['end'] - $shift['start']) / 3600 * 2, 2) . '&nbsp;h'
. '</p>';
- if (in_array('user_shifts_admin', $privileges)) {
+ if (auth()->can('user_shifts_admin')) {
$myshift['comment'] .= '<br />'
. '<p class="text-danger">' . __('Freeloaded') . ': ' . $shift['freeload_comment'] . '</p>';
} else {
@@ -393,7 +391,7 @@ function User_view_myshift($shift, $user_source, $its_me)
$myshift['actions'] = [
button(shift_link($shift), glyph('eye-open') . __('view'), 'btn-xs')
];
- if ($its_me || in_array('user_shifts_admin', $privileges)) {
+ if ($its_me || auth()->can('user_shifts_admin')) {
$myshift['actions'][] = button(
page_link_to('user_myshifts', ['edit' => $shift['id'], 'id' => $user_source->id]),
glyph('edit') . __('edit'),