From 9d0105c8d965c5433db3a5280376caa0d0fe3433 Mon Sep 17 00:00:00 2001 From: Esteban Sanchez Date: Wed, 20 May 2009 13:24:50 +0000 Subject: [PATCH] 2009-05-20 Esteban Sanchez * general/ui/agents_list.php: Fixed searching filter. Added pagination via AJAX. * godmode/alerts/configure_alert_template.php: Typo error. * images/application_edit.png, images/suc.png, images/err.png: Tiny changes. * images/application_not_writable.png: Added to repository. * include/styles/pandora.css: Make success and error messages a little bit narrower. Typo error. * include/functions.php: Style corrections in safe_input(). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1698 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 27 ++- pandora_console/general/ui/agents_list.php | 213 ++++++++---------- .../alerts/configure_alert_template.php | 2 +- pandora_console/images/application_edit.png | Bin 660 -> 623 bytes .../images/application_not_writable.png | Bin 0 -> 456 bytes pandora_console/images/err.png | Bin 1603 -> 1140 bytes pandora_console/images/suc.png | Bin 1619 -> 1165 bytes pandora_console/include/functions.php | 4 +- pandora_console/include/styles/pandora.css | 4 +- 9 files changed, 127 insertions(+), 123 deletions(-) create mode 100644 pandora_console/images/application_not_writable.png diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 5f090365d3..0024bbea98 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,20 @@ +2009-05-20 Esteban Sanchez + + * general/ui/agents_list.php: Fixed searching filter. Added pagination + via AJAX. + + * godmode/alerts/configure_alert_template.php: Typo error. + + * images/application_edit.png, images/suc.png, images/err.png: Tiny + changes. + + * images/application_not_writable.png: Added to repository. + + * include/styles/pandora.css: Make success and error messages a little + bit narrower. Typo error. + + * include/functions.php: Style corrections in safe_input(). + 2009-05-19 Evi Vanoost * include/functions_incidents.php: Removed upgrade_inc13to21. An old @@ -8,7 +25,6 @@ * include/functions_ui.php: Added $config['ignore_callback']. Useful if you decide to flush the buffers (eg. to offer a download) - * include/functions_db.php: Cleaned up get_db_all_rows_filter and added some documentation and todo's. Added get_agentmodule_data to get all datapoints of a module. Cleaned up get_agentmodule_data_average @@ -19,6 +35,15 @@ * include/exportdata.php: Rewritten. Added filters for group. Works using functions and export into HTML, CSV and Excel with the option for expansion (specify the delimiter values) +svn co +2009-05-19 Esteban Sanchez + + * operation/agentes/status_monitor.php: Many fixes in the code for + pagination. Fixes #2762175 + + * images/networkmap/4.png, images/networkmap/firewall.png, + images/networkmap/7.png, images/networkmap/9.png, + images/networkmap/printer.png: Updated with tango icons. 2009-05-19 Esteban Sanchez diff --git a/pandora_console/general/ui/agents_list.php b/pandora_console/general/ui/agents_list.php index 0851f4ac62..b7160cc68b 100644 --- a/pandora_console/general/ui/agents_list.php +++ b/pandora_console/general/ui/agents_list.php @@ -22,74 +22,33 @@ require_once ('include/functions_agents.php'); if (is_ajax ()) { $search_agents = (bool) get_parameter ('search_agents'); + $show_filter_form = (bool) get_parameter ('show_filter_form', false); + $access = (string) get_parameter ('access', 'AR'); + + $filter = str_replace ("\\\"", "\"", $_POST['filter']); + $filter = json_decode ($filter, true); + $id_group = (int) get_parameter ('id_group'); + if ($id_group > 1 && give_acl ($config['id_user'], $id_group, $access)) + $filter['id_grupo'] = $id_group; + else + $filter['id_grupo'] = array_keys (get_user_groups (false, $access)); + + $fields = ''; + if (isset ($_POST['fields'])) + $fields = json_decode (str_replace ("\\\"", "\"", $_POST['fields'])); + + $table_heads = array (); + if (isset ($_POST['table_heads'])) + $table_heads = json_decode (str_replace ("\\\"", "\"", $_POST['table_heads'])); + $table_size = array (); + if (isset ($_POST['table_size'])) + $table_size = json_decode (str_replace ("\\\"", "\"", $_POST['table_size'])); + $table_size = array (); + if (isset ($_POST['table_align'])) + $table_align = json_decode (str_replace ("\\\"", "\"", $_POST['table_align'])); + $table_renders = str_replace ("\\\"", "\"", $_POST['table_renders']); + $table_renders = json_decode ($table_renders, true); - if ($search_agents) { - require_once ('include/functions_ui_renders.php'); - - $filter = str_replace ("\\\"", "\"", $_POST['filter']); - $filter = json_decode ($filter, true); - $fields = ''; - if (isset ($_POST['fields'])) - $fields = json_decode (str_replace ("\\\"", "\"", $_POST['fields'])); - - $table_renders = str_replace ("\\\"", "\"", $_POST['table_renders']); - $table_renders = json_decode ($table_renders, true); - $access = (string) get_parameter ('access', 'AR'); - - foreach ($_POST as $field => $value) { - $value = safe_input ($value); - switch ($field) { - case 'page': - case 'search_agents': - case 'table_renders': - case 'fields': - case 'filter': - case 'access': - continue; - case 'search': - array_push ($filter, '(nombre LIKE "%'.$value.'%" OR comentarios LIKE "%'.$value.'%")'); - break; - case 'id_group': - if ($value == 1) - $filter['id_grupo'] = array_keys (get_user_groups (false, $value)); - else - $filter['id_grupo'] = $value; - break; - default: - $filter[$field] = $value; - } - } - - $total_agents = get_agents ($filter, array ('COUNT(*) AS total'), $access); - - if ($total_agents !== false) - $total_agents = $total_agents[0]['total']; - else - $total_agents = 0; - $filter['limit'] = $config['block_size']; - $filter['offset'] = (int) get_parameter ('offset'); - $agents = get_agents ($filter, $fields, $access); - - $all_data = array (); - if ($agents !== false) { - foreach ($agents as $agent) { - $data = array (); - foreach ($table_renders as $name => $values) { - if (! is_numeric ($name)) { - array_push ($data, render_agent_field (&$agent, $name, $values, true)); - } else { - array_push ($data, render_agent_field (&$agent, $values, false, true)); - } - } - array_push ($all_data, $data); - } - } - - echo json_encode ($all_data); - - return; - } - return; } require_once ('include/functions_ui_renders.php'); @@ -122,7 +81,7 @@ if ($show_filter_form) { if ($odd) $data = array (); $data[] = __('Search'); - $data[] = print_input_text ('search', '', '', 15, 255, true); + $data[] = print_input_text ('search_string', '', '', 15, 255, true); if (! $odd) array_push ($table->data, $data); $odd = !$odd; @@ -140,13 +99,13 @@ if ($show_filter_form) { require_jquery_file ('form'); } -$table->width = '90%'; -$table->id = 'agents_table'; -$table->head = $table_heads; -$table->align = $table_align; -$table->size = $table_size; -$table->style = array (); -$table->data = array (); +if (! isset ($filter) || ! is_array ($filter)) + $filter = array (); + +$search_string = (string) get_parameter ('search_string'); +if ($search_string != '') { + $filter[] = '(nombre LIKE "%'.$search_string.'%" OR comentarios LIKE "%'.$search_string.'%" OR direccion LIKE "%'.$search_string.'%")'; +} $total_agents = get_agents ($filter, array ('COUNT(*) AS total'), $access); if ($total_agents !== false) @@ -159,15 +118,25 @@ $agents = get_agents ($filter, $fields, $access); unset ($filter['limit']); unset ($filter['offset']); -echo ''; +if (! is_ajax ()) { + echo ''; +} echo ''; + +if (is_ajax ()) + return; ?>