modified get_events functions in functions_api

This commit is contained in:
alejandro-campos 2019-10-24 13:18:26 +02:00
parent f2dbcea183
commit a4988fe9af
1 changed files with 32 additions and 20 deletions

View File

@ -8701,21 +8701,25 @@ function otherParameter2Filter($other, $return_as_array=false, $use_agent_name=f
$filter['criticity'] = $other['data'][1];
}
$idAgent = null;
if (isset($other['data'][2]) && $other['data'][2] != '') {
if ($use_agent_name === true) {
$idAgentByName = agents_get_agent_id($other['data'][2]);
if ($use_agent_name === false) {
$idAgents = agents_get_agent_id_by_alias($other['data'][2]);
if (!empty($idAgentByName)) {
$filter[] = 'id_agente = '.$idAgentByName;
if (!empty($idAgents)) {
$idAgent = [];
foreach ($idAgents as $key => $value) {
$idAgent[] .= $value['id_agente'];
}
$filter[] = 'id_agente IN ('.implode(',', $idAgent).')';
} else {
$filter['sql'] = '1=0';
}
} else {
$idAgents = agents_get_agent_id_by_alias($other['data'][2]);
$idAgent = agents_get_agent_id($other['data'][2]);
if (!empty($idAgent)) {
$filter[] = 'id_agente IN ('.explode(',', $idAgents).')';
$filter[] = 'id_agente = '.$idAgent;
} else {
$filter['sql'] = '1=0';
}
@ -8729,9 +8733,21 @@ function otherParameter2Filter($other, $return_as_array=false, $use_agent_name=f
$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';
}
}
@ -8820,13 +8836,11 @@ function otherParameter2Filter($other, $return_as_array=false, $use_agent_name=f
if ($other['data'][12] == 'more_criticity') {
$filter['more_criticity'] = true;
}
} else {
}
} else {
if ($return_as_array) {
$filter['total'] = false;
$filter['more_criticity'] = false;
} else {
}
}
@ -8834,7 +8848,7 @@ function otherParameter2Filter($other, $return_as_array=false, $use_agent_name=f
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];
}
}
@ -10239,7 +10253,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$utimestamp_upper = 0;
$utimestamp_bottom = 0;
$use_agent_name = ($other['data'][14] === '1') ? true : false;
$use_agent_name = ($other['data'][16] === '1') ? true : false;
$filter = otherParameter2Filter($other, true, $use_agent_name);
@ -10661,8 +10675,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;
}
@ -10702,8 +10715,6 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db=null)
returnError('ERROR_API_PANDORAFMS', $returnType);
}
}
return;
}
if ($other['type'] == 'string') {
@ -10717,12 +10728,13 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db=null)
} else if ($other['type'] == 'array') {
$separator = $other['data'][0];
$use_agent_name = ($other['data'][14] === '1') ? true : false;
// By default it uses agent alias.
$use_agent_name = ($other['data'][16] === '1') ? true : false;
$filterString = otherParameter2Filter($other, false, $use_agent_name);
}
if (defined('METACONSOLE')) {
if (is_metaconsole()) {
$dataRows = db_get_all_rows_filter('tmetaconsole_event', $filterString);
} else {
$dataRows = db_get_all_rows_filter('tevento', $filterString);