From cc3189196c7c28ad79826e8dc32d276952cc8b1c Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 5 Oct 2020 12:45:26 +0200 Subject: [PATCH] Fix secondary groups match while group filtering --- pandora_console/include/functions_events.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 4247a1868a..ecdb92a528 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1063,6 +1063,7 @@ function events_get_all( } } + $_tmp = ''; foreach ($tags as $id_tag) { if (!isset($tags_names[$id_tag])) { $tags_names[$id_tag] = tags_get_name($id_tag); @@ -1304,6 +1305,7 @@ function events_get_all( $tgrupo_join = 'LEFT'; $tgrupo_join_filters = []; + if (isset($groups) && (is_array($groups) || $groups > 0) @@ -1311,17 +1313,21 @@ function events_get_all( $tgrupo_join = 'INNER'; if (is_array($groups)) { $tgrupo_join_filters[] = sprintf( - ' AND (tg.id_grupo IN (%s) OR tasg.id_group IN (%s))', + ' (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s)) + OR (te.id_agente = tasg.id_agent AND tasg.id_group IN (%s)))', join(', ', $groups), join(', ', $groups) ); } else { $tgrupo_join_filters[] = sprintf( - ' AND (tg.id_grupo = %s OR tasg.id_group = %s)', + ' (te.id_grupo = tg.id_grupo AND tg.id_grupo = %s) + OR (te.id_agente = tasg.id_agent AND tasg.id_group = %s)', $groups, $groups ); } + } else { + $tgrupo_join_filters[] = ' te.id_grupo = tg.id_grupo'; } $server_join = ''; @@ -1376,8 +1382,7 @@ function events_get_all( %s %s %s JOIN tgrupo tg - ON te.id_grupo = tg.id_grupo - %s + ON %s %s WHERE 1=1 %s