From 91d11bd4cf32868a966782b3af84a93b2372f86d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= <jose.gonzalez@pandorafms.com>
Date: Tue, 18 May 2021 16:37:05 +0200
Subject: [PATCH] Controlled pandora_revent with id_agent 0

---
 pandora_console/include/functions_api.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php
index a4fdddc405..a37d1dbd7d 100644
--- a/pandora_console/include/functions_api.php
+++ b/pandora_console/include/functions_api.php
@@ -12905,7 +12905,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
 
         $error_msg = '';
         if ($other['data'][2] != '') {
-            // Id agent assignment.
+            // Id agent assignment. If come from pandora_revent, id_agent can be 0.
             $id_agent = $other['data'][2];
             // To the next if is metaconsole and id_agent is not none.
             if (is_metaconsole() === true && $id_agent > 0) {
@@ -12931,7 +12931,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
 
             $values['id_agente'] = $id_agent;
 
-            if (!util_api_check_agent_and_print_error($id_agent, 'string', 'AR')) {
+            if ((int) $id_agent > 0 && util_api_check_agent_and_print_error($id_agent, 'string', 'AR') === false) {
                 if (is_metaconsole()) {
                     metaconsole_restore_db();
                 }