13328-Fix recursion in Tactical group view->Heatmap
This commit is contained in:
parent
8539d1d905
commit
247edbcb59
|
@ -206,3 +206,43 @@ function groupview_get_groups_list($id_user=false, $access='AR', $is_not_paginat
|
|||
'counter' => $counter,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
function get_recursive_groups_heatmap($parent_group, $acl)
|
||||
{
|
||||
if ($parent_group['counter'] > 0) {
|
||||
foreach ($parent_group['groups'] as $group_key => $group_value) {
|
||||
if ((int) $group_value['_id_'] === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$childrens = groups_get_children($group_value['_id_'], true, $acl, false);
|
||||
if (empty($childrens) === false) {
|
||||
foreach ($childrens as $children) {
|
||||
$children_status = groups_get_status($children['id_grupo']);
|
||||
$parent_group['groups'][$group_key]['_monitor_checks_']++;
|
||||
switch ($children_status) {
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
$parent_group['groups'][$group_key]['_monitors_critical_']++;
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_WARNING:
|
||||
$parent_group['groups'][$group_key]['_monitors_warning_']++;
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_UNKNOWN:
|
||||
$parent_group['groups'][$group_key]['_monitors_unknown_']++;
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_NORMAL:
|
||||
default:
|
||||
$parent_group['groups'][$group_key]['_monitors_ok_']++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $parent_group;
|
||||
}
|
||||
|
|
|
@ -454,13 +454,17 @@ class Groups extends Element
|
|||
// ACL Check.
|
||||
$agent_a = check_acl($config['id_user'], 0, 'AR');
|
||||
$agent_w = check_acl($config['id_user'], 0, 'AW');
|
||||
$acl = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
|
||||
|
||||
$groups_list = groupview_get_groups_list(
|
||||
$config['id_user'],
|
||||
($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'),
|
||||
$acl,
|
||||
true
|
||||
);
|
||||
|
||||
// Recursive groups.
|
||||
$groups_list = get_recursive_groups_heatmap($groups_list, $acl);
|
||||
|
||||
$total_groups = $groups_list['counter'];
|
||||
$groups = $groups_list['groups'];
|
||||
// Best square.
|
||||
|
|
Loading…
Reference in New Issue