From fd85034e7f2277730f4ea4de49dade6d125832dd Mon Sep 17 00:00:00 2001 From: msquare Date: Tue, 19 Dec 2017 20:58:01 +0100 Subject: redo shift signoff and icons for delete/confirm/acknowledgment questions --- includes/model/Shifts_model.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'includes/model/Shifts_model.php') diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 8cbbe2aa..f3bb042a 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -402,6 +402,38 @@ function Shift_signup_allowed_admin($needed_angeltype, $shift_entries) return new ShiftSignupState(ShiftSignupState::FREE, $free_entries); } +/** + * Check if an angel can signout from a shift. + * + * @param $shift The shift + * @param $angeltype The angeltype + * @param $signout_user The user that was signed up for the shift + * + * @return bool + */ +function Shift_signout_allowed($shift, $angeltype, $signout_user) { + global $user, $privileges; + + // user shifts admin can sign out any user at any time + if (in_array('user_shifts_admin', $privileges)) { + return true; + } + + // angeltype supporter can sign out any user at any time from their supported angeltype + if ( + in_array('shiftentry_edit_angeltype_supporter', $privileges) + && User_is_AngelType_supporter($user, $angeltype) + ) { + return true; + } + + if($signout_user['UID'] == $user['UID'] && $shift['start'] > time() + config('last_unsubscribe') * 3600) { + return true; + } + + return false; +} + /** * Check if an angel can sign up for given shift. * -- cgit v1.2.3-70-g09d2