summaryrefslogtreecommitdiff
path: root/includes/controller/users_controller.php
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2014-09-28 15:01:02 +0200
committerPhilip Häusler <msquare@notrademark.de>2014-09-28 15:01:02 +0200
commitbd2a8b441f16c6a1beb0b38e787be3d75a1b8da2 (patch)
treee483ae40f60c416ef7443210e016ff0684a3f56c /includes/controller/users_controller.php
parent1d9e1c467cf4d3920f9bcf0157481c7ca8ea6d5d (diff)
clear up mvc for user list
Diffstat (limited to 'includes/controller/users_controller.php')
-rw-r--r--includes/controller/users_controller.php31
1 files changed, 7 insertions, 24 deletions
diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php
index b1692e21..b24a7fdf 100644
--- a/includes/controller/users_controller.php
+++ b/includes/controller/users_controller.php
@@ -54,6 +54,9 @@ function user_controller() {
);
}
+/**
+ * List all users.
+ */
function users_list_controller() {
global $privileges;
@@ -61,39 +64,19 @@ function users_list_controller() {
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'
- )))
+ if (isset($_REQUEST['OrderBy']) && in_array($_REQUEST['OrderBy'], User_sortable_columns()))
$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");
+ foreach ($users as &$user)
+ $user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user));
return array(
_('All users'),
- Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count)
+ Users_view($users, $order_by, User_arrived_count(), User_active_count(), User_force_active_count(), ShiftEntries_freeleaded_count(), User_tshirts_count())
);
}