diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 59b78c9e02..546e4b1c28 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -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 .= ''; +$form_filter .= "".__('Group').''; +$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 .= ''; if (defined('METACONSOLE')) { $form_filter .= ''; @@ -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) { diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index 50404fbffa..b8be4f128f 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -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) { diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index cff575a19b..7548843ce8 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -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,