From 5667fc2326d45ed7ebc344bdcea486dd4c2789de Mon Sep 17 00:00:00 2001 From: Tim Neumann Date: Wed, 4 Nov 2020 17:52:09 +0100 Subject: [PATCH] Allow specifying the deadline for signup in terms of shift length Allow finer control over the specification of the time after shift start where signup is still allowed. The new config field is multiplied by the shift duration, and the result added to the start time to determine the time when signup is closed. The existing signup_post_minutes is just added to the time calculated by this new feature. The feature is useful when the signup should be allowed not just a few minutes after shift start but for a larger part of the shift (like for half of the shift). With the previous option it would not make sense to allow a late signup longer than the shortest shift of the event. This is a follow-up to a50dd9cae09f0167c6ece831d99b975ac5b4af4a --- config/config.default.php | 9 ++++++++- includes/model/Shifts_model.php | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config/config.default.php b/config/config.default.php index 98f41785..041bf6ef 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -207,9 +207,16 @@ return [ // Setting this to 0 disables the feature 'signup_advance_hours' => env('SIGNUP_ADVANCE_HOURS', 0), - // Allow signup this many minutes after the start of the shift + // Allow signup this many minutes after the start of the shift. + // If signup_post_fraction is set, first applies that before adding the number of minutes specified by this. 'signup_post_minutes' => env('SIGNUP_POST_MINUTES', 0), + // Allow signup this fraction of the shift length after the start of the shift. + // Example: If this is set to 1, signup is allowed until the end of a shift + // If this is set to 0.5, signup is allowd for the first half of a shift + // If signup_post_minutes is set, first applies this and then adds the signup_post_minutes on top. + 'signup_post_fraction' => env('SIGNUP_POST_FRACTION', 0), + // Number of hours that an angel has to sign out own shifts 'last_unsubscribe' => env('LAST_UNSUBSCRIBE', 3), diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 107430c0..96ec0033 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -358,7 +358,9 @@ function Shift_signup_allowed_angel( return new ShiftSignupState(ShiftSignupState::SIGNED_UP, $free_entries); } - if (time() > $shift['start'] + config('signup_post_minutes') * 60) { + $shift_post_signup_total_allowed_seconds = (config('signup_post_fraction') * ($shift['end'] - $shift['start'])) + (config('signup_post_minutes') * 60); + + if (time() > $shift['start'] + $shift_post_signup_total_allowed_seconds) { // you can only join if the shift is in future return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries); }