From 74a4ef7b830deda01cffb8daaf1bd2aaed676f34 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 10 Oct 2013 12:55:22 +0000 Subject: [PATCH] 2013-10-10 Miguel de Dios * include/functions_tags.php, operation/agentes/estado_monitores.php, operation/agentes/status_events.php: uploaded the fixes of Juanma. Thanks Juanma ;) git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8885 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 +++++++ pandora_console/include/functions_tags.php | 13 +++++++++++++ .../operation/agentes/estado_monitores.php | 5 ++++- pandora_console/operation/agentes/status_events.php | 5 ++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 00f8ceed87..7c2be3907c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2013-10-10 Miguel de Dios + + * include/functions_tags.php, + operation/agentes/estado_monitores.php, + operation/agentes/status_events.php: uploaded the fixes of Juanma. + Thanks Juanma ;) + 2013-10-10 Sergio Martin * include/styles/pandora.css diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index 4b9be08476..97b77f373c 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -767,11 +767,18 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') { } $condition = ''; + + // Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression) + $i = 0; foreach ($acltags as $group_id => $group_tags) { if ($condition != '') { $condition .= ' OR '; } + // Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression) + if ($i == 0) + $condition .= ' ( '; + // Group condition (The module belongs to an agent of the group X) if (!array_key_exists(0, array_keys($acltags))) { $group_condition = sprintf('%sid_agente IN (SELECT id_agente FROM tagente WHERE id_grupo = %d)', $modules_table, $group_id); @@ -784,8 +791,14 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') { $tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, implode(',',$group_tags)); $condition .= "($group_condition AND \n$tags_condition)\n"; + + $i++; } + // Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression) + if (!empty($acltags)) + $condition .= ' ) '; + //Avoid the user profiles with all group access. //if (!empty($condition)) { if (!empty($condition) && diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index 1f34b4bba8..0b5e4035c2 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -152,8 +152,11 @@ switch ($config["dbtype"]) { break; } +// Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!) +$groups = users_get_groups($config["id_user"]); + $tags_sql = tags_get_acl_tags($config['id_user'], - $agent['id_grupo'], 'AR', 'module_condition', 'AND', 'tagente_modulo'); + array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo'); $status_filter_monitor = (int)get_parameter('status_filter_monitor', -1); $status_text_monitor = get_parameter('status_text_monitor', ''); diff --git a/pandora_console/operation/agentes/status_events.php b/pandora_console/operation/agentes/status_events.php index 54796ed6fe..825d0c58c5 100644 --- a/pandora_console/operation/agentes/status_events.php +++ b/pandora_console/operation/agentes/status_events.php @@ -26,7 +26,10 @@ require_once ("include/functions_events.php"); echo "

".__('Latest events for this agent')."

"; -$tags_condition = tags_get_acl_tags($config['id_user'], $agent['id_grupo'], 'ER', 'event_condition', 'AND'); +// Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!) +$groups = users_get_groups($config["id_user"]); + +$tags_condition = tags_get_acl_tags($config['id_user'], /*$agent['id_grupo']*/ array_keys($groups), 'ER', 'event_condition', 'AND'); events_print_event_table ("estado <> 1 $tags_condition", 10, '100%', false, $id_agente);