diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index b790e5f8cc..76e10533aa 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -15990,3 +15990,34 @@ function util_api_check_agent_and_print_error($id_agent, $returnType, $access='A return false; } + + +/** + * Function for get event id and node id, then we get in return the Metaconsole event ID. + * + * @param [string] $server_id id server (Node) + * @param [string] $console_event_id console Id node event in tmetaconsole_event + * @param [string] $trash2 don't use + * @param [string] $returnType + * + * Example + * api.php?op=get&op2=event_mcid&return_type=json&id=0&id2=0&apipass=1234&user=admin&pass=pandora + * + * @return void + */ +function api_get_event_mcid($server_id, $console_event_id, $trash2, $returnType) +{ + global $config; + + if (is_metaconsole()) { + $mc_event_id = db_get_all_rows_sql("SELECT id_evento FROM tmetaconsole_event WHERE id_source_event = $console_event_id AND server_id = $server_id "); + if ($mc_event_id !== false) { + returnData($returnType, ['type' => 'string', 'data' => $mc_event_id]); + } else { + returnError('id_not_found', 'string'); + } + } else { + returnError('forbidden', 'string'); + return; + } +}