diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php index 06461f38..6dce5918 100644 --- a/includes/pages/user_myshifts.php +++ b/includes/pages/user_myshifts.php @@ -20,10 +20,18 @@ function user_myshifts() { $user = auth()->user(); $request = request(); + $is_angeltype_supporter = false; + if ($request->has('edit')) { + $id = $request->input('edit'); + $shiftEntry = ShiftEntry::where('id', $id) + ->where('user_id', User::find($request->input('id'))->id) + ->first(); + $is_angeltype_supporter = $shiftEntry && auth()->user()->isAngelTypeSupporter($shiftEntry->angelType); + } if ( $request->has('id') - && auth()->can('user_shifts_admin') + && (auth()->can('user_shifts_admin') || $is_angeltype_supporter) && preg_match('/^\d+$/', $request->input('id')) && User::find($request->input('id')) ) { @@ -61,7 +69,10 @@ function user_myshifts() if ($request->hasPostData('submit')) { $valid = true; - if (auth()->can('user_shifts_admin')) { + if ( + auth()->can('user_shifts_admin') + || $is_angeltype_supporter + ) { $freeloaded = $request->has('freeloaded'); $freeloaded_comment = strip_request_item_nl('freeloaded_comment'); if ($freeloaded && $freeloaded_comment == '') { @@ -91,6 +102,9 @@ function user_myshifts() . '. Freeloaded: ' . ($freeloaded ? 'YES Comment: ' . $freeloaded_comment : 'NO') ); success(__('Shift saved.')); + if ($is_angeltype_supporter) { + throw_redirect(url('/shifts', ['action' => 'view', 'shift_id' => $shiftEntry->shift_id])); + } throw_redirect(url('/users', ['action' => 'view', 'user_id' => $shifts_user->id])); } } @@ -104,13 +118,13 @@ function user_myshifts() $shiftEntry->user_comment, $shiftEntry->freeloaded, $shiftEntry->freeloaded_comment, - auth()->can('user_shifts_admin') + auth()->can('user_shifts_admin'), + $is_angeltype_supporter ); } else { throw_redirect(url('/user-myshifts')); } } - throw_redirect(url('/users', ['action' => 'view', 'user_id' => $shifts_user->id])); return ''; } diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php index 4420b414..d1a34423 100644 --- a/includes/view/ShiftEntry_view.php +++ b/includes/view/ShiftEntry_view.php @@ -205,15 +205,16 @@ function ShiftEntry_edit_view( $comment, $freeloaded, $freeloaded_comment, - $user_admin_shifts = false + $user_admin_shifts = false, + $angeltype_supporter = false ) { $freeload_form = []; - if ($user_admin_shifts) { + if ($user_admin_shifts || $angeltype_supporter) { $freeload_form = [ form_checkbox('freeloaded', __('Freeloaded'), $freeloaded), form_textarea( 'freeloaded_comment', - __('Freeload comment (Only for shift coordination):'), + __('Freeload comment (Only for shift coordination and supporters):'), $freeloaded_comment ), ]; diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index a49ed005..d9b22c41 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -319,14 +319,12 @@ function Shift_view_render_shift_entry(ShiftEntry $shift_entry, $user_shift_admi $isUser = $shift_entry->user_id == auth()->user()->id; if ($user_shift_admin || $angeltype_supporter || $isUser) { $entry .= '