From 142871f852c717319608de43d954180f17e5ed66 Mon Sep 17 00:00:00 2001 From: MichiK Date: Sun, 3 Dec 2017 04:05:02 +0100 Subject: 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. --- includes/model/ShiftSignupState.php | 5 +++++ includes/model/Shifts_model.php | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'includes/model') diff --git a/includes/model/ShiftSignupState.php b/includes/model/ShiftSignupState.php index 8d588de3..a2618cf1 100644 --- a/includes/model/ShiftSignupState.php +++ b/includes/model/ShiftSignupState.php @@ -38,6 +38,11 @@ class ShiftSignupState */ const SHIFT_ENDED = 'SHIFT_ENDED'; + /** + * Shift is not available yet + */ + const NOT_YET = 'NOT_YET'; + /** * User is already signed up */ diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 6f422c32..6bb17cf2 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -325,6 +325,10 @@ function Shift_signup_allowed_angel( 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)) { $user_shifts = Shifts_by_user($user->id); } -- cgit v1.2.3-70-g09d2