diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index c902a6479a..dcc92fa446 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -372,8 +372,8 @@ if ($save_event_filter) { $values['custom_data'] = get_parameter('custom_data'); $values['custom_data_filter_type'] = get_parameter('custom_data_filter_type'); - if (is_metaconsole()) { - $values['server_id'] = get_parameter('server_id'); + if (is_metaconsole() === true) { + $values['server_id'] = implode(',', get_parameter('server_id')); } $exists = (bool) db_get_value_filter( @@ -430,7 +430,7 @@ if ($update_event_filter) { $values['custom_data_filter_type'] = get_parameter('custom_data_filter_type'); if (is_metaconsole() === true) { - $values['server_id'] = get_parameter('server_id'); + $values['server_id'] = implode(',', get_parameter('server_id')); } if (io_safe_output($values['tag_with']) == '["0"]') { diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index b3aece13a3..ddd87077db 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1381,7 +1381,7 @@ function events_get_all( // Pagination. $pagination = ''; if (is_metaconsole() === true - && empty($id_server) === true + && (empty($id_server) === true || is_array($id_server) === true) && isset($filter['csv_all']) === false ) { // TODO: XXX TIP. captura el error. @@ -1656,7 +1656,9 @@ function events_get_all( if ($count === true && (is_metaconsole() === false - || (is_metaconsole() === true && empty($filter['server_id']) === false)) + || (is_metaconsole() === true + && empty($filter['server_id']) === false + && is_array($filter['server_id']) === false)) ) { $sql = 'SELECT count(*) as nitems FROM ('.$sql.') tt'; } @@ -1672,8 +1674,21 @@ function events_get_all( $metaconsole_connections = array_flip($metaconsole_connections); $metaconsole_connections['meta'] = 0; } else { - $only_id_server[$metaconsole_connections[$id_server]] = $id_server; - $metaconsole_connections = $only_id_server; + if (is_array($id_server) === false) { + $only_id_server[$metaconsole_connections[$id_server]] = $id_server; + $metaconsole_connections = $only_id_server; + } else { + $metaConnections = []; + foreach ($id_server as $idser) { + if ((int) $idser === 0) { + $metaConnections['meta'] = 0; + } else { + $metaConnections[$metaconsole_connections[$idser]] = $idser; + } + } + + $metaconsole_connections = $metaConnections; + } } $result_meta = Promise\wait( @@ -1747,7 +1762,7 @@ function events_get_all( } } - if (empty($filter['server_id']) === true) { + if ($count === false) { if ($sort_field !== 'agent_name' && $sort_field !== 'server_name' && $sort_field !== 'timestamp' diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index b3d4b52377..b07ac67a06 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -218,9 +218,36 @@ $id_source_event = get_parameter( $server_id = get_parameter( 'filter[server_id]', - ($filter['id_server_meta'] ?? 0) + ($filter['id_server_meta'] ?? '') ); +if (is_metaconsole() === true) { + $servers = metaconsole_get_servers(); + if (is_array($servers) === true) { + $servers = array_reduce( + $servers, + function ($carry, $item) { + $carry[$item['id']] = $item['server_name']; + return $carry; + } + ); + } else { + $servers = []; + } + + $servers[0] = __('Metaconsola'); + + if ($server_id === '') { + $server_id = array_keys($servers); + } else if (is_array($server_id) === false) { + if ((int) $server_id !== 0) { + $server_id = [$server_id]; + } else { + $server_id = array_keys($servers); + } + } +} + $custom_data_filter_type = get_parameter( 'filter[custom_data_filter_type]', ($filter['custom_data_filter_type'] ?? '') @@ -363,7 +390,8 @@ if (is_ajax() === true) { $buffers = []; if (is_metaconsole() === false || (is_metaconsole() === true - && empty($filter['server_id']) === false) + && empty($filter['server_id']) === false + && is_array($filter['server_id']) === false) ) { $count = events_get_all( 'count', @@ -1788,14 +1816,19 @@ $adv_inputs[] = $in; // Mixed. Metaconsole => server, Console => module. if (is_metaconsole() === true) { $title = __('Server'); - $data = html_print_select_from_sql( - 'SELECT id, server_name FROM tmetaconsole_setup', + $data = html_print_select( + $servers, 'server_id', $server_id, '', - __('All'), - '0', - true + '', + 0, + true, + true, + true, + '', + false, + 'height: 60px;' ); } else { $title = __('Module search'); @@ -2817,7 +2850,7 @@ $(document).ready( function() { data: { page: 'include/ajax/events', load_filter_modal: 1 - }, + }, success: function (data){ $('#load-modal-filter') .empty()