Added group filter in alert list
This commit is contained in:
parent
b2de9eeef2
commit
fc88d265d4
|
@ -133,6 +133,16 @@ $sb_list = [];
|
|||
$sb_list[1] = __('Standby on');
|
||||
$sb_list[0] = __('Standby off');
|
||||
$form_filter .= html_print_select($sb_list, 'standby', $standby, '', __('All'), -1, true);
|
||||
$form_filter .= '</td>';
|
||||
$form_filter .= "</td><td style='font-weight: bold;'>".__('Group').'</td><td>';
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
if (!$own_info['is_admin'] && !check_acl($config['id_user'], 0, 'AR') && !check_acl($config['id_user'], 0, 'AW')) {
|
||||
$return_all_group = false;
|
||||
} else {
|
||||
$return_all_group = true;
|
||||
}
|
||||
|
||||
$form_filter .= html_print_select_groups(false, 'AR', $return_all_group, 'ag_group', $ag_group, '', '', 0, true, false, true, '', false);
|
||||
$form_filter .= '</td></tr>';
|
||||
if (defined('METACONSOLE')) {
|
||||
$form_filter .= '<tr>';
|
||||
|
@ -214,7 +224,7 @@ $total = agents_get_alerts_simple(
|
|||
$where,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
$ag_group,
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -375,7 +385,7 @@ switch ($sortField) {
|
|||
break;
|
||||
}
|
||||
|
||||
$form_params = '&template_name='.$templateName.'&agent_name='.$agentName.'&module_name='.$moduleName.'&action_id='.$actionID.'&field_content='.$fieldContent.'&priority='.$priority.'&enabledisable='.$enabledisable.'&standby='.$standby;
|
||||
$form_params = '&template_name='.$templateName.'&agent_name='.$agentName.'&module_name='.$moduleName.'&action_id='.$actionID.'&field_content='.$fieldContent.'&priority='.$priority.'&enabledisable='.$enabledisable.'&standby='.$standby.'&ag_group='.$ag_group;
|
||||
$sort_params = '&sort_field='.$sortField.'&sort='.$sort;
|
||||
|
||||
if ($id_agente) {
|
||||
|
@ -394,7 +404,9 @@ $simple_alerts = agents_get_alerts_simple(
|
|||
'order' => $order,
|
||||
],
|
||||
$where,
|
||||
false
|
||||
false,
|
||||
false,
|
||||
$ag_group
|
||||
);
|
||||
|
||||
if (!$id_agente) {
|
||||
|
|
|
@ -67,6 +67,7 @@ $searchFlag = get_parameter('search', 0);
|
|||
$enabledisable = get_parameter('enabledisable', '');
|
||||
$standby = get_parameter('standby', '');
|
||||
$pure = get_parameter('pure', 0);
|
||||
$ag_group = get_parameter('ag_group', 0);
|
||||
$messageAction = '';
|
||||
|
||||
if ($update_alert) {
|
||||
|
|
|
@ -295,10 +295,17 @@ function agents_get_alerts_simple($id_agent=false, $filter='', $options=false, $
|
|||
|
||||
if (($id_agent !== false) && ($idGroup !== false)) {
|
||||
if ($idGroup != 0) {
|
||||
$has_secondary = enterprise_hook('agents_is_using_secondary_groups');
|
||||
// All group
|
||||
$subQuery = 'SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE delete_pending = 0 AND id_agente IN (SELECT id_agente FROM tagente WHERE id_grupo = '.$idGroup.')';
|
||||
WHERE delete_pending = 0 AND id_agente IN (SELECT id_agente FROM tagente WHERE id_grupo = '.$idGroup;
|
||||
|
||||
if ($has_secondary) {
|
||||
$subQuery .= ' OR tasg.id_group = '.$idGroup;
|
||||
}
|
||||
|
||||
$subQuery .= ')';
|
||||
} else {
|
||||
$subQuery = 'SELECT id_agente_modulo
|
||||
FROM tagente_modulo WHERE delete_pending = 0';
|
||||
|
@ -337,17 +344,31 @@ function agents_get_alerts_simple($id_agent=false, $filter='', $options=false, $
|
|||
$selectText = 'COUNT(talert_template_modules.id) AS count';
|
||||
}
|
||||
|
||||
$secondary_join = '';
|
||||
if ($idGroup) {
|
||||
if (isset($has_secondary) && $has_secondary) {
|
||||
$secondary_join = sprintf(
|
||||
'LEFT JOIN tagent_secondary_group tasg
|
||||
ON t3.id_agente = tasg.id_agent
|
||||
AND tasg.id_group = %d',
|
||||
$idGroup
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
FROM talert_template_modules
|
||||
INNER JOIN tagente_modulo t2
|
||||
ON talert_template_modules.id_agent_module = t2.id_agente_modulo
|
||||
INNER JOIN tagente t3
|
||||
ON t2.id_agente = t3.id_agente
|
||||
INNER JOIN talert_templates t4
|
||||
ON talert_template_modules.id_alert_template = t4.id
|
||||
INNER JOIN tagente_modulo t2
|
||||
ON talert_template_modules.id_agent_module = t2.id_agente_modulo
|
||||
INNER JOIN tagente t3
|
||||
ON t2.id_agente = t3.id_agente
|
||||
%s
|
||||
INNER JOIN talert_templates t4
|
||||
ON talert_template_modules.id_alert_template = t4.id
|
||||
WHERE id_agent_module in (%s) %s %s %s',
|
||||
$selectText,
|
||||
$secondary_join,
|
||||
$subQuery,
|
||||
$where,
|
||||
$filter,
|
||||
|
|
Loading…
Reference in New Issue