Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 0 additions & 18 deletions includes/controller/shift_entries_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
8 changes: 7 additions & 1 deletion includes/view/Shifts_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down