diff options
author | Philip Häusler <msquare@notrademark.de> | 2014-08-23 01:55:18 +0200 |
---|---|---|
committer | Philip Häusler <msquare@notrademark.de> | 2014-08-23 01:55:18 +0200 |
commit | f5a094fd8b32d44767f7fc30a65f407f4e1d9945 (patch) | |
tree | eac9a223e103c3066ef6e0b57e0bf215eaa89a72 /includes/model/User_model.php | |
parent | 74647e16d37fac9425a4561b49618b52cdc3e75c (diff) |
add user view, better bootstrap
Diffstat (limited to 'includes/model/User_model.php')
-rw-r--r-- | includes/model/User_model.php | 28 |
1 files changed, 28 insertions, 0 deletions
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 @@ -4,6 +4,34 @@ */ /** + * 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. * * @param Angeltype $angeltype |