fixed get event api call
This commit is contained in:
parent
3dd92397f9
commit
c360a3a06c
|
@ -9985,6 +9985,10 @@ function otherParameter2Filter($other, $return_as_array=false, $use_agent_name=f
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($idTemplate) && $idTemplate != '') {
|
||||
$filter['id_alert_template'] = $idTemplate;
|
||||
}
|
||||
|
||||
if (isset($other['data'][5]) && $other['data'][5] != '') {
|
||||
$filter['id_usuario'] = $other['data'][5];
|
||||
}
|
||||
|
@ -11451,10 +11455,9 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
|
|||
$event_view_hr = 0;
|
||||
$tag = '';
|
||||
$group_rep = 0;
|
||||
$offset = 0;
|
||||
$pagination = 40;
|
||||
$utimestamp_upper = 0;
|
||||
$utimestamp_bottom = 0;
|
||||
$id_alert_template = -1;
|
||||
|
||||
$use_agent_name = ($other['data'][16] === '1') ? true : false;
|
||||
|
||||
|
@ -11469,7 +11472,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
|
|||
}
|
||||
|
||||
if (isset($filter['id_agentmodule'])) {
|
||||
$id_agentmodule = $filter['id_agentmodule'];
|
||||
$id_agentmodule = $filter['id_agentmodule'][0];
|
||||
}
|
||||
|
||||
if (isset($filter['id_alert_am'])) {
|
||||
|
@ -11488,12 +11491,8 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
|
|||
$search = $filter['evento'];
|
||||
}
|
||||
|
||||
if (isset($filter['limit'])) {
|
||||
$pagination = $filter['limit'];
|
||||
}
|
||||
|
||||
if (isset($filter['offset'])) {
|
||||
$offset = $filter['offset'];
|
||||
if (isset($filter['id_alert_template'])) {
|
||||
$id_alert_template = $filter['id_alert_template'];
|
||||
}
|
||||
|
||||
$id_group = (int) $filter['id_group'];
|
||||
|
@ -11611,10 +11610,6 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
|
|||
$sql_post .= ' AND id_agentmodule = '.$id_agentmodule;
|
||||
}
|
||||
|
||||
if ($id_alert_am != -1) {
|
||||
$sql_post .= ' AND id_alert_am = '.$id_alert_am;
|
||||
}
|
||||
|
||||
if ($id_event != -1) {
|
||||
$sql_post .= ' AND id_evento = '.$id_event;
|
||||
}
|
||||
|
@ -11647,6 +11642,21 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
|
|||
$sql_post .= ' AND ('.$filter['sql'].') ';
|
||||
}
|
||||
|
||||
// Inject agent ID filter (it is set as the first numeric key in filter array).
|
||||
if (isset($filter[0]) === true) {
|
||||
$sql_post .= ' AND '.$filter[0];
|
||||
}
|
||||
|
||||
if ($id_alert_template !== -1) {
|
||||
$sql_post .= ' AND talert_template_modules.id_alert_template = '.$id_alert_template;
|
||||
}
|
||||
|
||||
$alert_join = '';
|
||||
|
||||
if ($id_alert_template !== -1) {
|
||||
$alert_join = ' INNER JOIN talert_template_modules ON '.$table_events.'.id_alert_am=talert_template_modules.id';
|
||||
}
|
||||
|
||||
if ($group_rep == 0) {
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
|
@ -11669,10 +11679,9 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
|
|||
(SELECT t2.icon
|
||||
FROM tgrupo t2
|
||||
WHERE t2.id_grupo = '.$table_events.'.id_grupo) AS group_icon
|
||||
FROM '.$table_events.'
|
||||
FROM '.$table_events.$alert_join.'
|
||||
WHERE 1=1 '.$sql_post.'
|
||||
ORDER BY utimestamp DESC
|
||||
LIMIT '.$offset.','.$pagination;
|
||||
ORDER BY utimestamp DESC';
|
||||
} else {
|
||||
$sql = 'SELECT *,
|
||||
(SELECT t1.alias
|
||||
|
@ -11690,10 +11699,9 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
|
|||
SELECT tagente_modulo.id_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE tagente_modulo.id_agente_modulo=tevento.id_agentmodule)) AS module_name
|
||||
FROM '.$table_events.'
|
||||
FROM '.$table_events.$alert_join.'
|
||||
WHERE 1=1 '.$sql_post.'
|
||||
ORDER BY utimestamp DESC
|
||||
LIMIT '.$offset.','.$pagination;
|
||||
ORDER BY utimestamp DESC';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -11718,15 +11726,12 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
|
|||
WHERE tagente_modulo.id_agente_modulo=tevento.id_agentmodule)) AS module_name
|
||||
FROM tevento
|
||||
WHERE 1=1 '.$sql_post.'
|
||||
ORDER BY utimestamp DESC
|
||||
LIMIT '.$pagination.' OFFSET '.$offset;
|
||||
ORDER BY utimestamp DESC';
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
// TODO TOTAL
|
||||
$set = [];
|
||||
$set['limit'] = $pagination;
|
||||
$set['offset'] = $offset;
|
||||
|
||||
$sql = 'SELECT *,
|
||||
(SELECT t1.alias
|
||||
|
@ -11764,8 +11769,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
|
|||
FROM ".$table_events.'
|
||||
WHERE 1=1 '.$sql_post.'
|
||||
GROUP BY evento, id_agentmodule
|
||||
ORDER BY timestamp_rep DESC
|
||||
LIMIT '.$offset.','.$pagination;
|
||||
ORDER BY timestamp_rep DESC';
|
||||
break;
|
||||
|
||||
case 'postgresql':
|
||||
|
@ -11776,14 +11780,11 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
|
|||
FROM ".$table_events.'
|
||||
WHERE 1=1 '.$sql_post.'
|
||||
GROUP BY evento, id_agentmodule
|
||||
ORDER BY timestamp_rep DESC
|
||||
LIMIT '.$pagination.' OFFSET '.$offset;
|
||||
ORDER BY timestamp_rep DESC';
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
$set = [];
|
||||
$set['limit'] = $pagination;
|
||||
$set['offset'] = $offset;
|
||||
// TODO: Remove duplicate user comments
|
||||
$sql = 'SELECT a.*, b.event_rep, b.timestamp_rep
|
||||
FROM (SELECT *
|
||||
|
|
Loading…
Reference in New Issue