From f4d035cfa5e02c832f08185b76706aa46de84af8 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Tue, 21 Nov 2017 10:27:17 +0100 Subject: [PATCH] Added changes to filter by group. Not finished --- pandora_console/include/functions_graph.php | 23 +++++++++-- pandora_console/include/functions_groups.php | 38 +++++++++++++++++++ .../operation/agentes/networkmap.dinamic.php | 7 ++-- 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index ccad237208..76ffa2d4dd 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -5802,17 +5802,34 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { $filter_module_group = (!empty($filter) && !empty($filter['module_group'])) ? $filter['module_group'] : false; - $groups = users_get_groups(false, "AR", false, true, (!empty($filter) && isset($filter['group']) ? $filter['group'] : null)); + if ($filter['group'] != 0) { + $groups = db_get_row_sql ("SELECT * FROM tgrupo where id_grupo = " . $filter['group']); + $groups_ax = array($groups['id_grupo'] => $groups); + + $groups = $groups_ax; + } + else { + $groups = users_get_groups(false, "AR", false, true, (!empty($filter) && isset($filter['group']) ? $filter['group'] : null)); + } $data_groups = array(); if (!empty($groups)) { $groups_aux = $groups; - $data_groups = groups_get_tree($groups); + + if ($filter['group'] != 0) { + $data_groups[$filter['group']] = $groups[$filter['group']]; + groups_get_all_hierarchy_group_to_childrens($groups[$filter['group']], $filter['group'], $data_groups); + } + else { + groups_get_all_hierarchy_groups_to_childrens($groups, $data_groups); + } + $groups_aux = null; } if (!empty($data_groups)) { $filter = array('id_grupo' => array_keys($data_groups)); + $fields = array('id_agente', 'id_parent', 'id_grupo', 'alias'); $agents = agents_get_agents($filter, $fields); @@ -6029,7 +6046,6 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { } function iterate_group_array ($groups, &$data_agents) { - $data = array(); foreach ($groups as $id => $group) { @@ -6068,6 +6084,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { if (!isset($group['children'])) $group_aux['children'] = array(); + if (!empty($group['children'])) $group_aux['children'] = iterate_group_array($group['children'], $data_agents); diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 757e5014d5..02ed697a15 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -2241,6 +2241,9 @@ function groups_get_tree(&$groups, $parent = false) { if (!empty($children)) { $return[$id]['children'] = $children; } + else { + $return[$id]['children'] = array(); + } } else if ($parent && isset($group['parent']) && $group['parent'] == $parent) { $return[$id] = $group; @@ -2250,6 +2253,9 @@ function groups_get_tree(&$groups, $parent = false) { if (!empty($children)) { $return[$id]['children'] = $children; } + else { + $return[$id]['children'] = array(); + } } else { continue; @@ -2258,6 +2264,7 @@ function groups_get_tree(&$groups, $parent = false) { return $return; } + function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { global $config; @@ -2289,6 +2296,37 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { return $hierarchy; } +function groups_get_all_hierarchy_group_to_childrens ($group, $parent, &$hierachy) { + $childrens = db_get_all_rows_sql("SELECT * FROM tgrupo WHERE parent = " . $group['id_grupo']); + if ($childrens) { + foreach ($childrens as $child) { + $hierachy[$parent]['children'][$child['id_grupo']] = $child; + groups_get_all_hierarchy_group_to_childrens($child, $child['id_grupo'], $hierachy); + } + } + else { + $hierachy[$parent]['children'] = array(); + } +} + +function groups_get_all_hierarchy_groups_to_childrens ($groups, &$hierachy, $is_children = false) { + foreach ($groups as $id => $group) { + if (!$is_children) { + $hierachy[$group['id_grupo']] = $group; + } + + $childrens = db_get_all_rows_sql("SELECT * FROM tgrupo WHERE parent = " . $group['id_grupo']); + if ($childrens) { + foreach ($childrens as $child) { + $hierachy[$group['id_grupo']]['children'][$child['id_grupo']] = $child; + + unset($hierachy[$child['id_grupo']]); + groups_get_all_hierarchy_groups_to_childrens($childrens, $hierachy, true); + } + } + } +} + function group_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $mode = 'group', $agent_filter = array(), $module_filter = array()) { global $config; if ($id_user == false) { diff --git a/pandora_console/operation/agentes/networkmap.dinamic.php b/pandora_console/operation/agentes/networkmap.dinamic.php index 01b0e54bc6..30debc4fff 100644 --- a/pandora_console/operation/agentes/networkmap.dinamic.php +++ b/pandora_console/operation/agentes/networkmap.dinamic.php @@ -136,11 +136,12 @@ if ($activeTab == "radial_dynamic") { echo "
"; $filter = array(); - if (!empty($group)) - $filter['group'] = $group; + if ($networkmap['source'] == 0) { + $filter['group'] = $networkmap['source_data']; + } if (!empty($module_group)) $filter['module_group'] = $module_group; - + html_debug($filter, true); echo graph_monitor_wheel($width, $height, $filter, $strict_user); echo "
";