From 31c36dc0155131d0aea60b0d19e4c0b70aaf4a7c Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Wed, 23 Oct 2019 15:53:30 +0200 Subject: [PATCH] Ent 4819 no funciona llamada api get events --- pandora_console/include/functions_api.php | 39 +++++++++++++++-------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 2473b5c2af..ca52209101 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -8293,12 +8293,16 @@ function otherParameter2Filter($other, $return_as_array=false) $filter['criticity'] = $other['data'][1]; } - $idAgent = null; if (isset($other['data'][2]) && $other['data'][2] != '') { $idAgents = agents_get_agent_id_by_alias($other['data'][2]); - if (!empty($idAgent)) { - $filter[] = 'id_agente IN ('.explode(',', $idAgents).')'; + if (!empty($idAgents)) { + $idAgent = []; + foreach ($idAgents as $key => $value) { + $idAgent[] .= $value['id_agente']; + } + + $filter[] = 'id_agente IN ('.implode(',', $idAgent).')'; } else { $filter['sql'] = '1=0'; } @@ -8311,9 +8315,21 @@ function otherParameter2Filter($other, $return_as_array=false) $filterModule['id_agente'] = $idAgent; } - $idAgentModulo = db_get_value_filter('id_agente_modulo', 'tagente_modulo', $filterModule); - if ($idAgentModulo !== false) { - $filter['id_agentmodule'] = $idAgentModulo; + $idAgentModulo = db_get_all_rows_filter('tagente_modulo', $filterModule, 'id_agente_modulo'); + + if (!empty($idAgentModulo)) { + $id_agentmodule = []; + foreach ($idAgentModulo as $key => $value) { + $id_agentmodule[] .= $value['id_agente_modulo']; + } + + $idAgentModulo = $id_agentmodule; + if ($idAgentModulo !== false) { + $filter['id_agentmodule'] = $idAgentModulo; + } + } else { + // If the module doesn't exist or doesn't exist in that agent. + $filter['sql'] = '1=0'; } } @@ -8402,13 +8418,11 @@ function otherParameter2Filter($other, $return_as_array=false) if ($other['data'][12] == 'more_criticity') { $filter['more_criticity'] = true; } - } else { } } else { if ($return_as_array) { $filter['total'] = false; $filter['more_criticity'] = false; - } else { } } @@ -8416,7 +8430,7 @@ function otherParameter2Filter($other, $return_as_array=false) if ($return_as_array) { $filter['id_group'] = $other['data'][13]; } else { - $filterString .= ' AND id_grupo ='.$other['data'][13]; + $filterString .= ' AND id_grupo = '.$other['data'][13]; } } @@ -10045,8 +10059,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db $data['type'] = 'array'; $data['data'] = $result; - returnData($returnType, $data, $separator); - + // returnData($returnType, $data, $separator); if (empty($result)) { return false; } @@ -10086,8 +10099,6 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db=null) returnError('ERROR_API_PANDORAFMS', $returnType); } } - - return; } if ($other['type'] == 'string') { @@ -10104,7 +10115,7 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db=null) $filterString = otherParameter2Filter($other); } - if (defined('METACONSOLE')) { + if (is_metaconsole()) { $dataRows = db_get_all_rows_filter('tmetaconsole_event', $filterString); } else { $dataRows = db_get_all_rows_filter('tevento', $filterString);