diff --git a/pandora_console/extras/mr/56.sql b/pandora_console/extras/mr/56.sql index 13cc050dfc..da07b1612e 100644 --- a/pandora_console/extras/mr/56.sql +++ b/pandora_console/extras/mr/56.sql @@ -38,4 +38,6 @@ ALTER TABLE `tautoconfig` ADD COLUMN `executed` TINYINT UNSIGNED NOT NULL DEFAUL ALTER TABLE `tusuario` DROP COLUMN `metaconsole_assigned_server`; +ALTER TABLE `tevent_filter` ADD COLUMN `search_secondary_groups` INT NOT NULL DEFAULT 0; + COMMIT; diff --git a/pandora_console/godmode/events/event_edit_filter.php b/pandora_console/godmode/events/event_edit_filter.php index eebb4e213c..91045ce0ea 100644 --- a/pandora_console/godmode/events/event_edit_filter.php +++ b/pandora_console/godmode/events/event_edit_filter.php @@ -89,6 +89,7 @@ if ($id) { $tag_without_base64 = base64_encode($tag_without_json_clean); $filter_only_alert = $filter['filter_only_alert']; + $search_secondary_groups = $filter['search_secondary_groups']; $custom_data = $filter['custom_data']; $custom_data_filter_type = $filter['custom_data_filter_type']; @@ -126,6 +127,7 @@ if ($id) { $tag_without_json = $tag_without_json_clean = json_encode([]); $tag_without_base64 = base64_encode($tag_without_json); $filter_only_alert = ''; + $search_secondary_groups = 0; } if ($update || $create) { @@ -167,6 +169,8 @@ if ($update || $create) { $tag_without_json = io_safe_input(base64_decode($tag_without_base64)); $filter_only_alert = get_parameter('filter_only_alert', ''); + $search_secondary_groups = get_parameter('search_secondary_groups', 0); + $custom_data = get_parameter('custom_data', ''); $custom_data_filter_type = get_parameter('custom_data_filter_type', ''); @@ -193,6 +197,7 @@ if ($update || $create) { 'id_extra' => $id_extra, 'user_comment' => $user_comment, 'filter_only_alert' => $filter_only_alert, + 'search_secondary_groups' => $search_secondary_groups, 'custom_data' => $custom_data, 'custom_data_filter_type' => $custom_data_filter_type, ]; diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 93400ad5c8..d61206f710 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -356,6 +356,7 @@ if ($save_event_filter) { io_json_mb_encode([]) ); $values['filter_only_alert'] = get_parameter('filter_only_alert'); + $values['search_secondary_groups'] = get_parameter('search_secondary_groups'); $values['id_group_filter'] = get_parameter('id_group_filter'); $values['date_from'] = get_parameter('date_from'); $values['time_from'] = get_parameter('time_from'); @@ -412,6 +413,7 @@ if ($update_event_filter) { io_json_mb_encode([]) ); $values['filter_only_alert'] = get_parameter('filter_only_alert'); + $values['search_secondary_groups'] = get_parameter('search_secondary_groups'); $values['id_group_filter'] = get_parameter('id_group_filter'); $values['date_from'] = get_parameter('date_from'); $values['time_from'] = get_parameter('time_from'); @@ -457,31 +459,32 @@ if ($get_filter_values) { if ($event_filter === false) { $event_filter = [ - 'status' => EVENT_NO_VALIDATED, - 'event_view_hr' => $config['event_view_hr'], - 'group_rep' => 1, - 'tag_with' => [], - 'tag_without' => [], - 'history' => false, - 'module_search' => '', - 'filter_only_alert' => '-1', - 'user_comment' => '', - 'id_extra' => '', - 'id_user_ack' => '', - 'date_from' => '', - 'time_from' => '', - 'date_to' => '', - 'time_to' => '', - 'severity' => '', - 'event_type' => '', - 'group_rep' => 0, - 'id_group' => 0, - 'id_group_filter' => 0, - 'group_name' => 'All', - 'text_agent' => '', - 'id_agent' => 0, - 'id_name' => 'None', - 'filter_id' => 0, + 'status' => EVENT_NO_VALIDATED, + 'event_view_hr' => $config['event_view_hr'], + 'group_rep' => 1, + 'tag_with' => [], + 'tag_without' => [], + 'history' => false, + 'module_search' => '', + 'filter_only_alert' => '-1', + 'search_secondary_groups' => 0, + 'user_comment' => '', + 'id_extra' => '', + 'id_user_ack' => '', + 'date_from' => '', + 'time_from' => '', + 'date_to' => '', + 'time_to' => '', + 'severity' => '', + 'event_type' => '', + 'group_rep' => 0, + 'id_group' => 0, + 'id_group_filter' => 0, + 'group_name' => 'All', + 'text_agent' => '', + 'id_agent' => 0, + 'id_name' => 'None', + 'filter_id' => 0, ]; } else { $event_filter['module_search'] = io_safe_output( @@ -649,6 +652,8 @@ function load_form_filter() { $("#hidden-tag_without").val(val); if (i == 'filter_only_alert') $("#filter_only_alert").val(val); + if (i == 'search_secondary_groups') + $("#checkbox-search_secondary_groups").val(val); if (i == 'id_group_filter') $("#id_group_filter").val(val); if (i == 'source') @@ -891,6 +896,7 @@ function save_new_filter() { "tag_with": Base64.decode($("#hidden-tag_with").val()), "tag_without": Base64.decode($("#hidden-tag_without").val()), "filter_only_alert" : $("#filter_only_alert").val(), + "search_secondary_groups" : $("#checkbox-search_secondary_groups").val(), "id_group_filter": $("#id_group_filter").val(), "date_from": $("#text-date_from").val(), "time_from": $("#text-time_from").val(), @@ -966,6 +972,7 @@ function save_update_filter() { "tag_with" : Base64.decode($("#hidden-tag_with").val()), "tag_without" : Base64.decode($("#hidden-tag_without").val()), "filter_only_alert" : $("#filter_only_alert").val(), + "search_secondary_groups" : $("#checkbox-search_secondary_groups").val(), "id_group_filter": $("#id_group_filter").val(), "date_from": $("#text-date_from").val(), "time_from": $("#text-time_from").val(), @@ -2467,6 +2474,7 @@ if ($get_events_fired) { 'tag_with' => [], 'tag_without' => [], 'filter_only_alert' => -1, + 'search_secondary_groups' => 0, 'source' => '', 'id_extra' => '', 'user_comment' => '', diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 884a0a74be..b34a313737 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -626,6 +626,7 @@ function events_update_status($id_evento, $status, $filter=null) * 'tag_with' * 'tag_without' * 'filter_only_alert' + * 'search_secondary_groups' * 'module_search' * 'group_rep' * 'server_id' @@ -904,11 +905,18 @@ function events_get_all( $groups = [ $groups ]; } - $sql_filters[] = sprintf( - ' AND (te.id_grupo IN (%s) OR tasg.id_group IN (%s))', - join(',', $groups), - join(',', $groups) - ); + if ((bool) $filter['search_secondary_groups'] === true) { + $sql_filters[] = sprintf( + ' AND (te.id_grupo IN (%s) OR tasg.id_group IN (%s))', + join(',', $groups), + join(',', $groups) + ); + } else { + $sql_filters[] = sprintf( + ' AND te.id_grupo IN (%s)', + join(',', $groups) + ); + } } // Skip system messages if user is not PM. @@ -982,11 +990,18 @@ function events_get_all( $EW_groups = users_get_groups($config['id_user'], 'EW', true, true); // Get groups where user have ER grants. - $sql_filters[] = sprintf( - ' AND (te.id_grupo IN ( %s ) OR tasg.id_group IN (%s))', - join(', ', array_keys($ER_groups)), - join(', ', array_keys($ER_groups)) - ); + if ((bool) $filter['search_secondary_groups'] === true) { + $sql_filters[] = sprintf( + ' AND (te.id_grupo IN ( %s ) OR tasg.id_group IN (%s))', + join(', ', array_keys($ER_groups)), + join(', ', array_keys($ER_groups)) + ); + } else { + $sql_filters[] = sprintf( + ' AND te.id_grupo IN ( %s )', + join(', ', array_keys($ER_groups)) + ); + } } // Prepare agent join sql filters. @@ -1396,19 +1411,33 @@ function events_get_all( ) { $tgrupo_join = 'INNER'; if (is_array($groups) === true) { - $tgrupo_join_filters[] = sprintf( - ' (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s)) - OR (tg.id_grupo = tasg.id_group AND tasg.id_group IN (%s))', - join(', ', $groups), - join(', ', $groups) - ); + if ((bool) $filter['search_secondary_groups'] === true) { + $tgrupo_join_filters[] = sprintf( + ' (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s)) + OR (tg.id_grupo = tasg.id_group AND tasg.id_group IN (%s))', + join(', ', $groups), + join(', ', $groups) + ); + } else { + $tgrupo_join_filters[] = sprintf( + ' (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s))', + join(', ', $groups) + ); + } } else { - $tgrupo_join_filters[] = sprintf( - ' (te.id_grupo = tg.id_grupo AND tg.id_grupo = %s) - OR (tg.id_grupo = tasg.id_group AND tasg.id_group = %s)', - $groups, - $groups - ); + if ((bool) $filter['search_secondary_groups'] === true) { + $tgrupo_join_filters[] = sprintf( + ' (te.id_grupo = tg.id_grupo AND tg.id_grupo = %s) + OR (tg.id_grupo = tasg.id_group AND tasg.id_group = %s)', + $groups, + $groups + ); + } else { + $tgrupo_join_filters[] = sprintf( + ' (te.id_grupo = tg.id_grupo AND tg.id_grupo = %s)', + $groups + ); + } } } else { $tgrupo_join_filters[] = ' te.id_grupo = tg.id_grupo'; @@ -1418,7 +1447,9 @@ function events_get_all( $event_lj = ''; if (!$user_is_admin || ($user_is_admin && isset($groups) === true && $groups > 0)) { db_process_sql('SET group_concat_max_len = 9999999'); - $event_lj = events_get_secondary_groups_left_join($table); + if ((bool) $filter['search_secondary_groups'] === true) { + $event_lj = events_get_secondary_groups_left_join($table); + } } $group_selects = ''; diff --git a/pandora_console/include/styles/events.css b/pandora_console/include/styles/events.css index 194bd81c70..2e92c0d302 100644 --- a/pandora_console/include/styles/events.css +++ b/pandora_console/include/styles/events.css @@ -39,7 +39,7 @@ form.flex-row ul { margin: 0.5em 3em 0.5em 0; } -div.filter_input_little { +form div.filter_input_little { flex: 1; display: flex; flex-direction: row; @@ -132,6 +132,14 @@ table.dataTable tbody td { flex: 1; } +form.flex-row div.filter_input.filter_input_switch { + justify-content: flex-start; +} + +form.flex-row div.filter_input.filter_input_switch .p-slider { + width: 30px; +} + fieldset { margin: 0 auto; } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 52997e50e4..3d6b2cc96c 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -169,6 +169,10 @@ $filter_only_alert = get_parameter( 'filter[filter_only_alert]', ($filter['filter_only_alert'] ?? '') ); +$search_secondary_groups = get_parameter( + 'filter[search_secondary_groups]', + 0 +); $id_group_filter = get_parameter( 'filter[id_group_filter]', ($filter['id_group_filter'] ?? '') @@ -1051,6 +1055,7 @@ if ($loaded_filter !== false && $from_event_graph != 1 && isset($fb64) === false $tag_without_base64 = base64_encode(json_encode($tag_without)); $filter_only_alert = $filter['filter_only_alert']; + $search_secondary_groups = ($filter['search_secondary_groups'] ?? 0); $id_group_filter = $filter['id_group_filter']; $date_from = $filter['date_from']; $time_from = $filter['time_from']; @@ -1669,6 +1674,24 @@ $in = '