2013-03-20 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/events.php, mobile/include/ui.class.php, mobile/index.php: added first version of events section. * include/functions_incidents.php, include/functions_users.php, include/functions.php, include/functions_groups.php, include/functions_events.php, include/functions_html.php, operation/events/events.build_table.php, operation/events/events.build_query.php, operation/events/events_list.php: some changes for interact with mobile version. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7872 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
ae253e17ea
commit
0a59852587
|
@ -1,3 +1,16 @@
|
|||
2013-03-20 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* mobile/operation/events.php, mobile/include/ui.class.php,
|
||||
mobile/index.php: added first version of events section.
|
||||
|
||||
* include/functions_incidents.php, include/functions_users.php,
|
||||
include/functions.php, include/functions_groups.php,
|
||||
include/functions_events.php, include/functions_html.php,
|
||||
operation/events/events.build_table.php,
|
||||
operation/events/events.build_query.php,
|
||||
operation/events/events_list.php: some changes for interact with
|
||||
mobile version.
|
||||
|
||||
2013-03-20 Mario Pulido <mario.pulido@artica.es>
|
||||
|
||||
* godmode/setup/setup_general.php: Add help tip in Timezone Setup
|
||||
|
|
|
@ -855,6 +855,7 @@ function is_module_uncompressed ($module_type) {
|
|||
if (strstr($module_type, 'async') !== false || strstr($module_type, 'log4x') !== false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -863,7 +864,7 @@ function is_module_uncompressed ($module_type) {
|
|||
*
|
||||
* @return array module_name Module name to check.
|
||||
*/
|
||||
function get_event_types () {
|
||||
function get_event_types ($id_type = false) {
|
||||
global $config;
|
||||
|
||||
$types = array ();
|
||||
|
@ -888,7 +889,13 @@ function get_event_types () {
|
|||
$types[$key] = ui_print_truncate_text($type, GENERIC_SIZE_TEXT, false, true, false);
|
||||
}
|
||||
|
||||
return $types;
|
||||
if ($id_type === false) {
|
||||
return $types;
|
||||
}
|
||||
else {
|
||||
html_debug_print($id_type);
|
||||
return $types[$id_type];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -896,7 +903,7 @@ function get_event_types () {
|
|||
*
|
||||
* @return array An array with all the priorities.
|
||||
*/
|
||||
function get_priorities () {
|
||||
function get_priorities ($priority_param = false) {
|
||||
global $config;
|
||||
|
||||
$priorities = array ();
|
||||
|
@ -914,7 +921,12 @@ function get_priorities () {
|
|||
$priorities[$key] = ui_print_truncate_text($priority, GENERIC_SIZE_TEXT, false, true, false);
|
||||
}
|
||||
|
||||
return $priorities;
|
||||
if ($priority_param === false) {
|
||||
return $priorities;
|
||||
}
|
||||
else {
|
||||
return $priorities[$priority_param];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -63,10 +63,11 @@ function events_get_event ($id, $fields = false) {
|
|||
$event = db_get_row ('tevento', 'id_evento', $id, $fields);
|
||||
if (! check_acl ($config['id_user'], $event['id_grupo'], 'ER'))
|
||||
return false;
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $meta = false, $history = false) {
|
||||
function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $meta = false, $history = false, $total = false) {
|
||||
global $config;
|
||||
|
||||
$table = events_get_events_table($meta, $history);
|
||||
|
@ -81,58 +82,92 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met
|
|||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
db_process_sql ('SET group_concat_max_len = 9999999');
|
||||
$sql = "SELECT *, MAX(id_evento) AS id_evento,
|
||||
GROUP_CONCAT(DISTINCT user_comment SEPARATOR '<br>') AS user_comment,
|
||||
GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids,
|
||||
COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep,
|
||||
MIN(utimestamp) AS timestamp_rep_min,
|
||||
(SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user,
|
||||
(SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario
|
||||
FROM $table te
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
GROUP BY estado, evento, id_agentmodule" . $groupby_extra . "
|
||||
ORDER BY timestamp_rep DESC LIMIT " . $offset . "," . $pagination;
|
||||
if ($total) {
|
||||
$sql = "SELECT COUNT(*) FROM (SELECT *
|
||||
FROM $table te
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
GROUP BY estado, evento, id_agentmodule" . $groupby_extra . ") AS t";
|
||||
}
|
||||
else {
|
||||
$sql = "SELECT *, MAX(id_evento) AS id_evento,
|
||||
GROUP_CONCAT(DISTINCT user_comment SEPARATOR '<br>') AS user_comment,
|
||||
GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids,
|
||||
COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep,
|
||||
MIN(utimestamp) AS timestamp_rep_min,
|
||||
(SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user,
|
||||
(SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario
|
||||
FROM $table te
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
GROUP BY estado, evento, id_agentmodule" . $groupby_extra . "
|
||||
ORDER BY timestamp_rep DESC LIMIT " . $offset . "," . $pagination;
|
||||
}
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = "SELECT *, MAX(id_evento) AS id_evento, array_to_string(array_agg(DISTINCT user_comment), '<br>') AS user_comment,
|
||||
array_to_string(array_agg(DISTINCT id_evento), ',') AS similar_ids,
|
||||
COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep,
|
||||
if ($total) {
|
||||
$sql = "SELECT COUNT(*)
|
||||
FROM $table te
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
GROUP BY estado, evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra" . $groupby_extra;
|
||||
}
|
||||
else {
|
||||
$sql = "SELECT *, MAX(id_evento) AS id_evento, array_to_string(array_agg(DISTINCT user_comment), '<br>') AS user_comment,
|
||||
array_to_string(array_agg(DISTINCT id_evento), ',') AS similar_ids,
|
||||
COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep,
|
||||
MIN(utimestamp) AS timestamp_rep_min,
|
||||
(SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user,
|
||||
(SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario
|
||||
FROM $table te
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
GROUP BY estado, evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra" . $groupby_extra . "
|
||||
ORDER BY timestamp_rep DESC LIMIT " . $pagination . " OFFSET " . $offset;
|
||||
}
|
||||
break;
|
||||
case "oracle":
|
||||
if ($total) {
|
||||
$sql = "SELECT COUNT(*)
|
||||
FROM $table te
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
GROUP BY estado, to_char(evento), id_agentmodule" . $groupby_extra . ") b ";
|
||||
}
|
||||
else {
|
||||
$set = array();
|
||||
$set['limit'] = $pagination;
|
||||
$set['offset'] = $offset;
|
||||
// TODO: Remove duplicate user comments
|
||||
$sql = "SELECT a.*, b.event_rep, b.timestamp_rep
|
||||
FROM (SELECT * FROM $table WHERE 1=1 " . $sql_post . ") a,
|
||||
(SELECT MAX (id_evento) AS id_evento, to_char(evento) AS evento,
|
||||
id_agentmodule, COUNT(*) AS event_rep,
|
||||
LISTAGG(user_comment, '') AS user_comment, MAX(utimestamp) AS timestamp_rep,
|
||||
LISTAGG(id_evento, '') AS similar_ids,
|
||||
MIN(utimestamp) AS timestamp_rep_min,
|
||||
(SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user,
|
||||
(SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario
|
||||
FROM $table te
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
GROUP BY estado, evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra" . $groupby_extra . "
|
||||
ORDER BY timestamp_rep DESC LIMIT " . $pagination . " OFFSET " . $offset;
|
||||
break;
|
||||
case "oracle":
|
||||
$set = array();
|
||||
$set['limit'] = $pagination;
|
||||
$set['offset'] = $offset;
|
||||
// TODO: Remove duplicate user comments
|
||||
$sql = "SELECT a.*, b.event_rep, b.timestamp_rep
|
||||
FROM (SELECT * FROM $table WHERE 1=1 " . $sql_post . ") a,
|
||||
(SELECT MAX (id_evento) AS id_evento, to_char(evento) AS evento,
|
||||
id_agentmodule, COUNT(*) AS event_rep,
|
||||
LISTAGG(user_comment, '') AS user_comment, MAX(utimestamp) AS timestamp_rep,
|
||||
LISTAGG(id_evento, '') AS similar_ids,
|
||||
MIN(utimestamp) AS timestamp_rep_min,
|
||||
(SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user,
|
||||
(SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario
|
||||
FROM $table te
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
GROUP BY estado, to_char(evento), id_agentmodule" . $groupby_extra . ") b
|
||||
WHERE a.id_evento=b.id_evento AND
|
||||
to_char(a.evento)=to_char(b.evento)
|
||||
AND a.id_agentmodule=b.id_agentmodule";
|
||||
$sql = oracle_recode_query ($sql, $set);
|
||||
FROM $table te
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
GROUP BY estado, to_char(evento), id_agentmodule" . $groupby_extra . ") b
|
||||
WHERE a.id_evento=b.id_evento AND
|
||||
to_char(a.evento)=to_char(b.evento)
|
||||
AND a.id_agentmodule=b.id_agentmodule";
|
||||
$sql = oracle_recode_query ($sql, $set);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//Extract the events by filter (or not) from db
|
||||
$events = db_get_all_rows_sql ($sql);
|
||||
|
||||
return $events;
|
||||
if ($total) {
|
||||
return reset($events[0]);
|
||||
}
|
||||
else {
|
||||
return $events;
|
||||
}
|
||||
}
|
||||
|
||||
function events_get_total_events_grouped($sql_post, $meta = false, $history = false) {
|
||||
return events_get_events_grouped($sql_post, 0, 0, $meta, $history, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -306,7 +341,7 @@ function events_validate_event ($id_event, $similars = true, $new_status = 1, $m
|
|||
$event = events_get_event ($event);
|
||||
}
|
||||
|
||||
if($event['id_alert_am'] > 0 && !in_array($event['id_alert_am'], $alerts)) {
|
||||
if ($event['id_alert_am'] > 0 && !in_array($event['id_alert_am'], $alerts)) {
|
||||
$alerts[] = $event['id_alert_am'];
|
||||
}
|
||||
|
||||
|
@ -385,7 +420,7 @@ function events_change_status ($id_event, $new_status, $meta = false, $history =
|
|||
$ack_user = '';
|
||||
}
|
||||
|
||||
switch($new_status) {
|
||||
switch ($new_status) {
|
||||
case EVENT_STATUS_NEW:
|
||||
$status_string = 'New';
|
||||
break;
|
||||
|
@ -403,7 +438,7 @@ function events_change_status ($id_event, $new_status, $meta = false, $history =
|
|||
$alerts = array();
|
||||
|
||||
foreach ($id_event as $k => $id) {
|
||||
if($meta) {
|
||||
if ($meta) {
|
||||
$event_group = events_meta_get_group ($id, $history);
|
||||
$event = events_meta_get_event ($id, false, $history);
|
||||
$server_id = $event['server_id'];
|
||||
|
@ -413,7 +448,7 @@ function events_change_status ($id_event, $new_status, $meta = false, $history =
|
|||
$event = events_get_event ($id);
|
||||
}
|
||||
|
||||
if($event['id_alert_am'] > 0 && !in_array($event['id_alert_am'], $alerts)) {
|
||||
if ($event['id_alert_am'] > 0 && !in_array($event['id_alert_am'], $alerts)) {
|
||||
$alerts[] = $event['id_alert_am'];
|
||||
}
|
||||
|
||||
|
@ -487,7 +522,7 @@ function events_change_owner ($id_event, $new_owner = false, $force = false, $me
|
|||
$id_event = (array) safe_int ($id_event, 1);
|
||||
|
||||
foreach ($id_event as $k => $id) {
|
||||
if($meta) {
|
||||
if ($meta) {
|
||||
$event_group = events_meta_get_group ($id, $history);
|
||||
}
|
||||
else {
|
||||
|
@ -499,17 +534,17 @@ function events_change_owner ($id_event, $new_owner = false, $force = false, $me
|
|||
}
|
||||
}
|
||||
|
||||
if(empty($id_event)) {
|
||||
if (empty($id_event)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If no new_owner is provided, the current user will be the owner
|
||||
if(empty($new_owner)) {
|
||||
if (empty($new_owner)) {
|
||||
$new_owner = $config['id_user'];
|
||||
}
|
||||
|
||||
// Only generate comment when is forced (sometimes is changed the owner when comment)
|
||||
if($force) {
|
||||
if ($force) {
|
||||
events_comment($id_event, '', "Change owner to $new_owner", $meta, $history);
|
||||
}
|
||||
|
||||
|
@ -518,7 +553,7 @@ function events_change_owner ($id_event, $new_owner = false, $force = false, $me
|
|||
$where = array('id_evento' => $id_event);
|
||||
|
||||
// If not force, add to where if owner_user = ''
|
||||
if(!$force) {
|
||||
if (!$force) {
|
||||
$where['owner_user'] = '';
|
||||
}
|
||||
|
||||
|
@ -534,7 +569,7 @@ function events_change_owner ($id_event, $new_owner = false, $force = false, $me
|
|||
|
||||
function events_get_events_table($meta, $history) {
|
||||
if ($meta) {
|
||||
if($history) {
|
||||
if ($history) {
|
||||
$event_table = 'tmetaconsole_event_history';
|
||||
}
|
||||
else {
|
||||
|
@ -1416,18 +1451,23 @@ function events_get_all_status (){
|
|||
*
|
||||
* @return string Status description.
|
||||
*/
|
||||
function events_get_status ($status_id){
|
||||
switch($status_id) {
|
||||
case -1: $status_desc = __('All event');
|
||||
break;
|
||||
case 0: $status_desc = __('Only new');
|
||||
break;
|
||||
case 1: $status_desc = __('Only validated');
|
||||
break;
|
||||
case 2: $status_desc = __('Only in process');
|
||||
break;
|
||||
case 3: $status_desc = __('Only not validated');
|
||||
break;
|
||||
function events_get_status ($status_id) {
|
||||
switch ($status_id) {
|
||||
case -1:
|
||||
$status_desc = __('All event');
|
||||
break;
|
||||
case 0:
|
||||
$status_desc = __('Only new');
|
||||
break;
|
||||
case 1:
|
||||
$status_desc = __('Only validated');
|
||||
break;
|
||||
case 2:
|
||||
$status_desc = __('Only in process');
|
||||
break;
|
||||
case 3:
|
||||
$status_desc = __('Only not validated');
|
||||
break;
|
||||
}
|
||||
|
||||
return $status_desc;
|
||||
|
|
|
@ -471,7 +471,8 @@ function groups_get_groups_tree_recursive($groups, $parent = 0, $deep = 0) {
|
|||
$return = array();
|
||||
|
||||
foreach ($groups as $key => $group) {
|
||||
if (($key === 0 || $key === __('All')) && ($parent === 0 || $parent === __('All'))) { //When the groups is the all group
|
||||
if (($key === 0 || $key === __('All')) && ($parent === 0 || $parent === __('All'))) {
|
||||
//When the groups is the all group
|
||||
$group['deep'] = $deep;
|
||||
$group['hash_branch'] = true;
|
||||
$deep ++;
|
||||
|
|
|
@ -362,10 +362,13 @@ function html_print_select_style ($fields, $name, $selected = '', $style='', $sc
|
|||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
function html_print_select_groups($id_user = false, $privilege = "AR", $returnAllGroup = true,
|
||||
$name, $selected = '', $script = '', $nothing = '', $nothing_value = 0, $return = false,
|
||||
$multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false,
|
||||
$id_group = false, $keys_field = 'id_grupo') {
|
||||
function html_print_select_groups($id_user = false, $privilege = "AR",
|
||||
$returnAllGroup = true, $name, $selected = '', $script = '',
|
||||
$nothing = '', $nothing_value = 0, $return = false,
|
||||
$multiple = false, $sort = true, $class = '', $disabled = false,
|
||||
$style = false, $option_style = false, $id_group = false,
|
||||
$keys_field = 'id_grupo') {
|
||||
|
||||
global $config;
|
||||
|
||||
$fields = users_get_groups_for_select($id_user, $privilege,
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
*
|
||||
* @return array The several priorities with their values
|
||||
*/
|
||||
function incidents_get_priorities () {
|
||||
function incidents_get_priorities ($priority = false) {
|
||||
$fields = array();
|
||||
$fields[0] = __('Informative');
|
||||
$fields[1] = __('Low');
|
||||
|
@ -33,7 +33,12 @@ function incidents_get_priorities () {
|
|||
$fields[4] = __('Very serious');
|
||||
$fields[10] = __('Maintenance');
|
||||
|
||||
return $fields;
|
||||
if ($priority === false) {
|
||||
return $fields;
|
||||
}
|
||||
else {
|
||||
return $fields[$priority];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,10 +31,12 @@ require_once($config['homedir'] . "/include/functions_groups.php");
|
|||
*/
|
||||
function users_get_info ($order = "fullname", $info = "fullname") {
|
||||
$users = get_users ($order);
|
||||
|
||||
$ret = array ();
|
||||
foreach ($users as $user_id => $user_info) {
|
||||
$ret[$user_id] = $user_info[$info];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
@ -60,12 +62,13 @@ function users_disable ($user_id, $new_disabled_value) {
|
|||
*/
|
||||
function users_get_all_model_groups () {
|
||||
$groups = db_get_all_rows_in_table ('tmodule_group');
|
||||
if($groups === false) {
|
||||
if ($groups === false) {
|
||||
$groups = array();
|
||||
}
|
||||
|
||||
$returnGroups = array();
|
||||
foreach ($groups as $group)
|
||||
$returnGroups[$group['id_mg']] = $group['name'];
|
||||
$returnGroups[$group['id_mg']] = $group['name'];
|
||||
|
||||
$returnGroups[0] = "Not assigned"; //Module group external to DB but it exist
|
||||
|
||||
|
@ -86,12 +89,12 @@ function users_get_all_model_groups () {
|
|||
* @return array A list of the groups the user has certain privileges.
|
||||
*/
|
||||
function users_get_groups_for_select($id_user, $privilege = "AR", $returnAllGroup = true, $returnAllColumns = false, $id_groups = null, $keys_field = 'id_grupo') {
|
||||
if($id_groups === false) {
|
||||
if ($id_groups === false) {
|
||||
$id_groups = null;
|
||||
}
|
||||
|
||||
$user_groups = users_get_groups ($id_user, $privilege, $returnAllGroup, $returnAllColumns, null);
|
||||
|
||||
|
||||
if ($id_groups !== null) {
|
||||
$childrens = groups_get_childrens($id_groups);
|
||||
foreach ($childrens as $child) {
|
||||
|
@ -251,7 +254,7 @@ function users_get_first_group ($id_user = false, $privilege = "AR", $all_group
|
|||
*/
|
||||
function users_access_to_agent ($id_agent, $mode = "AR", $id_user = false) {
|
||||
if (empty ($id_agent))
|
||||
return false;
|
||||
return false;
|
||||
|
||||
if ($id_user == false) {
|
||||
global $config;
|
||||
|
@ -259,6 +262,7 @@ function users_access_to_agent ($id_agent, $mode = "AR", $id_user = false) {
|
|||
}
|
||||
|
||||
$id_group = (int) db_get_value ('id_grupo', 'tagente', 'id_agente', (int) $id_agent);
|
||||
|
||||
return (bool) check_acl ($id_user, $id_group, $mode);
|
||||
}
|
||||
|
||||
|
@ -353,7 +357,7 @@ function users_save_login() {
|
|||
|
||||
$user = db_get_row_filter('tusuario',
|
||||
array('id_user' => $config['id_user']));
|
||||
|
||||
|
||||
$message = sprintf(__('User %s login at %s'), $user['fullname'],
|
||||
date($config['date_format']));
|
||||
users_save_text_message($message, 'notification');
|
||||
|
@ -796,7 +800,7 @@ function users_can_manage_group_all($id_group = 0) {
|
|||
}
|
||||
|
||||
$is_admin = db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']);
|
||||
|
||||
|
||||
if (check_acl ($config['id_user'], 0, "PM") || $is_admin) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -472,7 +472,14 @@ class Ui {
|
|||
$item_value = $item;
|
||||
}
|
||||
|
||||
$html .= "<option value='" . $item_id . "'>" . $item_value . "</option>\n";
|
||||
$selected = '';
|
||||
if (isset($options['selected'])) {
|
||||
if ($options['selected'] == $item_id) {
|
||||
$selected = "selected = 'selected'";
|
||||
}
|
||||
}
|
||||
|
||||
$html .= "<option " . $selected . " value='" . $item_id . "'>" . $item_value . "</option>\n";
|
||||
}
|
||||
$html .= "</select>\n";
|
||||
|
||||
|
|
|
@ -47,6 +47,18 @@ if (!$user->isLogged()) {
|
|||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'ajax':
|
||||
$parameter1 = $system->getRequest('parameter1', false);
|
||||
$parameter2 = $system->getRequest('parameter2', false);
|
||||
|
||||
switch ($parameter1) {
|
||||
case 'events':
|
||||
$events = new Events();
|
||||
$events->ajax($parameter2);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
break;
|
||||
case 'login':
|
||||
if (!$user->checkLogin()) {
|
||||
$user->showLogin();
|
||||
|
|
|
@ -18,10 +18,11 @@ class Events {
|
|||
private $default = true;
|
||||
private $free_search = '';
|
||||
private $hours_old = 8;
|
||||
private $status = 2
|
||||
private $status = 3;
|
||||
private $type = "";
|
||||
private $severity = -1;
|
||||
private $filter = 0;
|
||||
private $group = 0;
|
||||
|
||||
function __construct() {
|
||||
$system = System::getInstance();
|
||||
|
@ -34,6 +35,64 @@ class Events {
|
|||
}
|
||||
}
|
||||
|
||||
public function ajax($parameter2 = false) {
|
||||
$system = System::getInstance();
|
||||
|
||||
if (!$this->correct_acl) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
switch ($parameter2) {
|
||||
case 'get_events':
|
||||
$this->eventsGetFilters();
|
||||
$page = $system->getRequest('page', 0);
|
||||
|
||||
$system = System::getInstance();
|
||||
|
||||
$listEvents = $this->getListEvents($page);
|
||||
$events_db = $listEvents['events'];
|
||||
$total_events = $listEvents['total'];
|
||||
|
||||
$events = array();
|
||||
$end = 1;
|
||||
foreach ($events_db as $event) {
|
||||
$end = 0;
|
||||
$row = array();
|
||||
$row[] = $event['evento'];
|
||||
switch ($event['estado']) {
|
||||
case 0:
|
||||
$img_st = "images/star.png";
|
||||
$title_st = __('New event');
|
||||
break;
|
||||
case 1:
|
||||
$img_st = "images/tick.png";
|
||||
$title_st = __('Event validated');
|
||||
break;
|
||||
case 2:
|
||||
$img_st = "images/hourglass.png";
|
||||
$title_st = __('Event in process');
|
||||
break;
|
||||
}
|
||||
$row[] = html_print_image ($img_st, true,
|
||||
array ("class" => "image_status",
|
||||
"width" => 16,
|
||||
"height" => 16,
|
||||
"title" => $title_st,
|
||||
"id" => 'status_img_' . $event["id_evento"]));
|
||||
$row[] = ui_print_timestamp ($event['timestamp_rep'], true);
|
||||
$row[] = ui_print_agent_name ($event["id_agente"], true);
|
||||
|
||||
|
||||
$events[$event['id_evento']] = $row;
|
||||
}
|
||||
|
||||
echo json_encode(array('end' => $end, 'events' => $events));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function eventsGetFilters() {
|
||||
$system = System::getInstance();
|
||||
|
||||
|
@ -41,17 +100,20 @@ class Events {
|
|||
if ($this->hours_old != 8) {
|
||||
$this->default = false;
|
||||
}
|
||||
|
||||
$this->free_search = $system->getRequest('free_search', '');
|
||||
if ($this->free_search != '') {
|
||||
$this->default = false;
|
||||
}
|
||||
|
||||
$this->status = $system->getRequest('status', __("Status"));
|
||||
if ($this->status === __("Status")) {
|
||||
$this->status = 2;
|
||||
$this->status = 3;
|
||||
}
|
||||
else {
|
||||
$this->default = false;
|
||||
}
|
||||
|
||||
$this->type = $system->getRequest('type', __("Type"));
|
||||
if ($this->type === __("Type")) {
|
||||
$this->type = "";
|
||||
|
@ -59,6 +121,15 @@ class Events {
|
|||
else {
|
||||
$this->default = false;
|
||||
}
|
||||
|
||||
$this->severity = $system->getRequest('group', __("Group"));
|
||||
if ($this->severity === __("Group")) {
|
||||
$this->severity = 0;
|
||||
}
|
||||
else {
|
||||
$this->default = false;
|
||||
}
|
||||
|
||||
$this->severity = $system->getRequest('severity', __("Severity"));
|
||||
if ($this->severity === __("Severity")) {
|
||||
$this->severity = -1;
|
||||
|
@ -76,10 +147,19 @@ class Events {
|
|||
}
|
||||
|
||||
///The user set a preset filter
|
||||
$this->loadPresetFilter()
|
||||
if ($this->filter > 0) {
|
||||
$this->loadPresetFilter();
|
||||
}
|
||||
}
|
||||
|
||||
private loadPresetFilter() {
|
||||
private function loadPresetFilter() {
|
||||
$filter = db_get_row('tevent_filter', 'id_filter', $this->filter);
|
||||
|
||||
$this->free_search = $filter['search'];
|
||||
$this->hours_old = $filter['event_view_hr'];
|
||||
$this->status = $filter['status'];
|
||||
$this->type = $filter['type'];
|
||||
$this->severity = $filter['severity'];
|
||||
}
|
||||
|
||||
public function show() {
|
||||
|
@ -117,56 +197,66 @@ class Events {
|
|||
'value' => 'events'
|
||||
);
|
||||
$ui->formAddInput($options);
|
||||
$items = array('caca' => 'caca', 'pis' => 'pis',
|
||||
'pedo' => 'pedo');
|
||||
|
||||
$items = db_get_all_rows_in_table('tevent_filter');
|
||||
$items[] = array('id_filter' => 0, 'id_name' => __('None'));
|
||||
$options = array(
|
||||
'name' => 'filter',
|
||||
'title' => __('Preset Filters'),
|
||||
'label' => __('Preset Filters'),
|
||||
'items' => $items
|
||||
'items' => $items,
|
||||
'item_id' => 'id_filter',
|
||||
'item_value' => 'id_name',
|
||||
'selected' => $this->filter
|
||||
);
|
||||
$ui->formAddSelectBox($options);
|
||||
$items = array('caca' => 'caca', 'pis' => 'pis',
|
||||
'pedo' => 'pedo');
|
||||
|
||||
$system = System::getInstance();
|
||||
$groups = users_get_groups_for_select(
|
||||
$system->getConfig('id_user'), "ER", true, true, false, 'id_grupo');
|
||||
$options = array(
|
||||
'name' => 'group',
|
||||
'title' => __('Group'),
|
||||
'label' => __('Group'),
|
||||
'items' => $items
|
||||
'items' => $groups,
|
||||
'selected' => $this->group
|
||||
);
|
||||
$items = array('caca' => 'caca', 'pis' => 'pis',
|
||||
'pedo' => 'pedo');
|
||||
$ui->formAddSelectBox($options);
|
||||
|
||||
$options = array(
|
||||
'name' => 'status',
|
||||
'title' => __('Status'),
|
||||
'label' => __('Status'),
|
||||
'items' => $items
|
||||
'items' => events_get_all_status(),
|
||||
'selected' => $this->status
|
||||
);
|
||||
$ui->formAddSelectBox($options);
|
||||
$items = array('caca' => 'caca', 'pis' => 'pis',
|
||||
'pedo' => 'pedo');
|
||||
|
||||
$options = array(
|
||||
'name' => 'type',
|
||||
'title' => __('Type'),
|
||||
'label' => __('Type'),
|
||||
'items' => $items
|
||||
'items' => get_event_types(),
|
||||
'selected' => $this->type
|
||||
);
|
||||
$ui->formAddSelectBox($options);
|
||||
$items = array('caca' => 'caca', 'pis' => 'pis',
|
||||
'pedo' => 'pedo');
|
||||
|
||||
$options = array(
|
||||
'name' => 'severity',
|
||||
'title' => __('Severity'),
|
||||
'label' => __('Severity'),
|
||||
'items' => $items
|
||||
'items' => get_priorities(),
|
||||
'selected' => $this->severity
|
||||
);
|
||||
$ui->formAddSelectBox($options);
|
||||
|
||||
$options = array(
|
||||
'name' => 'free_search',
|
||||
'value' => $this->free_search,
|
||||
'placeholder' => __('Free search')
|
||||
);
|
||||
$ui->formAddInputSearch($options);
|
||||
|
||||
$options = array(
|
||||
'label' => __('Max. hours old'),
|
||||
'name' => 'hours_old',
|
||||
|
@ -176,6 +266,7 @@ class Events {
|
|||
'step' => 8
|
||||
);
|
||||
$ui->formAddSlider($options);
|
||||
|
||||
$options = array(
|
||||
'icon' => 'refresh',
|
||||
'icon_pos' => 'right',
|
||||
|
@ -185,52 +276,239 @@ class Events {
|
|||
$html = $ui->getEndForm();
|
||||
$ui->contentCollapsibleAddItem($html);
|
||||
$ui->contentEndCollapsible();
|
||||
$this->listEvents();
|
||||
$this->listEventsHtml();
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
}
|
||||
|
||||
function listEvents() {
|
||||
$ui = Ui::getInstance();
|
||||
private function getListEvents($page = 0) {
|
||||
$system = System::getInstance();
|
||||
|
||||
//--------------Fill the SQL POST-------------------------------
|
||||
$sql_post = '';
|
||||
$result = events_get_events_grouped($sql_post,
|
||||
0, $system->getPageSize(), false, false);
|
||||
|
||||
$events = array(
|
||||
array(
|
||||
__('Status') => 'icon',
|
||||
__('Event Name') => 'nombre del evento',
|
||||
__('Timestamp') => '2 days',
|
||||
__('Agent') => 'pepito'),
|
||||
array(
|
||||
__('Status') => 'icon',
|
||||
__('Event Name') => 'nombre del evento',
|
||||
__('Timestamp') => '2 days',
|
||||
__('Agent') => 'pepito'));
|
||||
switch ($this->status) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
$sql_post .= " AND estado = " . $this->status;
|
||||
break;
|
||||
case 3:
|
||||
$sql_post .= " AND (estado = 0 OR estado = 2)";
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->free_search != "") {
|
||||
$sql_post .= " AND evento LIKE '%" . io_safe_input($this->free_search) . "%'";
|
||||
}
|
||||
|
||||
if ($this->severity != -1) {
|
||||
switch ($this->severity) {
|
||||
case EVENT_CRIT_WARNING_OR_CRITICAL:
|
||||
$sql_post .= " AND (criticity = " . EVENT_CRIT_WARNING . " OR
|
||||
criticity = " . EVENT_CRIT_CRITICAL . ")";
|
||||
break;
|
||||
case EVENT_CRIT_NOT_NORMAL:
|
||||
$sql_post .= " AND criticity != " . EVENT_CRIT_NORMAL;
|
||||
break;
|
||||
default:
|
||||
$sql_post .= " AND criticity = " . $this->severity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->hours_old > 0) {
|
||||
$unixtime = get_system_time () - ($this->hours_old * SECONDS_1HOUR);
|
||||
$sql_post .= " AND (utimestamp > " . $unixtime . ")";
|
||||
}
|
||||
|
||||
if ($this->type != "") {
|
||||
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
|
||||
// for the user so for him is presented only "warning, critical and normal"
|
||||
if ($this->type == "warning" || $this->type == "critical"
|
||||
|| $this->type == "normal") {
|
||||
$sql_post .= " AND event_type LIKE '%" . $this->type . "%' ";
|
||||
}
|
||||
elseif ($this->type == "not_normal") {
|
||||
$sql_post .= " AND event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%' ";
|
||||
}
|
||||
elseif ($this->type != "all") {
|
||||
$sql_post .= " AND event_type = '" . $this->type."'";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($this->group > 0) {
|
||||
//If a group is selected and it's in the groups allowed
|
||||
$sql_post = " AND id_grupo = " . $this->group;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
|
||||
$events_db = events_get_events_grouped($sql_post,
|
||||
$page * $system->getPageSize(), $system->getPageSize(), false, false);
|
||||
if (empty($events_db)) {
|
||||
$events_db = array();
|
||||
}
|
||||
|
||||
$total_events = events_get_total_events_grouped($sql_post);
|
||||
|
||||
return array('events' => $events_db, 'total' => $total_events);
|
||||
}
|
||||
|
||||
private function listEventsHtml($page = 0) {
|
||||
$system = System::getInstance();
|
||||
|
||||
$listEvents = $this->getListEvents($page);
|
||||
$events_db = $listEvents['events'];
|
||||
$total_events = $listEvents['total'];
|
||||
|
||||
if (empty($events_db))
|
||||
$events_db = array();
|
||||
|
||||
$events = array();
|
||||
$field_event_name = __('Event Name');
|
||||
$field_status = __('Status');
|
||||
$field_timestamp = __('Timestamp');
|
||||
$field_agent = __('Agent');
|
||||
foreach ($events_db as $event) {
|
||||
$row = array();
|
||||
$row[$field_event_name] = $event['evento'];
|
||||
switch ($event['estado']) {
|
||||
case 0:
|
||||
$img_st = "images/star.png";
|
||||
$title_st = __('New event');
|
||||
break;
|
||||
case 1:
|
||||
$img_st = "images/tick.png";
|
||||
$title_st = __('Event validated');
|
||||
break;
|
||||
case 2:
|
||||
$img_st = "images/hourglass.png";
|
||||
$title_st = __('Event in process');
|
||||
break;
|
||||
}
|
||||
$row[$field_status] = html_print_image ($img_st, true,
|
||||
array ("class" => "image_status",
|
||||
"width" => 16,
|
||||
"height" => 16,
|
||||
"title" => $title_st,
|
||||
"id" => 'status_img_' . $event["id_evento"]));
|
||||
$row[$field_timestamp] = ui_print_timestamp ($event['timestamp_rep'], true);
|
||||
$row[$field_agent] = ui_print_agent_name ($event["id_agente"], true);
|
||||
|
||||
|
||||
$events[$event['id_evento']] = $row;
|
||||
}
|
||||
|
||||
$ui = Ui::getInstance();
|
||||
$table = new Table();
|
||||
$table->importFromHash($events);
|
||||
$ui->contentAddHtml($table->getHTML());
|
||||
if (empty($events)) {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('No events') . '</p>');
|
||||
}
|
||||
else {
|
||||
$table = new Table();
|
||||
$table->importFromHash($events);
|
||||
$ui->contentAddHtml($table->getHTML());
|
||||
|
||||
if ($system->getPageSize() < $total_events) {
|
||||
$ui->contentAddHtml('<div id="loading_rows">' .
|
||||
html_print_image('images/spinner.gif', true) .
|
||||
' ' . __('Loading...') .
|
||||
'</div>');
|
||||
|
||||
$this->addJavascriptAddBottom();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function addJavascriptAddBottom() {
|
||||
$ui = Ui::getInstance();
|
||||
|
||||
$ui->contentAddHtml("<script type=\"text/javascript\">
|
||||
var load_more_rows = 1;
|
||||
var page = 1;
|
||||
$(document).ready(function() {
|
||||
$(window).bind(\"scroll\", function () {
|
||||
|
||||
if (load_more_rows) {
|
||||
if ($(this).scrollTop() + $(this).height()
|
||||
>= ($(document).height() - 100)) {
|
||||
|
||||
load_more_rows = 0;
|
||||
|
||||
postvars = {};
|
||||
postvars[\"action\"] = \"ajax\";
|
||||
postvars[\"parameter1\"] = \"events\";
|
||||
postvars[\"parameter2\"] = \"get_events\";
|
||||
postvars[\"filter\"] = $(\"select[name='filter']\").val();
|
||||
postvars[\"group\"] = $(\"select[name='group']\").val();
|
||||
postvars[\"status\"] = $(\"select[name='status']\").val();
|
||||
postvars[\"type\"] = $(\"select[name='type']\").val();
|
||||
postvars[\"severity\"] = $(\"select[name='severity']\").val();
|
||||
postvars[\"free_search\"] = $(\"input[name='free_search']\").val();
|
||||
postvars[\"hours_old\"] = $(\"input[name='hours_old']\").val();
|
||||
postvars[\"page\"] = page;
|
||||
page++;
|
||||
|
||||
$.post(\"index.php\",
|
||||
postvars,
|
||||
function (data) {
|
||||
if (data.end) {
|
||||
$(\"#loading_rows\").hide();
|
||||
}
|
||||
else {
|
||||
$.each(data.events, function(key, event) {
|
||||
$(\"table tbody\").append(\"<tr>\" +
|
||||
\"<th></th>\" +
|
||||
\"<td>\" + event[0] + \"</td>\" +
|
||||
\"<td>\" + event[1] + \"</td>\" +
|
||||
\"<td>\" + event[2] + \"</td>\" +
|
||||
\"<td>\" + event[3] + \"</td>\" +
|
||||
\"</tr>\");
|
||||
});
|
||||
|
||||
load_more_rows = 1;
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
\"json\");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>");
|
||||
}
|
||||
|
||||
private function filterEventsGetString() {
|
||||
if ($this->default)
|
||||
if ($this->default) {
|
||||
return __("(Default)");
|
||||
}
|
||||
else {
|
||||
if ($this->filter) {
|
||||
//TODO put the name of filter
|
||||
$filter = db_get_row('tevent_filter', 'id_filter', $this->filter);
|
||||
|
||||
return sprintf(__('Filter: %s'), $filter['id_name']);
|
||||
}
|
||||
else {
|
||||
/*
|
||||
$string = sprintf(__("(Status: %s Hours: %s Type: %s Severity: %s Free Search: %s)"),
|
||||
$this->hours_old,
|
||||
|
||||
$status = "";
|
||||
if (!empty($this->status))
|
||||
$status = events_get_status($this->status);
|
||||
$type = "";
|
||||
if (!empty($this->empty))
|
||||
$type = get_event_types($this->type);
|
||||
$severity = "";
|
||||
if ($this->severity != -1)
|
||||
$severity = get_priorities($this->severity);
|
||||
|
||||
|
||||
$string = sprintf(
|
||||
__("(Status: %s - Hours: %s - Type: %s - Severity: %s - Free Search: %s)"),
|
||||
$status, $this->hours_old, $type, $severity,
|
||||
$this->free_search);
|
||||
|
||||
return $string;
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ $groups = users_get_groups($id_user, 'ER');
|
|||
|
||||
//Group selection
|
||||
if ($ev_group > 0 && in_array ($ev_group, array_keys ($groups))) {
|
||||
|
||||
if($meta) {
|
||||
|
||||
if ($meta) {
|
||||
// In metaconsole the group search is performed by name
|
||||
$group_name = groups_get_name ($ev_group);
|
||||
$sql_post = " AND group_name = '$group_name'";
|
||||
|
@ -73,11 +73,11 @@ if ($event_type != "") {
|
|||
elseif ($event_type != "all") {
|
||||
$sql_post .= " AND event_type = '" . $event_type."'";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ($severity != -1) {
|
||||
switch($severity) {
|
||||
switch ($severity) {
|
||||
case EVENT_CRIT_WARNING_OR_CRITICAL:
|
||||
$sql_post .= " AND (criticity = " . EVENT_CRIT_WARNING . " OR
|
||||
criticity = " . EVENT_CRIT_CRITICAL . ")";
|
||||
|
@ -92,8 +92,8 @@ if ($severity != -1) {
|
|||
}
|
||||
|
||||
// In metaconsole mode the agent search is performed by name
|
||||
if($meta) {
|
||||
if($text_agent != __('All')) {
|
||||
if ($meta) {
|
||||
if ($text_agent != __('All')) {
|
||||
$sql_post .= " AND agent_name LIKE '%$text_agent%'";
|
||||
}
|
||||
}
|
||||
|
@ -137,6 +137,7 @@ if (!empty($tag_without)) {
|
|||
foreach ($tag_without as $id_tag) {
|
||||
if ($first) $first = false;
|
||||
else $sql_post .= " AND ";
|
||||
|
||||
$sql_post .= "tags NOT LIKE '%" . tags_get_name($id_tag) . "%'";
|
||||
}
|
||||
$sql_post .= ' ) ';
|
||||
|
@ -163,15 +164,15 @@ $tags_acls_condition = tags_get_acl_tags($id_user, $group_array, 'ER', 'event_co
|
|||
$sql_post .= $tags_acls_condition;
|
||||
|
||||
// Metaconsole fitlers
|
||||
if($meta) {
|
||||
if ($meta) {
|
||||
$enabled_nodes = db_get_all_rows_sql('SELECT id FROM tmetaconsole_setup WHERE disabled = 0');
|
||||
|
||||
if(empty($enabled_nodes)) {
|
||||
if (empty($enabled_nodes)) {
|
||||
$sql_post .= ' AND 1 = 0';
|
||||
}
|
||||
else {
|
||||
$enabled_nodes_id = array();
|
||||
foreach($enabled_nodes as $en) {
|
||||
foreach ($enabled_nodes as $en) {
|
||||
$enabled_nodes_id[] = $en['id'];
|
||||
}
|
||||
$sql_post .= ' AND server_id IN ('.implode(',',$enabled_nodes_id).')';
|
||||
|
|
|
@ -185,7 +185,7 @@ foreach ($result as $event) {
|
|||
$data[$i] = "#".$event["id_evento"];
|
||||
|
||||
// Pass grouped values in hidden fields to use it from modal window
|
||||
if($group_rep) {
|
||||
if ($group_rep) {
|
||||
$similar_ids = $event['similar_ids'];
|
||||
$timestamp_first = $event['timestamp_rep_min'];
|
||||
$timestamp_last = $event['timestamp_rep'];
|
||||
|
@ -224,7 +224,7 @@ foreach ($result as $event) {
|
|||
$i++;
|
||||
|
||||
if (in_array('server_name',$show_fields)) {
|
||||
if($meta) {
|
||||
if ($meta) {
|
||||
$data[$i] = "<a href='" . $event["server_url"] . "/index.php?sec=estado&sec2=operation/agentes/group_view" . $event['server_url_hash'] . "'>" . $event["server_name"] . "</a>";
|
||||
}
|
||||
else {
|
||||
|
@ -290,7 +290,7 @@ foreach ($result as $event) {
|
|||
|
||||
if ($event["id_agente"] > 0) {
|
||||
// Agent name
|
||||
if($meta) {
|
||||
if ($meta) {
|
||||
$data[$i] = '<b><a href="'.$event["server_url"].'/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $event["id_agente"] . $event["server_url_hash"] . '">';
|
||||
$data[$i] .= $event["agent_name"];
|
||||
$data[$i] .= "</a></b>";
|
||||
|
@ -338,7 +338,7 @@ foreach ($result as $event) {
|
|||
}
|
||||
|
||||
if (in_array('id_grupo',$show_fields)) {
|
||||
if($meta) {
|
||||
if ($meta) {
|
||||
$data[$i] = $event['group_name'];
|
||||
}
|
||||
else {
|
||||
|
@ -358,7 +358,7 @@ foreach ($result as $event) {
|
|||
}
|
||||
|
||||
if (in_array('id_agentmodule',$show_fields)) {
|
||||
if($meta) {
|
||||
if ($meta) {
|
||||
$data[$i] = '<b><a href="'.$event["server_url"].'/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $event["id_agente"] . $event["server_url_hash"] . '">';
|
||||
$data[$i] .= $event["module_name"];
|
||||
$data[$i] .= "</a></b>";
|
||||
|
@ -379,8 +379,8 @@ foreach ($result as $event) {
|
|||
$sql = 'SELECT name
|
||||
FROM talert_templates
|
||||
WHERE id IN (SELECT id_alert_template
|
||||
FROM talert_template_modules
|
||||
WHERE id = ' . $event["id_alert_am"] . ');';
|
||||
FROM talert_template_modules
|
||||
WHERE id = ' . $event["id_alert_am"] . ');';
|
||||
|
||||
$templateName = db_get_sql($sql);
|
||||
$data[$i] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$event["id_agente"].'&tab=alert">'.$templateName.'</a>';
|
||||
|
|
|
@ -154,25 +154,29 @@ echo "<br>";
|
|||
$update_pressed = get_parameter_post('update', '');
|
||||
$update_pressed = (int) !empty($update_pressed);
|
||||
|
||||
if ($update_pressed || $open_filter){
|
||||
if ($update_pressed || $open_filter) {
|
||||
$open_filter = true;
|
||||
}
|
||||
|
||||
//Link to toggle filter
|
||||
if ($open_filter) {
|
||||
echo '<a href="#" id="tgl_event_control"><b>'.__('Event control filter').'</b> '.html_print_image ("images/go.png", true, array ("title" => __('Toggle filter(s)'), "id" => 'toggle_arrow')).'</a><br><br>';
|
||||
echo '<a href="#" id="tgl_event_control"><b>' . __('Event control filter') . '</b> '.html_print_image ("images/go.png", true, array ("title" => __('Toggle filter(s)'), "id" => 'toggle_arrow')).'</a><br><br>';
|
||||
}
|
||||
else {
|
||||
echo '<a href="#" id="tgl_event_control"><b>'.__('Event control filter').'</b> '.html_print_image ("images/down.png", true, array ("title" => __('Toggle filter(s)'), "id" => 'toggle_arrow')).'</a><br><br>';
|
||||
echo '<a href="#" id="tgl_event_control"><b>' . __('Event control filter') . '</b> '.html_print_image ("images/down.png", true, array ("title" => __('Toggle filter(s)'), "id" => 'toggle_arrow')).'</a><br><br>';
|
||||
}
|
||||
|
||||
$filters = events_get_event_filter_select();
|
||||
|
||||
// Some translated words to be used from javascript
|
||||
html_print_div(array('hidden' => true, 'id' => 'not_filter_loaded_text', 'content' => __('No filter loaded')));
|
||||
html_print_div(array('hidden' => true, 'id' => 'filter_loaded_text', 'content' => __('Filter loaded')));
|
||||
html_print_div(array('hidden' => true, 'id' => 'save_filter_text', 'content' => __('Save filter')));
|
||||
html_print_div(array('hidden' => true, 'id' => 'load_filter_text', 'content' => __('Load filter')));
|
||||
html_print_div(array('hidden' => true,
|
||||
'id' => 'not_filter_loaded_text', 'content' => __('No filter loaded')));
|
||||
html_print_div(array('hidden' => true,
|
||||
'id' => 'filter_loaded_text', 'content' => __('Filter loaded')));
|
||||
html_print_div(array('hidden' => true,
|
||||
'id' => 'save_filter_text', 'content' => __('Save filter')));
|
||||
html_print_div(array('hidden' => true,
|
||||
'id' => 'load_filter_text', 'content' => __('Load filter')));
|
||||
|
||||
// Save filter div for dialog
|
||||
echo '<div id="save_filter_layer" style="display: none">';
|
||||
|
@ -320,7 +324,7 @@ html_print_input_hidden('id_name', $id_name);
|
|||
|
||||
// Hidden open filter flag
|
||||
// If autoupdate is in use collapse filter
|
||||
if ($open_filter){
|
||||
if ($open_filter) {
|
||||
html_print_input_hidden('open_filter', 'true');
|
||||
}
|
||||
else{
|
||||
|
@ -337,7 +341,8 @@ $table->data = array();
|
|||
|
||||
$data = array();
|
||||
$data[0] = __('Group') . '<br>';
|
||||
$data[0] .= html_print_select_groups($config["id_user"], "ER", true, 'id_group', $id_group, '', '', 0, true, false, false, 'w130');
|
||||
$data[0] .= html_print_select_groups($config["id_user"], "ER", true,
|
||||
'id_group', $id_group, '', '', 0, true, false, false, 'w130');
|
||||
$data[1] = __('Event type') . '<br>';
|
||||
$types = get_event_types ();
|
||||
// Expand standard array to add not_normal (not exist in the array, used only for searches)
|
||||
|
@ -386,7 +391,8 @@ else {
|
|||
$data[1] .= ui_print_agent_autocomplete_input($params);
|
||||
$data[2] = __('User ack.') . '<br>';
|
||||
$users = users_get_info ();
|
||||
$data[2] .= html_print_select ($users, "id_user_ack", $id_user_ack, '', __('Any'), 0, true);
|
||||
$data[2] .= html_print_select($users, "id_user_ack", $id_user_ack, '',
|
||||
__('Any'), 0, true);
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
|
||||
|
@ -444,13 +450,13 @@ if ($group_rep == 0) {
|
|||
case "mysql":
|
||||
$sql = "SELECT *, 1 event_rep
|
||||
FROM $event_table
|
||||
WHERE 1=1 ".$sql_post."
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination;
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = "SELECT *, 1 event_rep
|
||||
FROM $event_table
|
||||
WHERE 1=1 ".$sql_post."
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
ORDER BY utimestamp DESC LIMIT ".$pagination." OFFSET ".$offset;
|
||||
break;
|
||||
case "oracle":
|
||||
|
@ -459,7 +465,7 @@ if ($group_rep == 0) {
|
|||
$set['offset'] = $offset;
|
||||
$sql = "SELECT *, 1 event_rep
|
||||
FROM $event_table
|
||||
WHERE 1=1 ".$sql_post."
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
ORDER BY utimestamp DESC";
|
||||
$sql = oracle_recode_query ($sql, $set);
|
||||
break;
|
||||
|
@ -472,7 +478,7 @@ else {
|
|||
$result = events_get_events_grouped($sql_post, $offset, $pagination, $meta, $history);
|
||||
}
|
||||
|
||||
if(!empty($result)) {
|
||||
if (!empty($result)) {
|
||||
$params = array();
|
||||
$params['position'] = 'right';
|
||||
$params['icon_closed'] = 'images/setup.png';
|
||||
|
@ -485,7 +491,7 @@ if(!empty($result)) {
|
|||
$params['autotop'] = 'menu_tab_frame_view';
|
||||
$params['icon_width'] = 16;
|
||||
$params['icon_height'] = 16;
|
||||
|
||||
|
||||
html_print_side_layer($params);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue