From 71976b83e56c49300722e04dd7f02bd63d076d90 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Wed, 1 Sep 2010 08:03:20 +0000 Subject: [PATCH] 2010-09-01 Sergio Martin * operation/agentes/alerts_status.php operation/search_alerts.php: Fixed the search of alerts in alerts view and in main search git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3210 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 +++ .../operation/agentes/alerts_status.php | 2 +- pandora_console/operation/search_alerts.php | 37 ++++--------------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d482e55db3..d97b70387b 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2010-09-01 Sergio Martin + + * operation/agentes/alerts_status.php + operation/search_alerts.php: Fixed the search of + alerts in alerts view and in main search + 2010-08-31 Sergio Martin * operation/events/export_csv.php: Fixed ACLs to avoid diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index c3288afa68..a854c37fc4 100644 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -90,7 +90,7 @@ 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 ' . + 'talert_template_modules.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 . '%"))' . ')'; diff --git a/pandora_console/operation/search_alerts.php b/pandora_console/operation/search_alerts.php index 09f15d229c..5d4a379072 100755 --- a/pandora_console/operation/search_alerts.php +++ b/pandora_console/operation/search_alerts.php @@ -95,10 +95,14 @@ $alerts = false; if($searchAlerts) { $agents = array_keys(get_group_agents(array_keys(get_user_groups($config["id_user"], 'AR', false)))); - /*$whereAlerts = ' AND (t2.nombre LIKE "%'.$stringSearchSQL.'%" OR t3.nombre LIKE "%'.$stringSearchSQL.'%" - OR t4.name LIKE "%'.$stringSearchSQL.'%") ';*/ + $whereAlerts = 'AND (' . + 'id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE "%' . $stringSearchSQL . '%") OR ' . + 'id_alert_template IN (SELECT id FROM talert_templates WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $stringSearchSQL . '%")) OR ' . + 'talert_template_modules.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 "%' . $stringSearchSQL . '%")) OR ' . + 'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE "%' . $stringSearchSQL . '%") OR ' . + 'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN (SELECT id_agente FROM tagente WHERE nombre LIKE "%' . $stringSearchSQL . '%"))' . + ')'; - $whereAlerts = false; $alertsraw = get_agent_alerts_simple ($agents, "all_enabled", array('offset' => get_parameter ('offset',0), 'limit' => $config['block_size'], 'order' => $order['field'] . " " . $order['order']), $whereAlerts); $stringSearchPHP = substr($stringSearchSQL,1,strlen($stringSearchSQL)-2); @@ -113,38 +117,11 @@ if($searchAlerts) { $alerts[$key]['template_name'] = $alert['template_name']; $actions = get_alert_agent_module_actions($alert['id']); - // Check substring into agent, module, template and action names - if(strpos($alert['agent_name'], $stringSearchPHP) !== false) { - $finded = true; - } - - if(!$finded) { - if(strpos($alert['agent_module_name'], $stringSearchPHP) !== false) { - $finded = true; - } - } - - if(!$finded) { - if(strpos($alert['template_name'], $stringSearchPHP) !== false) { - $finded = true; - } - } - foreach($actions as $action) { $actions_name[] = $action['name']; - - if(!$finded) { - if(strpos($action['name'], $stringSearchPHP) !== false) { - $finded = true; - } - } } $alerts[$key]['actions'] = implode(',',$actions_name); - - if(!$finded) { - unset($alerts[$key]); - } } $totalAlerts = count($alerts);