From f5a094fd8b32d44767f7fc30a65f407f4e1d9945 Mon Sep 17 00:00:00 2001 From: Philip Häusler Date: Sat, 23 Aug 2014 01:55:18 +0200 Subject: add user view, better bootstrap --- includes/model/User_model.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'includes/model/User_model.php') diff --git a/includes/model/User_model.php b/includes/model/User_model.php index c8c48e6c..45600676 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -3,6 +3,34 @@ * User model */ +/** + * Returns -seconds until free if user is busy or seconds until next shift. + * 0 if there is an error or no upcoming shift. + * + * @param User $user + */ +function User_shift_state($user) { + $shifts = ShiftEntries_upcoming_for_user($user); + if ($shifts === false) + return 0; + if (count($shifts) == 0) + return 0; + if ($shifts[0]['start'] < time()) + return $shifts[0]['end'] - time(); + return $shifts[0]['start'] - time(); +} + +/** + * Returns true if user is freeloader + * + * @param User $user + */ +function User_is_freeloader($user) { + global $max_freeloadable_shifts, $user; + + return count(ShiftEntries_freeloaded_by_user($user)) >= $max_freeloadable_shifts; +} + /** * Returns all users that are not member of given angeltype. * -- cgit v1.2.3-70-g09d2