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 @@ -3,23 +3,6 @@ * 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 * 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 '' . _("Free") . ''; if ($shift_mode > 8 * 3600) @@ -30,7 +30,7 @@ function User_shift_mode_render($shift_mode) { return '' . _("Current shift ends in") . ''; } -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( '