From 98d990a51136260e4a0fba5335f87bd4cb379707 Mon Sep 17 00:00:00 2001 From: darode Date: Mon, 12 Jul 2010 11:42:15 +0000 Subject: [PATCH] 2010-07-12 Dario Rodriguez * operation/search_results.php: fixed bug in search with zero matches and filtering by: maps, reports or graphs. Fixes: #3025607 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2987 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++++++ pandora_console/operation/search_results.php | 21 ++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 2fec92c7e1..5ba3a978b3 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2010-07-12 Dario Rodriguez + + * operation/search_results.php: fixed bug in search with zero matches + and filtering by: maps, reports or graphs. + Fixes: #3025607 + 2010-07-12 Dario Rodriguez * operation/agentes/estado_agente.php: fixed bug with pagination offset diff --git a/pandora_console/operation/search_results.php b/pandora_console/operation/search_results.php index ffe569aabc..fd6b315298 100644 --- a/pandora_console/operation/search_results.php +++ b/pandora_console/operation/search_results.php @@ -73,14 +73,15 @@ if ($searchTab == 'users') { LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0); $users = process_sql($sql); - $sql = "SELECT COUNT(id_user) FROM tusuario + $sql = "SELECT COUNT(id_user) AS count FROM tusuario WHERE fullname LIKE '%" . $stringSearchSQL . "%' OR firstname LIKE '%" . $stringSearchSQL . "%' OR lastname LIKE '%" . $stringSearchSQL . "%' OR middlename LIKE '%" . $stringSearchSQL . "%' OR email LIKE '%" . $stringSearchSQL . "%'"; $totalUsers = get_db_row_sql($sql); - $totalUsers = $totalUsers[0]; + + $totalUsers = $totalUsers['count']; } $alerts = false; @@ -100,7 +101,7 @@ if ($searchTab == 'alerts') { LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0); $alerts = process_sql($sql); - $sql = "SELECT COUNT(t1.id) + $sql = "SELECT COUNT(t1.id) AS count FROM talert_template_modules AS t1 INNER JOIN tagente_modulo AS t2 ON t1.id_agent_module = t2.id_agente_modulo @@ -109,7 +110,7 @@ if ($searchTab == 'alerts') { INNER JOIN talert_templates AS t4 ON t1.id_alert_template = t4.id"; $totalAlerts = get_db_row_sql($sql); - $totalAlerts = $totalAlerts[0]; + $totalAlerts = $totalAlerts['count']; } @@ -120,9 +121,9 @@ if ($searchTab == 'graphs') { LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0); $graphs = process_sql($sql); - $sql = "SELECT COUNT(id_graph) FROM tgraph WHERE name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%'"; + $sql = "SELECT COUNT(id_graph) AS count FROM tgraph WHERE name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%'"; $totalGraphs = get_db_row_sql($sql); - $totalGraphs = $totalGraphs[0]; + $totalGraphs = $totalGraphs['count']; } } @@ -132,9 +133,9 @@ if (($config['search_category'] == 'all') || ($config['search_category'] == 'rep LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0); $reports = process_sql($sql); - $sql = "SELECT COUNT(id_report) FROM treport WHERE name LIKE '%" . $stringSearchSQL . "%'"; + $sql = "SELECT COUNT(id_report) AS count FROM treport WHERE name LIKE '%" . $stringSearchSQL . "%'"; $totalReports = get_db_row_sql($sql); - $totalReports = $totalReports[0]; + $totalReports = $totalReports['count']; } $maps = false; @@ -146,9 +147,9 @@ if (($config['search_category'] == 'all') || ($config['search_category'] == 'map LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0); $maps = process_sql($sql); - $sql = "SELECT COUNT(id) FROM tlayout WHERE name LIKE '%" . $stringSearchSQL . "%'"; + $sql = "SELECT COUNT(id) AS count FROM tlayout WHERE name LIKE '%" . $stringSearchSQL . "%'"; $totalMaps = get_db_row_sql($sql); - $totalMaps = $totalMaps[0]; + $totalMaps = $totalMaps['count']; } }