Merge branch 'ent-10127-14800-anadir-id_nodo-a-llamada-api-validate_events' into 'develop'

Ent 10127 14800 anadir id nodo a llamada api validate events

See merge request artica/pandorafms!5479
This commit is contained in:
Diego Muñoz-Reja 2023-02-27 16:53:01 +00:00
commit 0f635c8206
1 changed files with 41 additions and 6 deletions

View File

@ -11071,20 +11071,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];
}
}
}
// Set off the standby mode when close an event
$event = events_get_event($id_event);
alerts_agent_module_standby($event['id_alert_am'], 0);
try {
if (is_metaconsole() === true
&& (int) $node_int > 0
) {
$node = new Node($node_int);
$node->connect();
}
$result = events_change_status($id_event, EVENT_VALIDATE);
// 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',
[