From f952d5c70e7f8b65ab51fce191fdf598f4bc741a Mon Sep 17 00:00:00 2001 From: danielmaya Date: Mon, 8 Oct 2018 17:45:26 +0200 Subject: [PATCH] tags_get_acl_tags revision --- .../reporting/visual_console_builder.elements.php | 8 +++++--- pandora_console/include/functions_graph.php | 11 ++++++----- pandora_console/include/functions_tags.php | 2 +- pandora_console/mobile/operation/modules.php | 13 +++++++++---- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_builder.elements.php b/pandora_console/godmode/reporting/visual_console_builder.elements.php index c7e63358fa..9796a217e8 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.elements.php +++ b/pandora_console/godmode/reporting/visual_console_builder.elements.php @@ -420,9 +420,11 @@ foreach ($layoutDatas as $layoutData) { } else { if ($layoutData['id_agent'] != 0) { - $modules = agents_meta_get_modules( - $layoutData['id_metaconsole'], - $layoutData['id_agent']); + $server = db_get_row('tmetaconsole_setup', 'id', $layoutData['id_metaconsole']); + if (metaconsole_connect($server) == NOERR) { + $modules = agents_get_modules($layoutData['id_agent']); + metaconsole_restore_db(); + } } } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index feac091234..fd9460819c 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2267,7 +2267,7 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) { // Fix: tag filters implemented! for tag functionality groups have to be all user_groups (propagate ACL funct!) $groups = users_get_groups($config["id_user"]); - // TODO revision tag + $tags_condition = tags_get_acl_tags($config['id_user'], array_keys($groups), 'ER', 'event_condition', 'AND'); $data = array (); @@ -2771,7 +2771,6 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = } // Add tags condition to filter - // TODO revision tag $tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND'); //This will give the distinct id_agente, give the id_grupo that goes @@ -2859,7 +2858,6 @@ function grafico_eventos_total($filter = "", $width = 320, $height = 200, $noWat $filter = str_replace ( "\\" , "", $filter); // Add tags condition to filter - // TODO revision tag $tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND'); $filter .= $tags_condition; @@ -2873,8 +2871,11 @@ function grafico_eventos_total($filter = "", $width = 320, $height = 200, $noWat } $sql = sprintf("SELECT criticity, COUNT(id_evento) events - FROM tevento %s - GROUP BY criticity ORDER BY events DESC", $where); + FROM tevento + LEFT JOIN tagent_secondary_group tasg + ON tevento.id_agente = tasg.id_agent + %s %s + GROUP BY criticity ORDER BY events DESC", $where , $filter); $criticities = db_get_all_rows_sql ($sql, false, false); diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index fe4cd97d07..c2dac8a378 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -1145,7 +1145,7 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags = array(), $c if (users_is_admin($id_user)) { return true; } - // TODO revision tag + $tags_user = tags_get_acl_tags($id_user, $id_group, $access, 'data', '', '', true, $childrens_ids, true); // If there are wrong parameters or fail ACL check, return false if ($tags_user === ERR_WRONG_PARAMETERS || $tags_user === ERR_ACL) { diff --git a/pandora_console/mobile/operation/modules.php b/pandora_console/mobile/operation/modules.php index 5b86254209..f54b8009d3 100644 --- a/pandora_console/mobile/operation/modules.php +++ b/pandora_console/mobile/operation/modules.php @@ -281,8 +281,7 @@ class Modules { $modules = array(); $modules_db = array(); - $sql_conditions_base = " WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo"; + $sql_conditions_base = " WHERE 1=1"; // Part SQL for the id_agent @@ -302,7 +301,6 @@ class Modules { // Part SQL for the Tag - // TODO revision tag $sql_conditions_tags = tags_get_acl_tags($user->getIdUser(), $user->getIdGroups($this->acl), $this->acl, 'module_condition', 'AND', 'tagente_modulo'); @@ -401,7 +399,14 @@ class Modules { $sql_total = "SELECT count(*)"; - $sql = " FROM tagente, tagente_modulo, tagente_estado" . + $sql = " FROM tagente INNER JOIN tagente_modulo + ON tagente_modulo.id_agente = tagente.id_agente + INNER JOIN tagente_estado + ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + LEFT JOIN tagent_secondary_group tasg + ON tagente.id_agente = tasg.id_agent + LEFT JOIN ttag_module + ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo" . $sql_conditions_all; $sql_limit = "ORDER BY tagente.nombre ASC ";