From 63d322244dd9ca51ee35c1f7cd38b4c3755ef9e0 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Thu, 26 Mar 2015 19:34:56 +0100 Subject: [PATCH 1/2] Added a new parameter to the modules retrieving by tag function --- pandora_console/include/functions_networkmap.php | 4 ++-- pandora_console/include/functions_reporting.php | 12 ++++++------ pandora_console/include/functions_tags.php | 11 ++++++++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 005f8f3274..e02aa75f8a 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -376,7 +376,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, // Get agent modules data if ($strict_user) { - $modules = tags_get_agent_modules ($agent['id_agente'], $acltags, false, $filter, false); + $modules = tags_get_agent_modules ($agent['id_agente'], false, $acltags, false, $filter, false); } else { $modules = agents_get_modules($agent['id_agente'], '*', $filter, true, true); } @@ -792,7 +792,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, // Get agent modules data if ($strict_user) { $filter['disabled'] = 0; - $modules = tags_get_agent_modules ($agent['id_agente'], $acltags, false, $filter, false); + $modules = tags_get_agent_modules ($agent['id_agente'], false, $acltags, false, $filter, false); } else { $modules = agents_get_modules ($agent['id_agente'], false, array('disabled' => 0), true, false); } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 55c818c4e4..4ea953ce9a 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -7862,14 +7862,14 @@ function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent', $ $id_agent = $counts_info['id_agente']; $counts_info = array(); - $counts_info['normal_count'] = count(tags_get_agent_modules ($id_agent, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NORMAL)); - $counts_info['warning_count'] = count(tags_get_agent_modules ($id_agent, $acltags, false, $filter, false, AGENT_MODULE_STATUS_WARNING)); - $counts_info['critical_count'] = count(tags_get_agent_modules ($id_agent, $acltags, false, $filter, false, AGENT_MODULE_STATUS_CRITICAL_BAD)); - $counts_info['notinit_count'] = count(tags_get_agent_modules ($id_agent, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NOT_INIT)); - $counts_info['unknown_count'] = count(tags_get_agent_modules ($id_agent, $acltags, false, $filter, false, AGENT_MODULE_STATUS_UNKNOWN)); + $counts_info['normal_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NORMAL)); + $counts_info['warning_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_WARNING)); + $counts_info['critical_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_CRITICAL_BAD)); + $counts_info['notinit_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NOT_INIT)); + $counts_info['unknown_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_UNKNOWN)); $counts_info['total_count'] = $counts_info['normal_count'] + $counts_info['warning_count'] + $counts_info['critical_count'] + $counts_info['unknown_count'] + $counts_info['notinit_count']; - $all_agent_modules = tags_get_agent_modules ($id_agent, $acltags, false, $filter); + $all_agent_modules = tags_get_agent_modules ($id_agent, false, $acltags, false, $filter); if (!empty($all_agent_modules)) { $mod_clause = "(".implode(',', array_keys($all_agent_modules)).")"; diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index a2a6b87171..74d7b66d8d 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -2419,7 +2419,7 @@ function tags_get_all_user_agents ($id_tag = false, $id_user = false, $groups_an return $user_agents; } -function tags_get_agent_modules ($id_agent, $groups_and_tags = array(), $fields = false, $filter = false, $return_all_fields = false, $get_filter_status = -1) { +function tags_get_agent_modules ($id_agent, $id_tag = false, $groups_and_tags = array(), $fields = false, $filter = false, $return_all_fields = false, $get_filter_status = -1) { global $config; @@ -2427,6 +2427,12 @@ function tags_get_agent_modules ($id_agent, $groups_and_tags = array(), $fields if (empty($id_agent)) return false; + if (empty($id_tag)) { + $tag_filter = ""; + } else { + $tag_filter = " AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag) "; + } + if (!is_array ($fields)) { $fields = array (); $fields[0] = "tagente_modulo.id_agente_modulo"; @@ -2445,12 +2451,11 @@ function tags_get_agent_modules ($id_agent, $groups_and_tags = array(), $fields } - $tag_filter = ""; if (!empty($groups_and_tags)) { $agent_group = db_get_value('id_grupo', 'tagente', 'id_agente', $id_agent); if (isset($groups_and_tags[$agent_group]) && ($groups_and_tags[$agent_group] != '')) { //~ $tag_filter = " AND ttag_module.id_tag IN (".$groups_and_tags[$agent_group].")"; - $tag_filter = " AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (".$groups_and_tags[$agent_group]."))"; + $tag_filter .= " AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (".$groups_and_tags[$agent_group]."))"; } } From b99e7773004a4b2ddaee61bf5396c917e69f6acf Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Thu, 26 Mar 2015 21:17:53 +0100 Subject: [PATCH 2/2] Fixed an error on the function"tags_get_all_user_agents" --- pandora_console/include/functions_tags.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index 74d7b66d8d..6cc25d6d37 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -2298,7 +2298,7 @@ function tags_get_all_user_agents ($id_tag = false, $id_user = false, $groups_an $groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo"); } } else { - $groups_clause = " AND tagente.id_grupo IN (".implode(',',$groups_and_tags).")"; + $groups_clause = " AND tagente.id_grupo IN (".implode(',', array_keys($groups_and_tags)).")"; } if (!empty($filter['id_group'])) {