diff options
author | Philip Häusler <msquare@notrademark.de> | 2014-09-28 14:50:08 +0200 |
---|---|---|
committer | Philip Häusler <msquare@notrademark.de> | 2014-09-28 14:50:08 +0200 |
commit | 1d9e1c467cf4d3920f9bcf0157481c7ca8ea6d5d (patch) | |
tree | 72e815859ba1fc37d82facdabe5ede76f3823ac4 /includes/controller/users_controller.php | |
parent | 0f77edc4fb5581eacd0305ec9010b78afc489b55 (diff) |
user list rewritten
Diffstat (limited to 'includes/controller/users_controller.php')
-rw-r--r-- | includes/controller/users_controller.php | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php index 1f3b3677..b1692e21 100644 --- a/includes/controller/users_controller.php +++ b/includes/controller/users_controller.php @@ -55,7 +55,46 @@ function user_controller() { } function users_list_controller() { - redirect(page_link_to('admin_user')); + global $privileges; + + if (! in_array('admin_user', $privileges)) + redirect(page_link_to('')); + + $order_by = 'Nick'; + if (isset($_REQUEST['OrderBy']) && in_array($_REQUEST['OrderBy'], array( + 'Nick', + 'Name', + 'Vorname', + 'Alter', + 'DECT', + 'email', + 'Size', + 'Gekommen', + 'Aktiv', + 'force_active', + 'Tshirt', + 'lastLogIn' + ))) + $order_by = $_REQUEST['OrderBy']; + + $users = Users($order_by); + if ($users === false) + engelsystem_error('Unable to load users.'); + + foreach ($users as &$user) { + $user['freeloads'] = sql_select_single_cell("SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1 AND `UID` = " . sql_escape($user['UID'])); + } + + $arrived_count = sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Gekommen` = 1"); + $active_count = sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Aktiv` = 1"); + $force_active_count = sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `force_active` = 1"); + $freeloads_count = sql_select_single_cell("SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1"); + $tshirts_count = sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Tshirt` = 1"); + + return array( + _('All users'), + Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count) + ); } /** |