From 1b301758358a118241fff2c54ab033a9bdaba846 Mon Sep 17 00:00:00 2001 From: vgilc Date: Tue, 17 Jan 2012 10:20:53 +0000 Subject: [PATCH] 2012-01-17 Vanessa Gil * include/functions_agents.php extensions/module_groups.php: Fixed bug: sql error in extension "Module Groups" and popup alert. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5376 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 +++++ pandora_console/extensions/module_groups.php | 25 ++++++++++---------- pandora_console/include/functions_agents.php | 13 +++++----- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 6d8dcaf0ca..cf18275d8a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2012-01-17 Vanessa Gil + + * include/functions_agents.php + extensions/module_groups.php: Fixed bug: sql error in + extension "Module Groups" and popup alert. + 2012-01-16 Vanessa Gil * godmode/netflow/nf_edit.php diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 2da80cdf6f..38c11f4ee2 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -28,9 +28,9 @@ if (is_ajax ()) { $data = false; if ($get_info_alert_module_group) { - $agents = agents_get_group_agents($id_agent_group); + $agents = agents_get_group_agents($id_agent_group); if (!empty($agents)) { - $alerts = agents_get_alerts_simple($agents); + $alerts = agents_get_alerts_simple(array_keys($agents)); foreach ($alerts as $alert) { $module = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $alert['id_agent_module'])); if ($module_group == $module['id_module_group']) { @@ -49,8 +49,7 @@ if (is_ajax ()) { FROM talert_template_module_actions AS t1 INNER JOIN talert_actions AS t2 ON t1.id_alert_action = t2.id WHERE t1.id_alert_template_module = ' . $template['id'] . ' - OR t2.id = ' . $template['id_alert_action'] . ';'; - + OR t2.id = ' . $template['id_alert_action'] . ';'; $actions = db_get_all_rows_sql($sql); if ($actions === false) { $actions = array(); @@ -129,7 +128,7 @@ function mainModuleGroups() { ui_print_page_header (__("Combined table of agent group and module group"), "images/brick.png", false, "", false, ''); echo "

" . __("This table shows in columns the modules group and in rows agents group. The cell shows all modules") . "

"; - + $agentGroups = users_get_groups ($config['id_user'], "AR", false); $modelGroups = users_get_all_model_groups(); @@ -165,18 +164,17 @@ function mainModuleGroups() { foreach ($modelGroups as $idModelGroup => $modelGroup) { $query = sprintf($sql,$idAgentGroup, $idModelGroup); - + $rowsDB = db_get_all_rows_sql ($query); - - + $agents = agents_get_group_agents($idAgentGroup); - + if (!empty($agents)) { - $alerts = agents_get_alerts_simple($agents); - + $alerts = agents_get_alerts_simple(array_keys($agents)); + foreach ($alerts as $alert) { $module = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $alert['id_agent_module'])); - + if ($idModelGroup == $module['id_module_group']) { if ($alert["times_fired"] > 0) { $fired = true; @@ -184,7 +182,7 @@ function mainModuleGroups() { } } } - + $states = array(); if ($rowsDB !== false) { foreach ($rowsDB as $rowDB) { @@ -193,6 +191,7 @@ function mainModuleGroups() { } $count = 0; + foreach ($states as $idState => $state) { $count += $state; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index f82d3de852..59b0bf0ba2 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -186,7 +186,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f $orderbyText = sprintf("ORDER BY %s", $orderby); } } - + $selectText = 'talert_template_modules.*, t2.nombre AS agent_module_name, t3.nombre AS agent_name, t4.name AS template_name'; if ($count !== false) { $selectText = 'COUNT(talert_template_modules.id) AS count'; @@ -198,7 +198,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f }else if ($extra_sql != '') { $extra_sql .= ' OR '; } - + $sql = sprintf ("SELECT %s FROM talert_template_modules INNER JOIN tagente_modulo t2 @@ -951,11 +951,10 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower */ function agents_get_modules ($id_agent = null, $details = false, $filter = false, $indexed = true, $get_not_init_modules = true) { global $config; - + if ($id_agent === null) { //Extract the agents of group user. $groups = users_get_groups(false, 'AR', false); - if(empty($groups)) { return array(); } @@ -975,8 +974,10 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false } $id_agent = $temp; } - - $id_agent = safe_int ($id_agent, 1); + + if (!is_array($id_agent)) { + $id_agent = safe_int ($id_agent, 1); + } $extra_sql = ''; if ($id_agent != 0){