summaryrefslogtreecommitdiff
path: root/includes/model/User_model.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/model/User_model.php')
-rw-r--r--includes/model/User_model.php28
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