Add a config option for maximum signup in advance

We now have `signup_advance_hours` in the configuration that
only allows signup for shifts so many hours in the future.
A notice is displayed in the shift view for shifts in the
far future, together with an info notice on when signup for
that shift will be possible.

In addition, we now have a new shift state `NOT_YET` for this
purpose so we do not have to abuse `SHIFT_ENDED` anymore for
`signup_requires_arrival` as well.
This commit is contained in:
MichiK 2017-12-03 04:05:02 +01:00 committed by msquare
parent ead56a89fe
commit 142871f852
6 changed files with 31 additions and 0 deletions

View File

@ -88,6 +88,10 @@ return [
// Whether newly-registered user should automatically be marked as arrived // Whether newly-registered user should automatically be marked as arrived
'autoarrive' => false, 'autoarrive' => false,
// Only allow shift signup this number of hours in advance
// Setting this to 0 disables the feature
'signup_advance_hours' => 0,
// Number of hours that an angel has to sign out own shifts // Number of hours that an angel has to sign out own shifts
'last_unsubscribe' => 3, 'last_unsubscribe' => 3,

View File

@ -38,6 +38,11 @@ class ShiftSignupState
*/ */
const SHIFT_ENDED = 'SHIFT_ENDED'; const SHIFT_ENDED = 'SHIFT_ENDED';
/**
* Shift is not available yet
*/
const NOT_YET = 'NOT_YET';
/** /**
* User is already signed up * User is already signed up
*/ */

View File

@ -325,6 +325,10 @@ function Shift_signup_allowed_angel(
return new ShiftSignupState(ShiftSignupState::NOT_ARRIVED, $free_entries); return new ShiftSignupState(ShiftSignupState::NOT_ARRIVED, $free_entries);
} }
if (config('signup_advance_hours') && $shift['start'] > time() + config('signup_advance_hours') * 3600) {
return new ShiftSignupState(ShiftSignupState::NOT_YET, $free_entries);
}
if (empty($user_shifts)) { if (empty($user_shifts)) {
$user_shifts = Shifts_by_user($user->id); $user_shifts = Shifts_by_user($user->id);
} }

View File

@ -74,6 +74,7 @@ class ShiftCalendarShiftRenderer
return 'primary'; return 'primary';
case ShiftSignupState::NOT_ARRIVED: case ShiftSignupState::NOT_ARRIVED:
case ShiftSignupState::NOT_YET:
case ShiftSignupState::SHIFT_ENDED: case ShiftSignupState::SHIFT_ENDED:
return 'default'; return 'default';
@ -203,6 +204,10 @@ class ShiftCalendarShiftRenderer
$entry_list[] = $inner_text . ' (' . __('please arrive for signup') . ')'; $entry_list[] = $inner_text . ' (' . __('please arrive for signup') . ')';
break; break;
case ShiftSignupState::NOT_YET:
$entry_list[] = $inner_text . '(' . _('not yet') . ')';
break;
case ShiftSignupState::ANGELTYPE: case ShiftSignupState::ANGELTYPE:
if ($angeltype['restricted'] == 1) { if ($angeltype['restricted'] == 1) {
// User has to be confirmed on the angeltype first // User has to be confirmed on the angeltype first

View File

@ -129,6 +129,13 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt
$content[] = info(__('You are signed up for this shift.'), true); $content[] = info(__('You are signed up for this shift.'), true);
} }
if (config('signup_advance_hours') && $shift['start'] > time() + config('signup_advance_hours') * 3600) {
$content[] = info(sprintf(
_('This shift is in the far future and becomes available for signup at %s.'),
date(_('Y-m-d') . ' H:i', $shift['start'] - config('signup_advance_hours') * 3600)
), true);
}
$buttons = []; $buttons = [];
if ($shift_admin || $admin_shifttypes || $admin_rooms) { if ($shift_admin || $admin_shifttypes || $admin_rooms) {
$buttons = [ $buttons = [

View File

@ -2124,6 +2124,12 @@ msgstr "Eintragen"
msgid "ended" msgid "ended"
msgstr "vorbei" msgstr "vorbei"
msgid "not yet"
msgstr "noch nicht"
msgid "This shift is in the far future and becomes available for signup at %s."
msgstr "Diese Schicht liegt in der fernen Zukunft und du kannst dich ab %s eintragen."
# Wie ist dies zu verstehen bitte? # Wie ist dies zu verstehen bitte?
#: includes/view/ShiftCalendarShiftRenderer.php:203 #: includes/view/ShiftCalendarShiftRenderer.php:203
msgid "please arrive for signup" msgid "please arrive for signup"