From adb7c33863cff0ac45f6c067116aec4099a83c27 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 26 Jun 2023 17:05:46 +0200 Subject: [PATCH 1/2] #10870 changed status from view details views when is agruped by extraid --- pandora_console/include/ajax/events.php | 18 ++++++++++++++---- pandora_console/include/functions_events.php | 8 ++++++-- .../include/javascript/pandora_events.js | 5 +++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 666d23d244..991081b2aa 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -1487,6 +1487,7 @@ if ($add_comment === true) { if ($change_status === true) { $event_ids = get_parameter('event_ids'); $new_status = get_parameter('new_status'); + $group_rep = (int) get_parameter('group_rep', 0); $server_id = 0; if (is_metaconsole() === true) { $server_id = (int) get_parameter('server_id'); @@ -1500,10 +1501,19 @@ if ($change_status === true) { $node->connect(); } - $return = events_change_status( - explode(',', $event_ids), - $new_status - ); + if ($group_rep !== 3) { + $return = events_change_status( + explode(',', $event_ids), + $new_status + ); + } else { + // Update all elements with same extraid. + $return = events_update_status( + $event_ids, + (int) $new_status, + ['group_rep' => $group_rep] + ); + } } catch (\Exception $e) { // Unexistent agent. if (is_metaconsole() === true diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 8d5aeedd6f..c2c790d951 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -477,7 +477,7 @@ function events_update_status($id_evento, $status, $filter=null) { global $config; - if (!$status) { + if (!$status && $status !== 0) { return false; } @@ -3595,11 +3595,15 @@ function events_page_responses($event) ); if ($status_blocked === false) { + if (isset($event['server_id']) === false) { + $event['server_id'] = '0'; + } + $data[2] = html_print_button( __('Update'), 'status_button', false, - 'event_change_status("'.$event['similar_ids'].'",'.$event['server_id'].');', + 'event_change_status("'.$event['similar_ids'].'",'.$event['server_id'].', '.$event['group_rep'].');', [ 'icon' => 'next', 'mode' => 'link', diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 2092d30589..2e78370908 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -322,7 +322,7 @@ function perform_response(response, response_id, index = "") { } // Change the status of an event to new, in process or validated. -function event_change_status(event_ids, server_id) { +function event_change_status(event_ids, server_id, group_rep) { var new_status = $("#estado").val(); $("#button-status_button").attr("disabled", "disabled"); @@ -334,7 +334,8 @@ function event_change_status(event_ids, server_id) { change_status: 1, event_ids: event_ids, new_status: new_status, - server_id: server_id + server_id: server_id, + group_rep: group_rep }, type: "POST", url: getUrlAjax(), From dd5a4887a2fbea54e800fa71db08418af52d024b Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Fri, 18 Aug 2023 14:14:51 +0200 Subject: [PATCH 2/2] #10870 fixed change status from event --- pandora_console/include/functions_events.php | 4 +--- pandora_console/operation/events/export_csv.php | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 1c62ccad7c..32113327b8 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1762,11 +1762,9 @@ function events_get_all( } } - $string_metaconsole_connections = implode(',', $metaconsole_connections); - $explode_metaconsole_connections = explode(',', $string_metaconsole_connections); $result_meta = Promise\wait( parallelMap( - $explode_metaconsole_connections, + $metaconsole_connections, function ($node_int) use ($sql, $history) { try { if (is_metaconsole() === true diff --git a/pandora_console/operation/events/export_csv.php b/pandora_console/operation/events/export_csv.php index d820b8302a..ab5abde993 100644 --- a/pandora_console/operation/events/export_csv.php +++ b/pandora_console/operation/events/export_csv.php @@ -157,6 +157,10 @@ try { throw new Exception('Invalid filter. ['.$plain_filter.']'); } + if (key_exists('server_id', $filter) === true && is_array($filter['server_id']) === false) { + $filter['server_id'] = explode(',', $filter['server_id']); + } + $filter['csv_all'] = true; $names = events_get_column_names($column_names);