From 8aaa4f5d04778c070df5ace3331a852ce0585b36 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 15 Sep 2009 13:56:48 +0000 Subject: [PATCH] 2009-09-15 Miguel de Dios * include/functions_db.php: add function "get_db_value_sql" for use in alert_list.php and in futures uses. This function returns the first column and first row from a query pass as parameters. * godmode/alerts/alert_list.php: fix bug that you can't add new alerts. Fixes: 2859264 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1943 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 12 ++++++++++-- pandora_console/godmode/alerts/alert_list.php | 2 +- pandora_console/include/functions_db.php | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e7a198495b..cd41bc34fc 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,11 +1,19 @@ -2009-09-14 Miguel de Dios +2009-09-15 Miguel de Dios + + * include/functions_db.php: add function "get_db_value_sql" for use in + alert_list.php and in futures uses. This function returns the first column + and first row from a query pass as parameters. + * godmode/alerts/alert_list.php: fix bug that you can't add new alerts. + Fixes: 2859264 + +2009-09-15 Miguel de Dios * godmode/agentes/module_manager.php: change the method for test if a module is a numeric, and can normalize. Now obtain the ids from modules tipe that it's not proc or string, and this ids use to test. Fixes: 2849325 -2009-09-14 Miguel de Dios +2009-09-15 Miguel de Dios * godmode/reporting/map_builder.php: change (at the moment) the ajax for delete elements by html static form with select, because sometimes (when you diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index cdd7685e12..f04123cfa5 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -109,7 +109,7 @@ if ($create_alert) { $id_alert_template = (int) get_parameter ('template'); $id_agent_module = (int) get_parameter ('id_agent_module'); - if (get_db_row_sql("SELECT COUNT(id) + if (get_db_value_sql("SELECT COUNT(id) FROM talert_template_modules WHERE id_agent_module = " . $id_agent_module . " AND id_alert_template = " . $id_alert_template) > 0) { diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 82b788395d..f703834bf9 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -1604,6 +1604,24 @@ function get_db_value_filter ($field, $table, $filter, $where_join = 'AND') { return $result[0][$field]; } +/** + * Get the first value of the first row of a table result from query. + * + * @param string SQL select statement to execute. + * + * @return the first value of the first row of a table result from query. + * + */ +function get_db_value_sql ($sql) { + $sql .= " LIMIT 1"; + $result = get_db_all_rows_sql ($sql); + + if($result === false) + return false; + + return $result[0][0]; +} + /** * Get the first row of an SQL database query. *