#8763 Added filter groups
This commit is contained in:
parent
d553ab04a9
commit
d6fc15f0bf
|
@ -42,17 +42,10 @@ if (tags_has_user_acl_tags()) {
|
|||
ui_print_tags_warning();
|
||||
}
|
||||
|
||||
$user_strict = (bool) db_get_value(
|
||||
'strict_acl',
|
||||
'tusuario',
|
||||
'id_user',
|
||||
$config['id_user']
|
||||
);
|
||||
$all_data = tactical_status_modules_agents(
|
||||
$config['id_user'],
|
||||
$user_strict,
|
||||
'AR',
|
||||
$user_strict
|
||||
false,
|
||||
'AR'
|
||||
);
|
||||
$data = [];
|
||||
|
||||
|
|
|
@ -471,7 +471,14 @@ function tactical_get_data($id_user=false, $user_strict=false, $acltags, $return
|
|||
$list['_monitors_alerts_fired_'] = tactical_monitor_fired_alerts(explode(',', $user_groups_ids), $user_strict, explode(',', $user_groups_ids));
|
||||
$list['_monitors_alerts_'] = tactical_monitor_alerts($user_strict);
|
||||
|
||||
$total_agentes = agents_get_agents(false, ['count(DISTINCT id_agente) as total_agents'], 'AR', false, false, 1);
|
||||
$total_agentes = agents_get_agents(
|
||||
['id_grupo' => explode(',', $user_groups_ids)],
|
||||
['count(DISTINCT id_agente) as total_agents'],
|
||||
'AR',
|
||||
false,
|
||||
false,
|
||||
1
|
||||
);
|
||||
$list['_total_agents_'] = $total_agentes[0]['total_agents'];
|
||||
|
||||
$list['_monitor_checks_'] = ($list['_monitors_not_init_'] + $list['_monitors_unknown_'] + $list['_monitors_warning_'] + $list['_monitors_critical_'] + $list['_monitors_ok_']);
|
||||
|
@ -486,16 +493,32 @@ function tactical_get_data($id_user=false, $user_strict=false, $acltags, $return
|
|||
}
|
||||
|
||||
|
||||
function tactical_status_modules_agents($id_user=false, $user_strict=false, $access='AR', $force_group_and_tag=true)
|
||||
function tactical_status_modules_agents($id_user=false, $user_strict=false, $access='AR', $groups=[])
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($id_user == false) {
|
||||
if ($id_user === false) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
if (empty($groups) === false) {
|
||||
if (is_array($groups) === false) {
|
||||
$groups = explode(',', (string) $groups);
|
||||
// Group id as key.
|
||||
$groups = array_flip($groups);
|
||||
}
|
||||
|
||||
if (isset($groups[0]) === true) {
|
||||
$groups = [];
|
||||
}
|
||||
}
|
||||
|
||||
$acltags = tags_get_user_groups_and_tags($id_user, $access, $user_strict);
|
||||
|
||||
if (empty($groups) === false) {
|
||||
$acltags = array_intersect_key($acltags, $groups);
|
||||
}
|
||||
|
||||
$result_list = tactical_get_data($id_user, $user_strict, $acltags);
|
||||
|
||||
return $result_list;
|
||||
|
|
|
@ -185,6 +185,7 @@ class TacticalWidget extends Widget
|
|||
if (empty($this->values['statusMonitor']) === true
|
||||
&& empty($this->values['serverPerformance']) === true
|
||||
&& empty($this->values['summary']) === true
|
||||
&& empty($this->values['groupId']) === true
|
||||
) {
|
||||
$this->configurationRequired = true;
|
||||
}
|
||||
|
@ -226,6 +227,18 @@ class TacticalWidget extends Widget
|
|||
$values['summary'] = $decoder['summary'];
|
||||
}
|
||||
|
||||
if (isset($decoder['id_groups']) === true) {
|
||||
if (is_array($decoder['id_groups']) === true) {
|
||||
$decoder['id_groups'][0] = implode(',', $decoder['id_groups']);
|
||||
}
|
||||
|
||||
$values['groupId'] = $decoder['id_groups'];
|
||||
}
|
||||
|
||||
if (isset($decoder['groupId']) === true) {
|
||||
$values['groupId'] = $decoder['groupId'];
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
@ -292,6 +305,43 @@ class TacticalWidget extends Widget
|
|||
],
|
||||
];
|
||||
|
||||
// Groups.
|
||||
$return_all_group = false;
|
||||
|
||||
// Restrict access to group.
|
||||
$selected_groups = [];
|
||||
if ($values['groupId']) {
|
||||
$selected_groups = explode(',', $values['groupId'][0]);
|
||||
|
||||
if (users_can_manage_group_all('AR') === true
|
||||
|| ($selected_groups[0] !== ''
|
||||
&& in_array(0, $selected_groups) === true)
|
||||
) {
|
||||
// Return all group if user has permissions
|
||||
// or it is a currently selected group.
|
||||
$return_all_group = true;
|
||||
}
|
||||
} else {
|
||||
if (users_can_manage_group_all('AR') === true) {
|
||||
$return_all_group = true;
|
||||
}
|
||||
}
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Groups'),
|
||||
'arguments' => [
|
||||
'type' => 'select_groups',
|
||||
'name' => 'groupId[]',
|
||||
'returnAllGroup' => true,
|
||||
'privilege' => 'AR',
|
||||
'selected' => $selected_groups,
|
||||
'return' => true,
|
||||
'multiple' => true,
|
||||
'returnAllGroup' => $return_all_group,
|
||||
'required' => true,
|
||||
],
|
||||
];
|
||||
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
|
@ -311,6 +361,7 @@ class TacticalWidget extends Widget
|
|||
'serverPerformance'
|
||||
);
|
||||
$values['summary'] = \get_parameter_switch('summary');
|
||||
$values['groupId'] = \get_parameter('groupId', []);
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
@ -327,7 +378,7 @@ class TacticalWidget extends Widget
|
|||
|
||||
$output = '';
|
||||
|
||||
$all_data = \tactical_status_modules_agents($config['id_user']);
|
||||
$all_data = \tactical_status_modules_agents($config['id_user'], false, 'AR', $this->values['groupId'][0]);
|
||||
|
||||
$data = [];
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ class Tactical
|
|||
$ui->beginContent();
|
||||
$ui->contentBeginGrid('responsive');
|
||||
// ~ $data = reporting_get_group_stats();
|
||||
$all_data = tactical_status_modules_agents($config['id_user'], $user_strict, 'AR', $user_strict);
|
||||
$all_data = tactical_status_modules_agents($config['id_user'], false, 'AR');
|
||||
|
||||
$data = [];
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ ui_print_standard_header(
|
|||
|
||||
// Currently this function makes loading this page is impossible. Change
|
||||
// and create new function.
|
||||
$all_data = tactical_status_modules_agents($config['id_user'], $user_strict, 'AR', $user_strict);
|
||||
$all_data = tactical_status_modules_agents($config['id_user'], false, 'AR');
|
||||
|
||||
$data = [];
|
||||
|
||||
|
|
Loading…
Reference in New Issue