diff options
author | msquare <msquare@notrademark.de> | 2017-12-19 20:58:01 +0100 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2017-12-19 20:58:01 +0100 |
commit | fd85034e7f2277730f4ea4de49dade6d125832dd (patch) | |
tree | 54017bb754302b578838479d8f4d68f4a92010dd /includes/model | |
parent | 567ed9ebd2603a5deb9c171b4d969f7188414794 (diff) |
redo shift signoff and icons for delete/confirm/acknowledgment questions
Diffstat (limited to 'includes/model')
-rw-r--r-- | includes/model/ShiftEntry_model.php | 21 | ||||
-rw-r--r-- | includes/model/Shifts_model.php | 32 |
2 files changed, 49 insertions, 4 deletions
diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php index bcc28f05..01b2369e 100644 --- a/includes/model/ShiftEntry_model.php +++ b/includes/model/ShiftEntry_model.php @@ -134,13 +134,26 @@ function ShiftEntry($shift_entry_id) /** * Delete a shift entry. * - * @param int $shift_entry_id + * @param array $shiftEntry */ -function ShiftEntry_delete($shift_entry_id) +function ShiftEntry_delete($shiftEntry) { - $shift_entry = ShiftEntry($shift_entry_id); - mail_shift_removed(User($shift_entry['UID']), Shift($shift_entry['SID'])); + mail_shift_removed(User($shiftEntry['UID']), Shift($shiftEntry['SID'])); DB::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]); + + $signout_user = User($shiftEntry['UID']); + $shift = Shift($shiftEntry['SID']); + $shifttype = ShiftType($shift['shifttype_id']); + $room = Room($shift['RID']); + $angeltype = AngelType($shiftEntry['TID']); + + engelsystem_log( + 'Shift signout: '. User_Nick_render($signout_user) . ' from shift ' . $shifttype['name'] + . ' at ' . $room['Name'] + . ' from ' . date('Y-m-d H:i', $shift['start']) + . ' to ' . date('Y-m-d H:i', $shift['end']) + . ' as ' . $angeltype['name'] + ); } /** 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 @@ -403,6 +403,38 @@ function Shift_signup_allowed_admin($needed_angeltype, $shift_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. * * @param array $signup_user |