diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index ac661ac5d0..4a45349d14 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2010-07-18 Miguel de Dios + + * include/auth/mysql.php: added function "get_users" the check to $order + parameter if it is array, extract the field and order. + + * operation/users/user.php, godmode/users/user_list.php: added posibility to + sort by columns ID User, Full name or Last Contanct. + 2010-07-18 Raúl Mateos * operation/incidents/incident_detail.php: Change Add button to links. diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index a839fc165a..ddea02e7c1 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -25,6 +25,57 @@ if (! give_acl ($config['id_user'], 0, "UM")) { exit; } +$sortField = get_parameter('sort_field'); +$sort = get_parameter('sort', 'none'); + +$selected = 'border: 1px solid black;'; +$selectUserIDUp = ''; +$selectUserIDDown = ''; +$selectFullnameUp = ''; +$selectFullnameDown = ''; +$selectLastConnectUp = ''; +$selectLastConnectDown = ''; +$order = null; + +switch ($sortField) { + case 'id_user': + switch ($sort) { + case 'up': + $selectUserIDUp = $selected; + $order = array('field' => 'id_user', 'order' => 'ASC'); + break; + case 'down': + $selectUserIDDown = $selected; + $order = array('field' => 'id_user', 'order' => 'DESC'); + break; + } + break; + case 'fullname': + switch ($sort) { + case 'up': + $selectFullnameUp = $selected; + $order = array('field' => 'fullname', 'order' => 'ASC'); + break; + case 'down': + $selectFullnameDown = $selected; + $order = array('field' => 'fullname', 'order' => 'DESC'); + break; + } + break; + case 'last_connect': + switch ($sort) { + case 'up': + $selectLastConnectUp = $selected; + $order = array('field' => 'fullname', 'order' => 'ASC'); + break; + case 'down': + $selectLastConnectDown = $selected; + $order = array('field' => 'fullname', 'order' => 'DESC'); + break; + } + break; +} + // Header print_page_header (__('User management').' » '.__('Users defined in Pandora'), "images/god3.png", false, "", true); @@ -61,9 +112,15 @@ $table->data = array (); $table->align = array (); $table->size = array (); -$table->head[0] = __('User ID'); -$table->head[1] = __('Name'); -$table->head[2] = __('Last contact'); +$table->head[0] = __('User ID') . ' ' . + '' . + ''; +$table->head[1] = __('Name') . ' ' . + '' . + ''; +$table->head[2] = __('Last contact') . ' ' . + '' . + ''; $table->head[3] = __('Profile'); $table->head[4] = __('Description'); $table->head[5] = ''; @@ -74,8 +131,8 @@ $table->align[5] = "center"; $table->size[5] = 40; $info = array (); -// Get users ordered by id_user -$info = get_users ("id_user",array ('offset' => (int) get_parameter ('offset'), + +$info = get_users ($order, array ('offset' => (int) get_parameter ('offset'), 'limit' => (int) $config['block_size'])); // Prepare pagination diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index d61d2344cd..52c6be2901 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -192,17 +192,22 @@ function get_user_info ($user) { * @return array An array of user information */ function get_users ($order = "fullname", $filter = false, $fields = false) { - switch ($order) { - case "id_user": - case "registered": - case "last_connect": - case "fullname": - break; - default: - $order = "fullname"; + if (is_array($order)) { + $filter['order'] = $order['field'] . ' ' . $order['order']; + } + else { + switch ($order) { + case "registered": + case "last_connect": + case "fullname": + break; + default: + $order = "fullname"; + break; + } + + $filter['order'] = $order." ASC"; } - - $filter['order'] = $order." ASC"; $output = array(); diff --git a/pandora_console/operation/users/user.php b/pandora_console/operation/users/user.php index 72e448d9e1..8a6c59427e 100644 --- a/pandora_console/operation/users/user.php +++ b/pandora_console/operation/users/user.php @@ -20,6 +20,57 @@ global $config; check_login (); +$sortField = get_parameter('sort_field'); +$sort = get_parameter('sort', 'none'); + +$selected = 'border: 1px solid black;'; +$selectUserIDUp = ''; +$selectUserIDDown = ''; +$selectFullnameUp = ''; +$selectFullnameDown = ''; +$selectLastConnectUp = ''; +$selectLastConnectDown = ''; +$order = null; + +switch ($sortField) { + case 'id_user': + switch ($sort) { + case 'up': + $selectUserIDUp = $selected; + $order = array('field' => 'id_user', 'order' => 'ASC'); + break; + case 'down': + $selectUserIDDown = $selected; + $order = array('field' => 'id_user', 'order' => 'DESC'); + break; + } + break; + case 'fullname': + switch ($sort) { + case 'up': + $selectFullnameUp = $selected; + $order = array('field' => 'fullname', 'order' => 'ASC'); + break; + case 'down': + $selectFullnameDown = $selected; + $order = array('field' => 'fullname', 'order' => 'DESC'); + break; + } + break; + case 'last_connect': + switch ($sort) { + case 'up': + $selectLastConnectUp = $selected; + $order = array('field' => 'fullname', 'order' => 'ASC'); + break; + case 'down': + $selectLastConnectDown = $selected; + $order = array('field' => 'fullname', 'order' => 'DESC'); + break; + } + break; +} + // Header print_page_header (__('Pandora users'), "images/group.png", false, "", false, ""); @@ -31,9 +82,15 @@ $table->head = array (); $table->data = array (); $table->align = array (); -$table->head[0] = __('User ID'); -$table->head[1] = __('Name'); -$table->head[2] = __('Last contact'); +$table->head[0] = __('User ID') . ' ' . + '' . + ''; +$table->head[1] = __('Name') . ' ' . + '' . + ''; +$table->head[2] = __('Last contact') . ' ' . + '' . + ''; $table->head[3] = __('Profile'); $table->head[4] = __('Description'); @@ -42,8 +99,8 @@ $table->align[3] = "center"; $info = array (); -// Get users ordered by id_user -$info = get_users ("id_user",array ('offset' => (int) get_parameter ('offset'), + +$info = get_users ($order,array ('offset' => (int) get_parameter ('offset'), 'limit' => (int) $config['block_size'])); //Only the users from the user groups are visible