#10127 added param 'id_node' in set_validate_events for update from metaconsole

This commit is contained in:
Daniel Cebrian 2023-01-31 12:37:55 +01:00
parent 2c047cb401
commit d49f1320f5
1 changed files with 41 additions and 6 deletions

View File

@ -11061,20 +11061,55 @@ function api_set_event_validate_filter($trash1, $trash2, $other, $trash3)
function api_set_validate_events($id_event, $trash1, $other, $return_type, $user_in_db)
{
$text = $other['data'];
$node_int = 0;
if ($other['type'] == 'string') {
returnError('Parameter error.');
return;
} else if ($other['type'] == 'array') {
$text = $other['data'][0];
if (is_metaconsole() === true) {
if (isset($other['data'][1]) === true
&& empty($other['data'][1]) === false
) {
$node_int = $other['data'][1];
}
}
}
try {
if (is_metaconsole() === true
&& (int) $node_int > 0
) {
$node = new Node($node_int);
$node->connect();
}
// Set off the standby mode when close an event
$event = events_get_event($id_event);
alerts_agent_module_standby($event['id_alert_am'], 0);
$result = events_change_status($id_event, EVENT_VALIDATE);
if ($result) {
if (!empty($text)) {
// Set the comment for the validation
events_comment($id_event, $text);
}
} catch (\Exception $e) {
if (is_metaconsole() === true
&& $node_int > 0
) {
$node->disconnect();
}
$result = false;
} finally {
if (is_metaconsole() === true
&& $node_int > 0
) {
$node->disconnect();
}
}
if ($result) {
returnData(
'string',
[