diff options
-rw-r--r-- | includes/controller/users_controller.php | 2 | ||||
-rw-r--r-- | includes/model/User_model.php | 17 | ||||
-rw-r--r-- | includes/pages/admin_free.php | 2 | ||||
-rw-r--r-- | includes/sys_menu.php | 2 | ||||
-rw-r--r-- | includes/view/User_view.php | 6 |
5 files changed, 6 insertions, 23 deletions
diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php index 77997278..1f3b3677 100644 --- a/includes/controller/users_controller.php +++ b/includes/controller/users_controller.php @@ -50,7 +50,7 @@ function user_controller() { return array( $user_source['Nick'], - User_view($user_source, $admin_user_privilege, User_is_freeloader($user_source), User_shift_state($user_source), User_angeltypes($user_source), User_groups($user_source), $shifts, $user['UID'] == $user_source['UID']) + User_view($user_source, $admin_user_privilege, User_is_freeloader($user_source), User_angeltypes($user_source), User_groups($user_source), $shifts, $user['UID'] == $user_source['UID']) ); } diff --git a/includes/model/User_model.php b/includes/model/User_model.php index 45600676..7d2809f7 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -4,23 +4,6 @@ */ /** - * 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 diff --git a/includes/pages/admin_free.php b/includes/pages/admin_free.php index 836197db..13d4f795 100644 --- a/includes/pages/admin_free.php +++ b/includes/pages/admin_free.php @@ -49,7 +49,7 @@ function admin_free() { $free_users_table[] = array( 'name' => User_Nick_render($usr), - 'shift_state' => User_shift_mode_render(User_shift_state($usr)), + 'shift_state' => User_shift_state_render($usr), 'dect' => $usr['DECT'], 'jabber' => $usr['jabber'], 'email' => $usr['email'], diff --git a/includes/sys_menu.php b/includes/sys_menu.php index 89c07572..790ca3b2 100644 --- a/includes/sys_menu.php +++ b/includes/sys_menu.php @@ -19,7 +19,7 @@ function header_toolbar() { $toolbar_items = array(); if (isset($user)) - $toolbar_items[] = toolbar_item_link('#', 'time', User_shift_mode_render(User_shift_state($user))); + $toolbar_items[] = toolbar_item_link('#', 'time', User_shift_state_render(User_shift_state($user))); $toolbar_items[] = make_langselect(); diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 1824a1c4..e5405835 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -19,7 +19,7 @@ $tshirt_sizes = array( 'XL-G' => "XL Girl" ); -function User_shift_mode_render($shift_mode) { +function User_shift_state_render($user) { if ($shift_mode == 0) return '<span class="text-success">' . _("Free") . '</span>'; if ($shift_mode > 8 * 3600) @@ -30,7 +30,7 @@ function User_shift_mode_render($shift_mode) { return '<span class="text-danger moment-countdown" data-seconds="' . $shift_mode . '">' . _("Current shift ends in") . '</span>'; } -function User_view($user_source, $admin_user_privilege, $freeloader, $user_shift_mode, $user_angeltypes, $user_groups, $shifts, $its_me) { +function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) { global $LETZTES_AUSTRAGEN, $privileges; $user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']); @@ -106,7 +106,7 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_shift div('col-md-3', array( '<h4>' . _("User state") . '</h4>', ($admin_user_privilege && $freeloader) ? '<span class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> ' . _("Freeloader") . '</span><br />' : '', - $user_source['Gekommen'] ? User_shift_mode_render($user_shift_mode) . '<br />' : '', + $user_source['Gekommen'] ? User_shift_state_render($user_source) . '<br />' : '', ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _("Arrived") . '</span>' : '<span class="text-danger">' . _("Not arrived") . '</span>'), ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' <span class="text-success">' . _("Active") . '</span>' : '', ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _("T-Shirt") . '</span>' : '' |