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 .= '
'; - if ($user_shift_admin || $isUser) { - $entry .= button_icon( - url('/user-myshifts', ['edit' => $shift_entry->id, 'id' => $shift_entry->user_id]), - 'pencil', - 'btn-sm', - __('form.edit') - ); - } + $entry .= button_icon( + url('/user-myshifts', ['edit' => $shift_entry->id, 'id' => $shift_entry->user_id]), + 'pencil', + 'btn-sm', + __('form.edit') + ); $angeltype = $shift_entry->angelType; $disabled = Shift_signout_allowed($shift, $angeltype, $shift_entry->user_id) ? '' : ' btn-disabled'; $entry .= button_icon( diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index d3c9b65e..d62e971a 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -1077,8 +1077,8 @@ msgstr "Schicht Anmeldung" msgid "Freeloaded" msgstr "Geschwänzt" -msgid "Freeload comment (Only for shift coordination):" -msgstr "Schwänzer Kommentar (Nur für die Schicht-Koordination):" +msgid "Freeload comment (Only for shift coordination and supporters):" +msgstr "Schwänzer Kommentar (Nur für Supporter und die Schicht-Koordination):" msgid "Edit shift entry" msgstr "Schichteintrag bearbeiten"