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

main
Igor Scheller 4 years ago committed by msquare
parent d423bb07d3
commit 28e357acd3

@ -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'],

@ -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(

Loading…
Cancel
Save