diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 63aaab575a..88b07e1125 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2010-04-05 Miguel de Dios + + * include/functions_agents.php: added parameter $where for SQL in function + "get_agent_alerts_compound". + + * operation/agentes/alerts_status.php: use the new free search for filter + the rows of alerts. + + * operation/agentes/alerts_status.functions.php: added parameter in the + function "printFormFilterAlert", the parameter $free_search and add + input text control for free search. + 2010-04-05 Miguel de Dios * include/functions_ui.php: changed some parts of source code in the diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 467b277338..efcfca507a 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -199,7 +199,7 @@ function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = fa * * @return array An array with all combined alerts defined for an agent. */ -function get_agent_alerts_compound ($id_agent = false, $filter = '', $options = false, $idGroup = false, $limit = false, $count = false) { +function get_agent_alerts_compound ($id_agent = false, $filter = '', $options = false, $idGroup = false, $limit = false, $count = false, $where = '') { switch ($filter) { case "notfired": $filter = ' AND times_fired = 0 AND disabled = 0'; @@ -250,8 +250,8 @@ function get_agent_alerts_compound ($id_agent = false, $filter = '', $options = } $sql = sprintf ("SELECT %s FROM talert_compound - WHERE id_agent IN (%s) %s %s", - $selectText, $subQuery, $filter, $limitText); + WHERE id_agent IN (%s) %s %s %s", + $selectText, $subQuery, $where, $filter, $limitText); $alerts = get_db_all_rows_sql ($sql);//debugPrint($sql); diff --git a/pandora_console/operation/agentes/alerts_status.functions.php b/pandora_console/operation/agentes/alerts_status.functions.php index 6e657d949b..8d73e82cb8 100755 --- a/pandora_console/operation/agentes/alerts_status.functions.php +++ b/pandora_console/operation/agentes/alerts_status.functions.php @@ -37,7 +37,7 @@ function validateAlert() { } } -function printFormFilterAlert($id_group, $filter, $url) { +function printFormFilterAlert($id_group, $filter, $free_search, $url) { $table->width = '90%'; $table->data = array (); $table->style = array (); @@ -55,6 +55,11 @@ function printFormFilterAlert($id_group, $filter, $url) { $table->data[0][2] = __('Status'); $table->data[0][3] = print_select ($alert_status_filter, "filter", $filter, 'javascript:this.form.submit();', '', '', true); + $table->data[1][0] = __('Free text for search') + . ' ' . __("Filter by agent name, module name, template name or action name") . ''; + $table->data[1][1] = print_input_text('free_search', $free_search, '', 20, 40, true); + $table->colspan[1][2] = 2; + $table->data[1][2] = print_submit_button(__('Filter'), 'filter_button', false, 'class="sub search"', true); echo '
'; print_table ($table); diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index 91fd1b865e..078500049a 100644 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -27,6 +27,7 @@ $filter = get_parameter ("filter", "all_enabled"); $offset_simple = (int) get_parameter_get ("offset_simple", 0); $offset_combined = (int) get_parameter_get("offset_combined", 0); $id_group = (int) get_parameter ("ag_group", 1); //1 is the All group (selects all groups) +$free_search = get_parameter("free_search", ''); $sec2 = get_parameter_get ('sec2'); $sec2 = safe_url_extraclean ($sec2); @@ -83,20 +84,39 @@ else { print_page_header (__('Alert detail'), "images/bricks.png", false, "alert_validation"); } +if ($free_search != '') { + $whereAlertSimple = 'AND (' . + 'id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE "%' . $free_search . '%") OR ' . + 'id_alert_template IN (SELECT id FROM talert_templates WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $free_search . '%")) OR ' . + 'id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $free_search . '%")) OR ' . + 'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE "%' . $free_search . '%") OR ' . + 'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN (SELECT id_agente FROM tagente WHERE nombre LIKE "%' . $free_search . '%"))' . + ')'; + + $whereAlertCombined = 'AND (' . + 'name LIKE "%' . $free_search . '%" OR ' . + 'id IN (SELECT id_alert_compound FROM talert_compound_elements WHERE id_alert_template_module IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $free_search . '%"))) ' . + ')'; +} +else { + $whereAlertSimple = ''; + $whereAlertCombined = ''; +} + $alerts = array(); -$alerts['alerts_simple'] = get_agent_alerts_simple ($agents, $filter, false, '', false, false, array('block_size' => $config["block_size"], 'offset' => $offset_simple), $idGroup); +$alerts['alerts_simple'] = get_agent_alerts_simple ($agents, $filter, false, $whereAlertSimple, false, false, array('block_size' => $config["block_size"], 'offset' => $offset_simple), $idGroup); $countAlertsSimple = get_agent_alerts_simple ($agents, $filter, false, '', false, false, false, $idGroup, true); -$alerts['alerts_combined'] = get_agent_alerts_compound($agents, $filter, false, $idGroup, array('block_size' => $config["block_size"], 'offset' => $offset_combined)); -$countAlertsCombined = get_agent_alerts_compound($agents, $filter, false, $idGroup, false, true); +$alerts['alerts_combined'] = get_agent_alerts_compound($agents, $filter, false, $idGroup, array('block_size' => $config["block_size"], 'offset' => $offset_combined), false, $whereAlertCombined); +$countAlertsCombined = get_agent_alerts_compound($agents, $filter, false, $idGroup, false, true, $whereAlertCombined); if ($tab != null) { $url = $url.'&tab='.$tab; } // Filter form if ($print_agent) { - printFormFilterAlert($id_group, $filter, $url); + printFormFilterAlert($id_group, $filter, $free_search, $url); } -$table->width = '90%'; +$table->width = '95%'; $table->class = "databox"; $table->size = array ();