Added code to fix agents generation in sunbrust chart

This commit is contained in:
Arturo Gonzalez 2017-11-24 11:27:10 +01:00
parent f4d035cfa5
commit 06f83825dc
3 changed files with 22 additions and 44 deletions

View File

@ -5812,23 +5812,20 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
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;
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);
}
$data_groups = groups_get_tree($groups);
$data_groups_keys = array();
groups_get_tree_keys($data_groups, $data_groups_keys);
$groups_aux = null;
}
if (!empty($data_groups)) {
$filter = array('id_grupo' => array_keys($data_groups));
$filter = array('id_grupo' => array_keys($data_groups_keys));
$fields = array('id_agente', 'id_parent', 'id_grupo', 'alias');
$agents = agents_get_agents($filter, $fields);
@ -6082,8 +6079,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
$tooltip_content = html_print_image("images/groups_small/" . $group['icon'] . ".png", true) . "&nbsp;" . __('Group') . ": <b>" . $group_aux['name'] . "</b>";
$group_aux['tooltip_content'] = $tooltip_content;
if (!isset($group['children']))
$group_aux['children'] = array();
$group_aux['children'] = array();
if (!empty($group['children']))
$group_aux['children'] = iterate_group_array($group['children'], $data_agents);
@ -6092,7 +6088,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
if (!empty($agents))
$group_aux['children'] = array_merge($group_aux['children'], $agents);
$data[] = $group_aux;
}
@ -6107,6 +6103,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
unset($agents[$id]);
}
}
if (!empty($valid_agents))
return $valid_agents;
else
@ -6114,7 +6111,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
}
$graph_data = array('name' => __('Main node'), 'children' => iterate_group_array($data_groups, $data_agents), 'color' => '#3F3F3F');
if (empty($graph_data['children']))
return fs_error_image();

View File

@ -2265,6 +2265,15 @@ function groups_get_tree(&$groups, $parent = false) {
return $return;
}
function groups_get_tree_keys ($groups, &$group_keys) {
foreach ($groups as $id => $group) {
$group_keys[$id] = $id;
if (isset($group['children'])) {
groups_get_tree_keys($groups[$id]['children'], $group_keys);
}
}
}
function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) {
global $config;
@ -2296,36 +2305,7 @@ 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;
@ -3074,4 +3054,5 @@ function groups_get_group_deep ($id_group) {
return $deep;
}
?>

View File

@ -141,7 +141,7 @@ if ($activeTab == "radial_dynamic") {
}
if (!empty($module_group))
$filter['module_group'] = $module_group;
html_debug($filter, true);
echo graph_monitor_wheel($width, $height, $filter, $strict_user);
echo "</div>";