Shift sign up: Allow Supporters to signup users to occupied shifts

This commit is contained in:
Igor Scheller 2020-12-26 21:06:15 +01:00 committed by msquare
parent d423bb07d3
commit 28e357acd3
2 changed files with 7 additions and 19 deletions

View File

@ -151,24 +151,6 @@ function shift_entry_create_controller_supporter($shift, $angeltype)
throw_redirect(shift_link($shift));
}
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype);
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
$shift_signup_state = Shift_signup_allowed(
$signup_user,
$shift,
$angeltype,
null,
null,
$needed_angeltype,
$shift_entries
);
if (!$shift_signup_state->isSignupAllowed()) {
if ($shift_signup_state->getState() == ShiftSignupState::OCCUPIED) {
error(__('This shift is already occupied.'));
}
throw_redirect(shift_link($shift));
}
if ($request->hasPostData('submit')) {
ShiftEntry_create([
'SID' => $shift['SID'],

View File

@ -82,7 +82,13 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
$user_angeltype = UserAngelType_by_User_and_AngelType(auth()->user()->id, $angeltype);
}
if (isset($angeltype['shift_signup_state']) && $angeltype['shift_signup_state']->isSignupAllowed()) {
if (
isset($angeltype['shift_signup_state'])
&& (
$angeltype['shift_signup_state']->isSignupAllowed()
|| User_is_AngelType_supporter(auth()->user(), $angeltype)
)
) {
return button(shift_entry_create_link($shift, $angeltype), __('Sign up'));
} elseif (empty($user_angeltype)) {
return button(