2012-10-09 Sergio Martin <sergio.martin@artica.es>
* include/functions_events.php include/styles/jquery-ui-1.8.23.custom.css include/javascript/pandora_events.js include/ajax/events.php operation/events/events_list.php operation/events/events.php extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql godmode/menu.php godmode/events/event_responses.list.php godmode/events/custom_events.php godmode/events/event_responses.php godmode/events/events.php godmode/events/event_responses.editor.php: Added several changes on events system as responses editor and performer, and several fixes git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7058 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
c6b977c0a5
commit
d0c85e24b2
|
@ -1,3 +1,21 @@
|
|||
2012-10-09 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_events.php
|
||||
include/styles/jquery-ui-1.8.23.custom.css
|
||||
include/javascript/pandora_events.js
|
||||
include/ajax/events.php
|
||||
operation/events/events_list.php
|
||||
operation/events/events.php
|
||||
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql
|
||||
godmode/menu.php
|
||||
godmode/events/event_responses.list.php
|
||||
godmode/events/custom_events.php
|
||||
godmode/events/event_responses.php
|
||||
godmode/events/events.php
|
||||
godmode/events/event_responses.editor.php: Added several changes on
|
||||
events system as responses editor and performer, and several
|
||||
fixes
|
||||
|
||||
2012-10-09 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
|
||||
|
|
|
@ -316,3 +316,20 @@ ALTER TABLE tnetwork_map ADD `pandoras_children` TINYINT(1) UNSIGNED NOT NULL DE
|
|||
-- Table `tagente_estado`
|
||||
-- ----------------------------------------------------------------------
|
||||
ALTER TABLE `tagente_estado` ADD COLUMN `last_known_status` tinyint(4) NOT NULL DEFAULT 0;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tevent_response`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tevent_response` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(600) NOT NULL default '',
|
||||
`description` TEXT NOT NULL,
|
||||
`target` TEXT NOT NULL,
|
||||
`type` varchar(60) NOT NULL,
|
||||
`id_group` MEDIUMINT(4) NOT NULL default 0,
|
||||
`modal_width` INTEGER NOT NULL DEFAULT 0,
|
||||
`modal_height` INTEGER NOT NULL DEFAULT 0,
|
||||
`new_window` TINYINT(4) NOT NULL DEFAULT 0,
|
||||
`params` TEXT NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
|
@ -106,6 +106,12 @@ if ($fields_selected[0]!='') {
|
|||
case 'id_extra':
|
||||
$result = __('Extra id');
|
||||
break;
|
||||
case 'owner_user':
|
||||
$result = __('Owner');
|
||||
break;
|
||||
case 'ack_utimestamp':
|
||||
$result = __('ACK Timestamp');
|
||||
break;
|
||||
}
|
||||
$result_selected[$field_selected] = $result;
|
||||
}
|
||||
|
@ -121,9 +127,12 @@ echo '</a></h3>';
|
|||
$table->width = '90%';
|
||||
|
||||
$table->size = array();
|
||||
$table->size[0] = '20%';
|
||||
$table->size[2] = '10px';
|
||||
$table->size[3] = '20%';
|
||||
//~ $table->size[0] = '20%';
|
||||
$table->size[1] = '10px';
|
||||
//~ $table->size[2] = '20%';
|
||||
|
||||
$table->style[0] = 'text-align:center;';
|
||||
$table->style[2] = 'text-align:center;';
|
||||
|
||||
$table->data = array();
|
||||
|
||||
|
@ -144,6 +153,8 @@ $fields_available['user_comment'] = __('Comment');
|
|||
$fields_available['tags'] = __('Tags');
|
||||
$fields_available['source'] = __('Source');
|
||||
$fields_available['id_extra'] = __('Extra id');
|
||||
$fields_available['owner_user'] = __('Owner');
|
||||
$fields_available['ack_utimestamp'] = __('ACK Timestamp');
|
||||
|
||||
//remove fields already selected
|
||||
foreach ($fields_available as $key=>$available) {
|
||||
|
@ -154,13 +165,14 @@ foreach ($fields_available as $key=>$available) {
|
|||
}
|
||||
}
|
||||
|
||||
$table->data[1][0] = '<b>' . __('Fields available').'</b>';
|
||||
$table->data[1][1] = html_print_select ($fields_available, 'fields_available[]', true, '', '', '', true, true, false, '', false, 'width: 200px');
|
||||
$table->data[1][2] = html_print_image('images/darrowright.png', true, array('id' => 'right', 'title' => __('Add fields to select'))); //html_print_input_image ('add', 'images/darrowright.png', 1, '', true, array ('title' => __('Add tags to module')));
|
||||
$table->data[1][2] .= '<br><br><br><br>' . html_print_image('images/darrowleft.png', true, array('id' => 'left', 'title' => __('Delete fields to select'))); //html_print_input_image ('add', 'images/darrowleft.png', 1, '', true, array ('title' => __('Delete tags to module')));
|
||||
$table->data[0][0] = '<b>' . __('Fields available').'</b>';
|
||||
$table->data[1][0] = html_print_select ($fields_available, 'fields_available[]', true, '', '', '', true, true, false, '', false, 'width: 200px');
|
||||
$table->data[1][1] = '<a href="javascript:">'.html_print_image('images/darrowright.png', true, array('id' => 'right', 'title' => __('Add fields to select'))).'</a>';
|
||||
$table->data[1][1] .= '<br><br><br><br><a href="javascript:">'. html_print_image('images/darrowleft.png', true, array('id' => 'left', 'title' => __('Delete fields to select'))).'</a>';
|
||||
|
||||
$table->data[1][3] = '<b>' . __('Fields selected') . '</b>';
|
||||
$table->data[1][4] = html_print_select($result_selected, 'fields_selected[]', true, '', '', '', true, true, false, '', false, 'width: 200px');
|
||||
$table->data[0][1] = '';
|
||||
$table->data[0][2] = '<b>' . __('Fields selected') . '</b>';
|
||||
$table->data[1][2] = html_print_select($result_selected, 'fields_selected[]', true, '', '', '', true, true, false, '', false, 'width: 200px');
|
||||
|
||||
echo '<form id="custom_events" method="post" action="index.php?sec=geventos&sec2=godmode/events/events§ion=fields">';
|
||||
html_print_table($table);
|
||||
|
@ -191,7 +203,7 @@ $(document).ready (function () {
|
|||
field_name = $(value).html();
|
||||
if (field_name != <?php echo "'".__('None')."'"; ?>){
|
||||
id_field = $(value).attr('value');
|
||||
$("select[name='fields_available[]']").append($("<option></option>").val(field_name).html('<i>' + id_field + '</i>'));
|
||||
$("select[name='fields_available[]']").append($("<option></option>").val(id_field).html('<i>' + field_name + '</i>'));
|
||||
$("#fields_selected").find("option[value='" + id_field + "']").remove();
|
||||
}
|
||||
});
|
||||
|
@ -203,4 +215,4 @@ $(document).ready (function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, "PM")) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access Group Management");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$event_response_id = get_parameter('id_response',0);
|
||||
|
||||
if($event_response_id > 0) {
|
||||
$event_response = db_get_row('tevent_response','id',$event_response_id);
|
||||
}
|
||||
else {
|
||||
$event_response = array();
|
||||
$event_response['name'] = '';
|
||||
$event_response['description'] = '';
|
||||
$event_response['id_group'] = 0;
|
||||
$event_response['type'] = '';
|
||||
$event_response['target'] = '';
|
||||
$event_response['id'] = 0;
|
||||
}
|
||||
|
||||
$table->width = '90%';
|
||||
|
||||
$table->size = array();
|
||||
|
||||
$table->style[0] = 'font-weight: bold;';
|
||||
$table->style[2] = 'font-weight: bold;';
|
||||
|
||||
$table->data = array();
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Name');
|
||||
$data[1] = html_print_input_text('name',$event_response['name'],'',100,255,true);
|
||||
$data[1] .= html_print_input_hidden('id_response',$event_response['id'],true);
|
||||
|
||||
$data[2] = __('Group');
|
||||
$data[3] = html_print_select_groups(false, 'AR', true, 'id_group',$event_response['id_group'],'','','',true);
|
||||
$table->data[0] = $data;
|
||||
|
||||
$data = array();
|
||||
$table->colspan[1][1] = 3;
|
||||
$data[0] = __('Description');
|
||||
$data[1] = html_print_textarea('description',5,40,$event_response['description'],'',true);
|
||||
$table->data[1] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Location');
|
||||
$locations = array(__('Modal window'), __('New window'));
|
||||
$data[1] = html_print_select($locations,'new_window',$event_response['new_window'],'','','',true);
|
||||
|
||||
$data[2] = '<span class="size">'.__('Size').'</span>';
|
||||
if($event_response['modal_width'] == 0) {
|
||||
$event_response['modal_width'] = 620;
|
||||
}
|
||||
if($event_response['modal_height'] == 0) {
|
||||
$event_response['modal_height'] = 500;
|
||||
}
|
||||
$data[3] = '<span class="size">'.__('Width').' (px) </span>';
|
||||
$data[3] .= '<span class="size">'.html_print_input_text('modal_width',$event_response['modal_width'],'',4,5,true).'</span>';
|
||||
$data[3] .= '<span class="size">'.__('Height').' (px) </span>';
|
||||
$data[3] .= '<span class="size">'.html_print_input_text('modal_height',$event_response['modal_height'],'',4,5,true).'</span>';
|
||||
$table->data[2] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Parameters').ui_print_help_icon ("response_parameters", true);
|
||||
$data[1] = html_print_input_text('params',$event_response['params'],'',100,255,true);
|
||||
$types = array('url' => __('URL'), 'command' => __('Command'));
|
||||
$data[2] = __('Type');
|
||||
$data[3] = html_print_select($types,'type',$event_response['type'],'','','',true);
|
||||
$table->data[3] = $data;
|
||||
|
||||
$data = array();
|
||||
$table->colspan[4][1] = 3;
|
||||
$data[0] = '<span id="command_label" class="labels">'.__('Command').'</span><span id="url_label" style="display:none;" class="labels">'.__('URL').'</span>';
|
||||
$data[1] = html_print_input_text('target',$event_response['target'],'',150,255,true);
|
||||
$types = array('url' => __('URL'), 'command' => __('Command'));
|
||||
$table->data[4] = $data;
|
||||
|
||||
$data = array();
|
||||
$table->colspan[5][0] = 4;
|
||||
|
||||
$macros = events_get_macros();
|
||||
|
||||
$macros_info = "<div style='margin-left:20px'>";
|
||||
foreach($macros as $k=>$v) {
|
||||
$macros_info .= "<b>$v:</b> $k<br>";
|
||||
}
|
||||
$macros_info .= "</div>";
|
||||
|
||||
$data[0] = ui_print_info_message(array('title'=>__('Available macros'), 'message' => '<br>'.$macros_info), '', true);
|
||||
$table->data[5] = $data;
|
||||
|
||||
echo '<br>';
|
||||
|
||||
if($event_response_id == 0) {
|
||||
echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/events§ion=responses&mode=list&action=create_response">';
|
||||
html_print_table($table);
|
||||
echo '<br><br><div style="width:90%;text-align:right;">';
|
||||
html_print_submit_button(__('Create'), 'create_response_button', false, array('class' => 'sub next'));
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
else {
|
||||
echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/events§ion=responses&mode=list&action=update_response">';
|
||||
html_print_table($table);
|
||||
echo '<br><br><div style="width:90%;text-align:right;">';
|
||||
html_print_submit_button(__('Update'), 'update_response_button', false, array('class' => 'sub next'));
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
?>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
$('#type').change(function() {
|
||||
$('.labels').hide();
|
||||
$('#'+$(this).val()+'_label').show();
|
||||
|
||||
switch($(this).val()) {
|
||||
case 'command':
|
||||
$('#new_window option[value="0"]').attr('selected','selected');
|
||||
$('#new_window').attr('disabled','disabled');
|
||||
break;
|
||||
case 'url':
|
||||
$('#new_window').removeAttr('disabled');
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$('#new_window').change(function() {
|
||||
switch($(this).val()) {
|
||||
case '0':
|
||||
$('.size').css('visibility','visible');
|
||||
break;
|
||||
case '1':
|
||||
$('.size').css('visibility','hidden');
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function update_form() {
|
||||
$('#type').trigger('change');
|
||||
$('#new_window').trigger('change');
|
||||
}
|
||||
|
||||
update_form();
|
||||
</script>
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, "PM")) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access Group Management");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<br><br><div style="width:90%;text-align:right;">';
|
||||
echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/events§ion=responses&mode=editor">';
|
||||
html_print_submit_button(__('Create response'), 'create_response_button', false, array('class' => 'sub next'));
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
$event_responses = db_get_all_rows_in_table('tevent_response');
|
||||
|
||||
if(empty($event_responses)) {
|
||||
ui_print_info_message(__('No responses found'));
|
||||
$event_responses = array();
|
||||
return;
|
||||
}
|
||||
|
||||
$table->width = '90%';
|
||||
|
||||
$table->size = array();
|
||||
$table->size[0] = '200px';
|
||||
$table->size[2] = '70px';
|
||||
$table->size[3] = '70px';
|
||||
|
||||
$table->style[2] = 'text-align:center;';
|
||||
$table->style[2] = 'text-align:center;';
|
||||
|
||||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('Description');
|
||||
$table->head[2] = __('Group');
|
||||
$table->head[3] = __('Actions');
|
||||
|
||||
$table->data = array();
|
||||
|
||||
foreach($event_responses as $response) {
|
||||
$data = array();
|
||||
$data[0] = '<a href="index.php?sec=geventos&sec2=godmode/events/events§ion=responses&mode=editor&id_response='.$response['id'].'">'.$response['name'].'</a>';
|
||||
$data[1] = $response['description'];
|
||||
$data[2] = ui_print_group_icon ($response['id_group'], true);
|
||||
$data[3] = '<a href="index.php?sec=geventos&sec2=godmode/events/events§ion=responses&action=delete_response&id_response='.$response['id'].'">'.html_print_image('images/cross.png', true, array('title'=>__('Delete'))).'</a>';
|
||||
$data[3] .= ' <a href="index.php?sec=geventos&sec2=godmode/events/events§ion=responses&mode=editor&id_response='.$response['id'].'">'.html_print_image('images/pencil.png', true, array('title'=>__('Edit'))).'</a>';
|
||||
$table->data[] = $data;
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
?>
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, "PM")) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access Group Management");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$mode = get_parameter('mode','list');
|
||||
$action = get_parameter('action');
|
||||
|
||||
switch($action) {
|
||||
case 'create_response':
|
||||
$values = array();
|
||||
$values['name'] = get_parameter('name');
|
||||
$values['description'] = get_parameter('description');
|
||||
$values['target'] = get_parameter('target');
|
||||
$values['type'] = get_parameter('type');
|
||||
$values['id_group'] = get_parameter('id_group',0);
|
||||
$values['modal_width'] = get_parameter('modal_width');
|
||||
$values['modal_height'] = get_parameter('modal_height');
|
||||
$values['new_window'] = get_parameter('new_window');
|
||||
$values['params'] = get_parameter('params');
|
||||
|
||||
if($values['new_window'] == 1) {
|
||||
$values['modal_width'] = 0;
|
||||
$values['modal_height'] = 0;
|
||||
}
|
||||
|
||||
$result = db_process_sql_insert('tevent_response', $values);
|
||||
|
||||
if($result) {
|
||||
ui_print_success_message(__('Response added succesfully'));
|
||||
}
|
||||
else {
|
||||
ui_print_error_message(__('Response cannot be added'));
|
||||
}
|
||||
|
||||
break;
|
||||
case 'update_response':
|
||||
$values = array();
|
||||
$values['name'] = get_parameter('name');
|
||||
$values['description'] = get_parameter('description');
|
||||
$values['target'] = get_parameter('target');
|
||||
$values['type'] = get_parameter('type');
|
||||
$values['id_group'] = get_parameter('id_group',0);
|
||||
$values['modal_width'] = get_parameter('modal_width');
|
||||
$values['modal_height'] = get_parameter('modal_height');
|
||||
$values['new_window'] = get_parameter('new_window');
|
||||
$values['params'] = get_parameter('params');
|
||||
|
||||
if($values['new_window'] == 1) {
|
||||
$values['modal_width'] = 0;
|
||||
$values['modal_height'] = 0;
|
||||
}
|
||||
|
||||
$response_id = get_parameter('id_response',0);
|
||||
|
||||
$result = db_process_sql_update('tevent_response', $values, array('id' => $response_id));
|
||||
|
||||
if($result) {
|
||||
ui_print_success_message(__('Response updated succesfully'));
|
||||
}
|
||||
else {
|
||||
ui_print_error_message(__('Response cannot be updated'));
|
||||
}
|
||||
break;
|
||||
case 'delete_response':
|
||||
$response_id = get_parameter('id_response',0);
|
||||
|
||||
$result = db_process_sql_delete('tevent_response', array('id' => $response_id));
|
||||
|
||||
if($result) {
|
||||
ui_print_success_message(__('Response deleted succesfully'));
|
||||
}
|
||||
else {
|
||||
ui_print_error_message(__('Response cannot be deleted'));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch($mode) {
|
||||
case 'list':
|
||||
require('event_responses.list.php');
|
||||
break;
|
||||
case 'editor':
|
||||
require('event_responses.editor.php');
|
||||
break;
|
||||
}
|
||||
?>
|
|
@ -37,6 +37,9 @@ $buttons = array(
|
|||
'filter' => array('active' => false,
|
||||
'text' => '<a href="index.php?sec=geventos&sec2=godmode/events/events&section=filter">' .
|
||||
html_print_image("images/lightning_go.png", true, array ("title" => __('Create filter'))) . '</a>'),
|
||||
'responses' => array('active' => false,
|
||||
'text' => '<a href="index.php?sec=geventos&sec2=godmode/events/events&section=responses">' .
|
||||
html_print_image("images/cog.png", true, array ("title" => __('Event responses'))) . '</a>'),
|
||||
'fields' => array('active' => false,
|
||||
'text' => '<a href="index.php?sec=geventos&sec2=godmode/events/events&section=fields">' .
|
||||
html_print_image("images/god6.png", true, array ("title" => __('Custom fields'))) . '</a>'),
|
||||
|
@ -51,6 +54,10 @@ switch ($section) {
|
|||
$buttons['fields']['active'] = true;
|
||||
$subpage = ' - ' . __('Custom fields');
|
||||
break;
|
||||
case 'responses':
|
||||
$buttons['responses']['active'] = true;
|
||||
$subpage = ' - ' . __('Responses');
|
||||
break;
|
||||
case 'view':
|
||||
$buttons['view']['active'] = true;
|
||||
break;
|
||||
|
@ -70,6 +77,9 @@ switch($section) {
|
|||
case 'fields':
|
||||
require_once('godmode/events/custom_events.php');
|
||||
break;
|
||||
case 'responses':
|
||||
require_once('godmode/events/event_responses.php');
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -150,6 +150,7 @@ if (check_acl ($config['id_user'], 0, "IW")) {
|
|||
// Custom event fields
|
||||
$sub = array ();
|
||||
$sub["godmode/events/events&section=fields"]["text"] = __('Custom events');
|
||||
$sub["godmode/events/events&section=responses"]["text"] = __('Event responses');
|
||||
|
||||
$menu_godmode["geventos"]["sub"] = $sub;
|
||||
}
|
||||
|
@ -298,4 +299,4 @@ if (check_acl ($config['id_user'], 0, "PM")) {
|
|||
if(!$config['pure']) {
|
||||
menu_print_menu ($menu_godmode);
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -25,6 +25,113 @@ $get_extended_event = (bool) get_parameter ('get_extended_event');
|
|||
$change_status = (bool) get_parameter ('change_status');
|
||||
$change_owner = (bool) get_parameter ('change_owner');
|
||||
$add_comment = (bool) get_parameter ('add_comment');
|
||||
$dialogue_event_response = (bool) get_parameter ('dialogue_event_response');
|
||||
$perform_event_response = (bool) get_parameter ('perform_event_response');
|
||||
$get_response = (bool) get_parameter ('get_response');
|
||||
$get_response_target = (bool) get_parameter ('get_response_target');
|
||||
$get_response_params = (bool) get_parameter ('get_response_params');
|
||||
$get_response_description = (bool) get_parameter ('get_response_description');
|
||||
|
||||
if($get_response_description) {
|
||||
$response_id = get_parameter ('response_id');
|
||||
|
||||
$description = db_get_value('description','tevent_response','id',$response_id);
|
||||
|
||||
if($description === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$description = io_safe_output($description);
|
||||
$description = str_replace("\r\n", '<br>', $description);
|
||||
|
||||
echo $description;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if($get_response_params) {
|
||||
$response_id = get_parameter ('response_id');
|
||||
|
||||
$params = db_get_value('params','tevent_response','id',$response_id);
|
||||
|
||||
if($params === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo json_encode(explode(',',$params));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if($get_response_target) {
|
||||
$response_id = get_parameter ('response_id');
|
||||
$event_id = get_parameter ('event_id');
|
||||
|
||||
$event_response = db_get_row('tevent_response','id',$response_id);
|
||||
|
||||
if(empty($event_response)) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo events_get_response_target($event_id, $response_id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if($get_response) {
|
||||
$response_id = get_parameter ('response_id');
|
||||
|
||||
$event_response = db_get_row('tevent_response','id',$response_id);
|
||||
|
||||
if(empty($event_response)) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo json_encode($event_response);
|
||||
return;
|
||||
}
|
||||
|
||||
if($perform_event_response) {
|
||||
global $config;
|
||||
|
||||
$command = get_parameter('target','');
|
||||
|
||||
echo system('/usr/bin/timeout 10 '.io_safe_output($command).' 2>&1');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if($dialogue_event_response) {
|
||||
global $config;
|
||||
|
||||
$event_id = get_parameter ('event_id');
|
||||
$response_id = get_parameter ('response_id');
|
||||
$command = get_parameter ('target');
|
||||
|
||||
$event_response = db_get_row('tevent_response','id',$response_id);
|
||||
|
||||
$event = db_get_row('tevento','id_evento',$event_id);
|
||||
|
||||
$prompt = "<br>> ";
|
||||
|
||||
switch($event_response['type']) {
|
||||
case 'command':
|
||||
echo "<div style='text-align:left'>";
|
||||
echo $prompt.sprintf(__('Executing command: %s',$command));
|
||||
echo "</div><br>";
|
||||
|
||||
echo "<div id='response_loading_command' style='display:none'>".html_print_image('images/spinner.gif', true)."</div>";
|
||||
echo "<br><div id='response_out' style='text-align:left'></div>";
|
||||
|
||||
echo "<br><div id='re_exec_command' style='display:none;'>";
|
||||
html_print_button(__('Execute again'),'btn_str',false,'perform_response(\''.$command.'\');', "class='sub next'");
|
||||
echo "</div>";
|
||||
break;
|
||||
case 'url':
|
||||
echo "<iframe src='$command' id='divframe' style='width:100%;height:90%;'></iframe>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($add_comment) {
|
||||
$comment = get_parameter ('comment');
|
||||
|
@ -81,24 +188,58 @@ if($get_extended_event) {
|
|||
$dialog_page = get_parameter('dialog_page','general');
|
||||
$event_id = get_parameter('event_id',false);
|
||||
|
||||
$event = events_get_event($event_id);
|
||||
$events = events_get_events_grouped("AND evento = (SELECT evento FROM tevento WHERE id_evento = $event_id)");
|
||||
|
||||
// If the event is not found, we abort
|
||||
if(empty($events)) {
|
||||
echo 'not found';
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
$event = reset($events);
|
||||
}
|
||||
|
||||
// Check ACLs
|
||||
if (is_user_admin ($config["id_user"])) {
|
||||
//Do nothing if you're admin, you get full access
|
||||
}
|
||||
else if($config["id_user"] == $event['owner_user']) {
|
||||
//Do nothing if you're the owner user, you get access
|
||||
}
|
||||
else if($event['id_grupo'] == 0){
|
||||
//If the event has access to all groups, you get access
|
||||
}
|
||||
else {
|
||||
// Get your groups
|
||||
$groups = users_get_groups($config['id_user'], 'IR');
|
||||
|
||||
if(in_array ($event['id_grupo'], array_keys ($groups))) {
|
||||
//If the event group is among the groups of the user, you get access
|
||||
}
|
||||
else {
|
||||
// If all the access types fail, abort
|
||||
echo 'fail';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$group_rep = get_parameter('group_rep',false);
|
||||
|
||||
// Print group_rep in a hidden field to recover it from javascript
|
||||
html_debug_print('group_rep',(int)$group_rep,true);
|
||||
|
||||
html_print_input_hidden('group_rep',(int)$group_rep);
|
||||
|
||||
if($event === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Tabs
|
||||
$tabs = "<ul style='background:#eeeeee;border:0px'>
|
||||
<li><a href='#extended_event_general_page' id='link_general'>".__('General')."</a></li>
|
||||
<li><a href='#extended_event_details_page' id='link_details'>".__('Details')."</a></li>
|
||||
<li><a href='#extended_event_custom_fields_page' id='link_custom_fields'>".__('Agent custom fields')."</a></li>
|
||||
<li><a href='#extended_event_comments_page' id='link_comments'>".__('Comments')."</a></li>
|
||||
<li><a href='#extended_event_actions_page' id='link_actions'>".__('Actions')."</a></li>
|
||||
<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png',true).__('General')."</a></li>
|
||||
<li><a href='#extended_event_details_page' id='link_details'>".html_print_image('images/zoom.png',true).__('Details')."</a></li>
|
||||
<li><a href='#extended_event_custom_fields_page' id='link_custom_fields'>".html_print_image('images/note.png',true).__('Agent fields')."</a></li>
|
||||
<li><a href='#extended_event_comments_page' id='link_comments'>".html_print_image('images/pencil.png',true).__('Comments')."</a></li>
|
||||
<li><a href='#extended_event_responses_page' id='link_responses'>".html_print_image('images/cog.png',true).__('Responses')."</a></li>
|
||||
</ul>";
|
||||
|
||||
// Get criticity image
|
||||
|
@ -128,7 +269,7 @@ if($get_extended_event) {
|
|||
}
|
||||
|
||||
|
||||
$actions = events_page_actions($event);
|
||||
$responses = events_page_responses($event);
|
||||
|
||||
$details = events_page_details($event);
|
||||
|
||||
|
@ -140,20 +281,32 @@ if($get_extended_event) {
|
|||
|
||||
$notifications = '<div id="notification_comment_error" style="display:none">'.ui_print_error_message(__('Error adding comment'),'',true).'</div>';
|
||||
$notifications .= '<div id="notification_comment_success" style="display:none">'.ui_print_success_message(__('Comment added successfully'),'',true).'</div>';
|
||||
$notifications .= '<div id="notification_status_error" style="display:none">'.ui_print_success_message(__('Error changing event status'),'',true).'</div>';
|
||||
$notifications .= '<div id="notification_status_error" style="display:none">'.ui_print_error_message(__('Error changing event status'),'',true).'</div>';
|
||||
$notifications .= '<div id="notification_status_success" style="display:none">'.ui_print_success_message(__('Event status changed successfully'),'',true).'</div>';
|
||||
$notifications .= '<div id="notification_owner_error" style="display:none">'.ui_print_success_message(__('Error changing event owner'),'',true).'</div>';
|
||||
$notifications .= '<div id="notification_owner_error" style="display:none">'.ui_print_error_message(__('Error changing event owner'),'',true).'</div>';
|
||||
$notifications .= '<div id="notification_owner_success" style="display:none">'.ui_print_success_message(__('Event owner changed successfully'),'',true).'</div>';
|
||||
|
||||
$out = '<div id="tabs" style="height:95%; overflow: auto">'.$tabs.$notifications.$general.$details.$custom_fields.$comments.$actions.html_print_input_hidden('id_event',$event['id_evento']).'</div>';
|
||||
$loading = '<div id="response_loading" style="display:none">'.html_print_image('images/spinner.gif',true).'</div>';
|
||||
|
||||
$out = '<div id="tabs" style="height:95%; overflow: auto">'.
|
||||
$tabs.
|
||||
$notifications.
|
||||
$loading.
|
||||
$general.
|
||||
$details.
|
||||
$custom_fields.
|
||||
$comments.
|
||||
$responses.
|
||||
html_print_input_hidden('id_event',$event['id_evento']).
|
||||
'</div>';
|
||||
|
||||
$js = '<script>
|
||||
$(function() {
|
||||
$tabs = $( "#tabs" ).tabs({
|
||||
|
||||
});
|
||||
';
|
||||
|
||||
// Load the required tab
|
||||
switch($dialog_page) {
|
||||
case "general":
|
||||
$js .= '$tabs.tabs("select", 0);';
|
||||
|
@ -167,7 +320,7 @@ if($get_extended_event) {
|
|||
case "comments":
|
||||
$js .= '$tabs.tabs("select", 3);';
|
||||
break;
|
||||
case "actions":
|
||||
case "responses":
|
||||
$js .= '$tabs.tabs("select", 4);';
|
||||
break;
|
||||
}
|
||||
|
@ -216,538 +369,4 @@ if($get_events_details) {
|
|||
|
||||
echo $out;
|
||||
}
|
||||
|
||||
function events_page_actions ($event) {
|
||||
global $config;
|
||||
/////////
|
||||
// Actions
|
||||
/////////
|
||||
|
||||
$table_actions->width = '100%';
|
||||
$table_actions->data = array ();
|
||||
$table_actions->head = array ();
|
||||
$table_actions->style[0] = 'width:35%; font-weight: bold; text-align: left;';
|
||||
$table_actions->style[1] = 'text-align: left;';
|
||||
$table_actions->class = "databox alternate";
|
||||
|
||||
// Owner
|
||||
$data = array();
|
||||
$data[0] = __('Change owner');
|
||||
|
||||
$user_name = db_get_value('fullname', 'tusuario', 'id_user', $config['id_user']);
|
||||
|
||||
$owners = array($config['id_user'] => $user_name);
|
||||
|
||||
if($event['owner_user'] == '') {
|
||||
$owner_name = __('None');
|
||||
}
|
||||
else {
|
||||
$owner_name = db_get_value('fullname', 'tusuario', 'id_user', $event['owner_user']);
|
||||
$owners[$event['owner_user']] = $owner_name;
|
||||
}
|
||||
|
||||
$data[1] = html_print_select($owners, 'id_owner', $event['owner_user'], '', __('None'), -1, true);
|
||||
$data[1] .= html_print_button(__('Update'),'owner_button',false,'event_change_owner();','class="sub next"',true);
|
||||
|
||||
$table_actions->data[] = $data;
|
||||
|
||||
// Status
|
||||
$data = array();
|
||||
$data[0] = __('Change status');
|
||||
|
||||
$status = array(0 => __('New'), 2 => __('In process'), 1 => __('Validated'));
|
||||
|
||||
$data[1] = html_print_select($status, 'estado', $event['estado'], '', '', 0, true);
|
||||
$data[1] .= html_print_button(__('Update'),'status_button',false,'event_change_status();','class="sub next"',true);
|
||||
|
||||
$table_actions->data[] = $data;
|
||||
|
||||
// Comments
|
||||
$data = array();
|
||||
$data[0] = __('Comment');
|
||||
$data[1] = html_print_button(__('Add comment'),'comment_button',false,'$(\'#link_comments\').trigger(\'click\');','class="sub next"',true);
|
||||
|
||||
$table_actions->data[] = $data;
|
||||
|
||||
// Delete
|
||||
$data = array();
|
||||
$data[0] = __('Delete event');
|
||||
$data[1] = '<form method="post" action="index.php?sec=eventos&sec2=operation/events/events§ion=list&delete=1&eventid='.$event['id_evento'].'">';
|
||||
$data[1] .= html_print_button(__('Delete event'),'delete_button',false,'if(!confirm(\''.__('Are you sure?').'\')) { return false; } this.form.submit();','class="sub cancel"',true);
|
||||
$data[1] .= '</form>';
|
||||
|
||||
$table_actions->data[] = $data;
|
||||
|
||||
$actions = '<div id="extended_event_actions_page" class="extended_event_pages">'.html_print_table($table_actions, true).'</div>';
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
function events_page_custom_fields ($event) {
|
||||
global $config;
|
||||
/////////
|
||||
// Custom fields
|
||||
/////////
|
||||
|
||||
$table->width = '100%';
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
$table->style[0] = 'width:35%; font-weight: bold; text-align: left;';
|
||||
$table->style[1] = 'text-align: left;';
|
||||
$table->class = "databox alternate";
|
||||
|
||||
$fields = db_get_all_rows_filter('tagent_custom_fields');
|
||||
|
||||
if($event['id_agente'] == 0) {
|
||||
$fields_data = array();
|
||||
}
|
||||
else {
|
||||
$fields_data = db_get_all_rows_filter('tagent_custom_data', array('id_agent' => $event['id_agente']));
|
||||
if(is_array($fields_data)) {
|
||||
$fields_data_aux = array();
|
||||
foreach($fields_data as $fd) {
|
||||
$fields_data_aux[$fd['id_field']] = $fd['description'];
|
||||
}
|
||||
$fields_data = $fields_data_aux;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($fields as $field) {
|
||||
// Owner
|
||||
$data = array();
|
||||
$data[0] = $field['name'];
|
||||
|
||||
$data[1] = isset($fields_data[$field['id_field']]) ? $fields_data[$field['id_field']] : '<i>'.__('N/A').'</i>';
|
||||
|
||||
$field['id_field'];
|
||||
|
||||
$table->data[] = $data;
|
||||
}
|
||||
|
||||
$custom_fields = '<div id="extended_event_custom_fields_page" class="extended_event_pages">'.html_print_table($table, true).'</div>';
|
||||
|
||||
return $custom_fields;
|
||||
}
|
||||
|
||||
function events_page_details ($event) {
|
||||
global $img_sev;
|
||||
|
||||
/////////
|
||||
// Details
|
||||
/////////
|
||||
|
||||
$table_details->width = '100%';
|
||||
$table_details->data = array ();
|
||||
$table_details->head = array ();
|
||||
$table_details->style[0] = 'width:35%; font-weight: bold; text-align: left;';
|
||||
$table_details->style[1] = 'text-align: left;';
|
||||
$table_details->class = "databox alternate";
|
||||
|
||||
switch($event['event_type']) {
|
||||
case 'going_unknown':
|
||||
case 'going_up_warning':
|
||||
case 'going_down_warning':
|
||||
case 'going_up_critical':
|
||||
case 'going_down_critical':
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ($event["id_agente"] != 0) {
|
||||
$agent = db_get_row('tagente','id_agente',$event["id_agente"]);
|
||||
}
|
||||
else {
|
||||
$agent = array();
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Agent details');
|
||||
$data[1] = empty($agent) ? '<i>' . __('N/A') . '</i>' : '';
|
||||
$table_details->data[] = $data;
|
||||
|
||||
if (!empty($agent)) {
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Name').'</div>';
|
||||
$data[1] = ui_print_agent_name ($event["id_agente"], true);
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('IP Address').'</div>';
|
||||
$data[1] = empty($agent['url_address']) ? '<i>'.__('N/A').'</i>' : $agent['url_address'];
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('OS').'</div>';
|
||||
$data[1] = ui_print_os_icon ($agent["id_os"], true, true).' ('.$agent["os_version"].')';
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Last contact').'</div>';
|
||||
$data[1] = $agent["ultimo_contacto"];
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Last remote contact').'</div>';
|
||||
if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") {
|
||||
$data[1] .= __('Never');
|
||||
}
|
||||
else {
|
||||
$data[1] .= $agent["ultimo_contacto_remoto"];
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Custom fields').'</div>';
|
||||
$data[1] = html_print_button(__('View custom fields'),'custom_button',false,'$(\'#link_custom_fields\').trigger(\'click\');','class="sub next"',true);
|
||||
$table_details->data[] = $data;
|
||||
}
|
||||
|
||||
if ($event["id_agentmodule"] != 0) {
|
||||
$module = db_get_row_filter('tagente_modulo',array('id_agente_modulo' => $event["id_agentmodule"], 'delete_pending' => 0));
|
||||
}
|
||||
else {
|
||||
$module = array();
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Module details');
|
||||
$data[1] = empty($module) ? '<i>' . __('N/A') . '</i>' : '';
|
||||
$table_details->data[] = $data;
|
||||
|
||||
if (!empty($module)) {
|
||||
// Module name
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Name').'</div>';
|
||||
$data[1] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$event["id_agente"].'&tab=data"><b>';
|
||||
$data[1] .= $module['nombre'];
|
||||
$data[1] .= '</b></a>';
|
||||
$table_details->data[] = $data;
|
||||
|
||||
// Module group
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Module group').'</div>';
|
||||
$id_module_group = $module['id_module_group'];
|
||||
if($id_module_group == 0) {
|
||||
$data[1] = __('No assigned');
|
||||
}
|
||||
else {
|
||||
$module_group = db_get_value('name', 'tmodule_group', 'id_mg', $id_module_group);
|
||||
$data[1] = '<a href="index.php?sec=estado&sec2=operation/agentes/status_monitor&status=-1&modulegroup=' . $id_module_group . '">';
|
||||
$data[1] .= $module_group;
|
||||
$data[1] .= '</a>';
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Graph').'</div>';
|
||||
$data[1] = '<a href="javascript:winopeng(\'operation/agentes/stat_win.php?type=sparse&period=86400&id='.$event["id_agentmodule"].'&label=L2Rldi9zZGE2&refresh=600\',\'day_5f80228c\')">';
|
||||
$data[1] .= html_print_image('images/chart_curve.png',true);
|
||||
$data[1] .= '</a>';
|
||||
$table_details->data[] = $data;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Alert details');
|
||||
$data[1] = $event["id_alert_am"] == 0 ? '<i>' . __('N/A') . '</i>' : '';
|
||||
$table_details->data[] = $data;
|
||||
|
||||
if($event["id_alert_am"] != 0) {
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Source').'</div>';
|
||||
$data[1] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$event["id_agente"].'&tab=alert">';
|
||||
$standby = db_get_value('standby', 'talert_template_modules', 'id', $event["id_alert_am"]);
|
||||
if(!$standby) {
|
||||
$data[1] .= html_print_image ("images/bell.png", true,
|
||||
array ("title" => __('Go to data overview')));
|
||||
}
|
||||
else {
|
||||
$data[1] .= html_print_image ("images/bell_pause.png", true,
|
||||
array ("title" => __('Go to data overview')));
|
||||
}
|
||||
|
||||
$sql = 'SELECT name
|
||||
FROM talert_templates
|
||||
WHERE id IN (SELECT id_alert_template
|
||||
FROM talert_template_modules
|
||||
WHERE id = ' . $event["id_alert_am"] . ');';
|
||||
|
||||
$templateName = db_get_sql($sql);
|
||||
|
||||
$data[1] .= $templateName;
|
||||
|
||||
$data[1] .= '</a>';
|
||||
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Priority').'</div>';
|
||||
|
||||
$priority_code = db_get_value('priority', 'talert_template_modules', 'id', $event["id_alert_am"]);
|
||||
$alert_priority = get_priority_name ($priority_code);
|
||||
$data[1] = html_print_image ($img_sev, true,
|
||||
array ("class" => "image_status",
|
||||
"width" => 12,
|
||||
"height" => 12,
|
||||
"title" => $alert_priority));
|
||||
$data[1] .= ' '.$alert_priority;
|
||||
|
||||
$table_details->data[] = $data;
|
||||
}
|
||||
|
||||
switch($event['event_type']) {
|
||||
case 'going_unknown':
|
||||
$data = array();
|
||||
$data[0] = __('Instructions');
|
||||
if ($event["unknown_instructions"] != '') {
|
||||
$data[1] = $event["unknown_instructions"];
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>' . __('N/A') . '</i>';
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
break;
|
||||
case 'going_up_warning':
|
||||
case 'going_down_warning':
|
||||
$data = array();
|
||||
$data[0] = __('Instructions');
|
||||
if ($event["warning_instructions"] != '') {
|
||||
$data[1] = $event["warning_instructions"];
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>' . __('N/A') . '</i>';
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
break;
|
||||
case 'going_up_critical':
|
||||
case 'going_down_critical':
|
||||
$data = array();
|
||||
$data[0] = __('Instructions');
|
||||
if ($event["critical_instructions"] != '') {
|
||||
$data[1] = $event["critical_instructions"];
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>' . __('N/A') . '</i>';
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
break;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Extra id');
|
||||
if ($event["id_extra"] != '') {
|
||||
$data[1] = $event["id_extra"];
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>' . __('N/A') . '</i>';
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Source');
|
||||
if ($event["source"] != '') {
|
||||
$data[1] = $event["source"];
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>' . __('N/A') . '</i>';
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$details = '<div id="extended_event_details_page" class="extended_event_pages">'.html_print_table($table_details, true).'</div>';
|
||||
|
||||
return $details;
|
||||
}
|
||||
|
||||
function events_page_general ($event) {
|
||||
global $img_sev;
|
||||
global $config;
|
||||
global $group_rep;
|
||||
/////////
|
||||
// General
|
||||
/////////
|
||||
|
||||
$table_general->width = '100%';
|
||||
$table_general->data = array ();
|
||||
$table_general->head = array ();
|
||||
$table_general->style[0] = 'width:35%; font-weight: bold; text-align: left;';
|
||||
$table_general->style[1] = 'text-align: left;';
|
||||
$table_general->class = "databox alternate";
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Event ID');
|
||||
$data[1] = "#".$event["id_evento"];
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Event name');
|
||||
$data[1] = io_safe_output(io_safe_output($event["evento"]));
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Timestamp');
|
||||
if ($group_rep == 1 && $event["event_rep"] > 0) {
|
||||
$data[1] = __('First event').': '.date ($config["date_format"], $event['timestamp_rep_min']).'<br>'.__('Last event').': '.date ($config["date_format"], $event['timestamp_rep']);
|
||||
}
|
||||
else {
|
||||
$data[1] = date ($config["date_format"], strtotime($event["timestamp"]));
|
||||
}
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Type');
|
||||
$data[1] = events_print_type_img ($event["event_type"], true).' '.events_print_type_description($event["event_type"], true);
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Repeated');
|
||||
if ($group_rep != 0) {
|
||||
if($event["event_rep"] == 0) {
|
||||
$data[1] = __('No');
|
||||
}
|
||||
else {
|
||||
$data[1] = sprintf("%d Times",$event["event_rep"]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data[1] = __('No');
|
||||
}
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Severity');
|
||||
$event_criticity = get_priority_name ($event["criticity"]);
|
||||
$data[1] = html_print_image ($img_sev, true,
|
||||
array ("class" => "image_status",
|
||||
"width" => 12,
|
||||
"height" => 12,
|
||||
"title" => $event_criticity));
|
||||
$data[1] .= ' '.$event_criticity;
|
||||
$table_general->data[] = $data;
|
||||
|
||||
// Get Status
|
||||
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;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Status');
|
||||
$data[1] = html_print_image($img_st,true).' '.$title_st;
|
||||
$table_general->data[] = $data;
|
||||
|
||||
// If event is validated, show who and when acknowleded it
|
||||
$data = array();
|
||||
$data[0] = __('Acknowledged by');
|
||||
|
||||
if($event['estado'] == 1) {
|
||||
$user_ack = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']);
|
||||
$date_ack = date ($config["date_format"], $event['ack_utimestamp']);
|
||||
$data[1] = $user_ack.' ('.$date_ack.')';
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>'.__('N/A').'</i>';
|
||||
}
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Group');
|
||||
$data[1] = ui_print_group_icon ($event["id_grupo"], true);
|
||||
$data[1] .= groups_get_name ($event["id_grupo"]);
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Tags');
|
||||
|
||||
if ($event["tags"] != '') {
|
||||
$tag_array = explode(',', $event["tags"]);
|
||||
$data[1] = '';
|
||||
foreach ($tag_array as $tag_element){
|
||||
$blank_char_pos = strpos($tag_element, ' ');
|
||||
$tag_name = substr($tag_element, 0, $blank_char_pos);
|
||||
$tag_url = substr($tag_element, $blank_char_pos + 1);
|
||||
$data[1] .= ' ' .$tag_name;
|
||||
if (!empty($tag_url)){
|
||||
$data[1] .= ' <a href="javascript: openURLTagWindow(\'' . $tag_url . '\');">' . html_print_image('images/lupa.png', true, array('title' => __('Click here to open a popup window with URL tag'))) . '</a> ';
|
||||
}
|
||||
$data[1] .= ',';
|
||||
}
|
||||
$data[1] = rtrim($table_general, ',');
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>' . __('N/A') . '</i>';
|
||||
}
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$general = '<div id="extended_event_general_page" class="extended_event_pages">'.html_print_table($table_general,true).'</div>';
|
||||
|
||||
return $general;
|
||||
}
|
||||
|
||||
function events_page_comments ($event) {
|
||||
/////////
|
||||
// Comments
|
||||
/////////
|
||||
|
||||
$table_comments->width = '100%';
|
||||
$table_comments->data = array ();
|
||||
$table_comments->head = array ();
|
||||
$table_comments->style[0] = 'width:35%; vertical-align: top; text-align: left;';
|
||||
$table_comments->style[1] = 'text-align: left;';
|
||||
$table_comments->class = "databox alternate";
|
||||
|
||||
$comments_array = explode('<br>',io_safe_output($event["user_comment"]));
|
||||
|
||||
// Split comments and put in table
|
||||
$col = 0;
|
||||
$data = array();
|
||||
foreach($comments_array as $c) {
|
||||
switch($col) {
|
||||
case 0:
|
||||
$row_text = preg_replace('/\s*--\s*/',"",$c);
|
||||
html_debug_print($row_text,true);
|
||||
$row_text = preg_replace('/\<\/b\>/',"</i>",$row_text);
|
||||
html_debug_print($row_text,true);
|
||||
$row_text = preg_replace('/\[/',"</b><br><br><i>[",$row_text);
|
||||
$row_text = preg_replace('/[\[|\]]/',"",$row_text);
|
||||
break;
|
||||
case 1:
|
||||
$row_text = preg_replace("/\r\n/","<br>",io_safe_output(strip_tags($c)));
|
||||
break;
|
||||
}
|
||||
|
||||
$data[$col] = $row_text;
|
||||
|
||||
$col++;
|
||||
|
||||
if($col == 2) {
|
||||
$col = 0;
|
||||
$table_comments->data[] = $data;
|
||||
$data = array();
|
||||
}
|
||||
}
|
||||
|
||||
if(count($comments_array) == 1 && $comments_array[0] == '') {
|
||||
$table_comments->style[0] = 'text-align:center;';
|
||||
$table_comments->colspan[0][0] = 2;
|
||||
$data = array();
|
||||
$data[0] = __('There are no comments');
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
|
||||
$comments_form = '<br><div id="comments_form" style="width:98%;">'.html_print_textarea("comment", 3, 10, '', 'style="min-height: 15px; width: 100%;"', true);
|
||||
$comments_form .= '<br><div style="text-align:right;">'.html_print_button(__('Add comment'),'comment_button',false,'event_comment();','class="sub next"',true).'</div><br></div>';
|
||||
|
||||
$comments = '<div id="extended_event_comments_page" class="extended_event_pages">'.$comments_form.html_print_table($table_comments, true).'</div>';
|
||||
|
||||
return $comments;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -64,6 +64,59 @@ function events_get_event ($id, $fields = false) {
|
|||
return $event;
|
||||
}
|
||||
|
||||
function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1) {
|
||||
global $config;
|
||||
|
||||
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 '') AS user_comment,
|
||||
MIN(estado) AS min_estado,
|
||||
MAX(estado) AS max_estado,
|
||||
COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep,
|
||||
MIN(utimestamp) AS timestamp_rep_min
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post."
|
||||
GROUP BY evento, id_agentmodule
|
||||
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), '') AS user_comment,
|
||||
MIN(estado) AS min_estado, MAX(estado) AS max_estado, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep,
|
||||
MIN(utimestamp) AS timestamp_rep_min
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post."
|
||||
GROUP BY 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
|
||||
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 tevento WHERE 1=1 ".$sql_post.") a,
|
||||
(SELECT MAX (id_evento) AS id_evento, to_char(evento) AS evento,
|
||||
id_agentmodule, COUNT(*) AS event_rep, MIN(estado) AS min_estado, MAX(estado) AS max_estado,
|
||||
LISTAGG(user_comment, '') AS user_comment, MAX(utimestamp) AS timestamp_rep,
|
||||
MIN(utimestamp) AS timestamp_rep_min
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post."
|
||||
GROUP BY to_char(evento), id_agentmodule) 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the events ids similar to a given event id.
|
||||
*
|
||||
|
@ -94,7 +147,7 @@ function events_get_similar_ids ($id) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete events in a transaction
|
||||
* Delete events in a transresponse
|
||||
*
|
||||
* @param mixed Event ID or array of events
|
||||
* @param bool Whether to delete similar events too.
|
||||
|
@ -146,7 +199,7 @@ function events_delete_event ($id_event, $similar = true) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Validate events in a transaction
|
||||
* Validate events in a transresponse
|
||||
*
|
||||
* @param mixed Event ID or array of events
|
||||
* @param bool Whether to validate similar events or not.
|
||||
|
@ -287,14 +340,14 @@ function events_change_owner_event ($id_event, $similars = true, $new_owner = fa
|
|||
}
|
||||
|
||||
/**
|
||||
* Comment events in a transaction
|
||||
* Comment events in a transresponse
|
||||
*
|
||||
* @param mixed Event ID or array of events
|
||||
* @param bool Whether to validate similar events or not.
|
||||
*
|
||||
* @return bool Whether or not it was successful
|
||||
*/
|
||||
function events_comment_event ($id_event, $similars = true, $comment = '', $action = 'Added comment') {
|
||||
function events_comment_event ($id_event, $similars = true, $comment = '', $response = 'Added comment') {
|
||||
global $config;
|
||||
|
||||
//Cleans up the selection for all unwanted values also casts any single values as an array
|
||||
|
@ -329,7 +382,7 @@ function events_comment_event ($id_event, $similars = true, $comment = '', $acti
|
|||
return false;
|
||||
}
|
||||
|
||||
$comment = '<b>-- '.$action.' by '.$config['id_user'].' '.'['.date ($config["date_format"]).'] --</b><br>'.$commentbox;
|
||||
$comment = '<b>-- '.$response.' by '.$config['id_user'].' '.'['.date ($config["date_format"]).'] --</b><br>'.$commentbox;
|
||||
$fullevent = events_get_event($event);
|
||||
if ($fullevent['user_comment'] != '') {
|
||||
$comment .= '<br>'.$fullevent['user_comment'];
|
||||
|
@ -1028,6 +1081,15 @@ function events_check_event_filter_group ($id_filter) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array with all the possible macros in event responses
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function events_get_macros() {
|
||||
return array('_agent_address_' => __('Agent address'), '_agent_id_' => __('Agent id'), '_event_id_' => __('Event id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a event filter.
|
||||
*
|
||||
|
@ -1077,4 +1139,623 @@ function events_get_event_filter_select(){
|
|||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// Events pages functions to load modal window with advanced view of an event.
|
||||
// Called from include/ajax/events.php
|
||||
|
||||
function events_page_responses ($event) {
|
||||
global $config;
|
||||
/////////
|
||||
// Responses
|
||||
/////////
|
||||
|
||||
$table_responses->id = 'responses_table';
|
||||
$table_responses->width = '100%';
|
||||
$table_responses->data = array ();
|
||||
$table_responses->head = array ();
|
||||
$table_responses->style[0] = 'width:35%; font-weight: bold; text-align: left;';
|
||||
$table_responses->style[1] = 'text-align: left;';
|
||||
$table_responses->class = "databox alternate";
|
||||
|
||||
// Owner
|
||||
$data = array();
|
||||
$data[0] = __('Change owner');
|
||||
|
||||
$users = groups_get_users(array_keys(users_get_groups(false, "AR", false)));
|
||||
|
||||
foreach($users as $u) {
|
||||
$owners[$u['id_user']] = $u['fullname'];
|
||||
}
|
||||
|
||||
if($event['owner_user'] == '') {
|
||||
$owner_name = __('None');
|
||||
}
|
||||
else {
|
||||
$owner_name = db_get_value('fullname', 'tusuario', 'id_user', $event['owner_user']);
|
||||
$owners[$event['owner_user']] = $owner_name;
|
||||
}
|
||||
|
||||
$data[1] = html_print_select($owners, 'id_owner', $event['owner_user'], '', __('None'), -1, true);
|
||||
$data[1] .= html_print_button(__('Update'),'owner_button',false,'event_change_owner();','class="sub next"',true);
|
||||
|
||||
$table_responses->data[] = $data;
|
||||
|
||||
// Status
|
||||
$data = array();
|
||||
$data[0] = __('Change status');
|
||||
|
||||
$status = array(0 => __('New'), 2 => __('In process'), 1 => __('Validated'));
|
||||
|
||||
$data[1] = html_print_select($status, 'estado', $event['estado'], '', '', 0, true, false, false);
|
||||
$data[1] .= html_print_button(__('Update'),'status_button',false,'event_change_status();','class="sub next"',true);
|
||||
|
||||
$table_responses->data[] = $data;
|
||||
|
||||
// Comments
|
||||
$data = array();
|
||||
$data[0] = __('Comment');
|
||||
$data[1] = html_print_button(__('Add comment'),'comment_button',false,'$(\'#link_comments\').trigger(\'click\');','class="sub next"',true);
|
||||
|
||||
$table_responses->data[] = $data;
|
||||
|
||||
// Delete
|
||||
$data = array();
|
||||
$data[0] = __('Delete event');
|
||||
$data[1] = '<form method="post" response="index.php?sec=eventos&sec2=operation/events/events§ion=list&delete=1&eventid='.$event['id_evento'].'">';
|
||||
$data[1] .= html_print_button(__('Delete event'),'delete_button',false,'if(!confirm(\''.__('Are you sure?').'\')) { return false; } this.form.submit();','class="sub cancel"',true);
|
||||
$data[1] .= '</form>';
|
||||
|
||||
$table_responses->data[] = $data;
|
||||
|
||||
// Custom responses
|
||||
$data = array();
|
||||
$data[0] = __('Custom responses');
|
||||
$event_responses = db_get_all_rows_in_table('tevent_response');
|
||||
|
||||
if(empty($event_responses)) {
|
||||
$data[1] .= '<i>'.__('N/A').'</i>';
|
||||
}
|
||||
else {
|
||||
$responses = array();
|
||||
foreach($event_responses as $v) {
|
||||
$responses[$v['id']] = $v['name'];
|
||||
}
|
||||
$data[1] .= html_print_select($responses,'select_custom_response','','','','',true, false, false);
|
||||
$data[1] .= html_print_button(__('Execute'),'custom_response_button',false,'execute_response('.$event['id_evento'].')',"class='sub next'",true);
|
||||
}
|
||||
|
||||
$table_responses->data[] = $data;
|
||||
|
||||
$responses_js = "<script>
|
||||
$('#select_custom_response').change(function() {
|
||||
var id_response = $('#select_custom_response').val();
|
||||
var params = get_response_params(id_response);
|
||||
var description = get_response_description(id_response);
|
||||
$('.params_rows').remove();
|
||||
|
||||
$('#responses_table').append('<tr class=\"params_rows\"><td style=\"text-align:left; padding-left:20px;\">".__('Description')."</td><td style=\"text-align:left;\">'+description+'</td></tr>');
|
||||
|
||||
if(params.length == 1 && params[0] == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#responses_table').append('<tr class=\"params_rows\"><td style=\"text-align:left; padding-left:20px;\" colspan=\"2\">".__('Parameters')."</td></tr>');
|
||||
|
||||
for(i=0;i<params.length;i++) {
|
||||
add_row_param('responses_table',params[i]);
|
||||
}
|
||||
});
|
||||
$('#select_custom_response').trigger('change');
|
||||
</script>";
|
||||
|
||||
$responses = '<div id="extended_event_responses_page" class="extended_event_pages">'.html_print_table($table_responses, true).$responses_js.'</div>';
|
||||
|
||||
return $responses;
|
||||
}
|
||||
|
||||
// Replace macros in the target of a response and return it
|
||||
function events_get_response_target($event_id, $response_id) {
|
||||
$event_response = db_get_row('tevent_response','id',$response_id);
|
||||
|
||||
$event = db_get_row('tevento','id_evento',$event_id);
|
||||
|
||||
$macros = array_keys(events_get_macros());
|
||||
|
||||
$target = io_safe_output($event_response['target']);
|
||||
foreach($macros as $macro) {
|
||||
$subst = '';
|
||||
switch($macro) {
|
||||
case '_agent_address_':
|
||||
$subst = agents_get_address($event['id_agente']);
|
||||
break;
|
||||
case '_agent_id_':
|
||||
$subst = $event['id_agente'];
|
||||
break;
|
||||
case '_event_id_':
|
||||
$subst = $event['id_evento'];
|
||||
break;
|
||||
}
|
||||
|
||||
$target = str_replace($macro,$subst,$target);
|
||||
}
|
||||
|
||||
return $target;
|
||||
}
|
||||
|
||||
function events_page_custom_fields ($event) {
|
||||
global $config;
|
||||
/////////
|
||||
// Custom fields
|
||||
/////////
|
||||
|
||||
$table->width = '100%';
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
$table->style[0] = 'width:35%; font-weight: bold; text-align: left;';
|
||||
$table->style[1] = 'text-align: left;';
|
||||
$table->class = "databox alternate";
|
||||
|
||||
$fields = db_get_all_rows_filter('tagent_custom_fields');
|
||||
|
||||
if($event['id_agente'] == 0) {
|
||||
$fields_data = array();
|
||||
}
|
||||
else {
|
||||
$fields_data = db_get_all_rows_filter('tagent_custom_data', array('id_agent' => $event['id_agente']));
|
||||
if(is_array($fields_data)) {
|
||||
$fields_data_aux = array();
|
||||
foreach($fields_data as $fd) {
|
||||
$fields_data_aux[$fd['id_field']] = $fd['description'];
|
||||
}
|
||||
$fields_data = $fields_data_aux;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($fields as $field) {
|
||||
// Owner
|
||||
$data = array();
|
||||
$data[0] = $field['name'];
|
||||
|
||||
$data[1] = empty($fields_data[$field['id_field']]) ? '<i>'.__('N/A').'</i>' : $fields_data[$field['id_field']];
|
||||
|
||||
$field['id_field'];
|
||||
|
||||
$table->data[] = $data;
|
||||
}
|
||||
|
||||
$custom_fields = '<div id="extended_event_custom_fields_page" class="extended_event_pages">'.html_print_table($table, true).'</div>';
|
||||
|
||||
return $custom_fields;
|
||||
}
|
||||
|
||||
function events_page_details ($event) {
|
||||
global $img_sev;
|
||||
|
||||
/////////
|
||||
// Details
|
||||
/////////
|
||||
|
||||
$table_details->width = '100%';
|
||||
$table_details->data = array ();
|
||||
$table_details->head = array ();
|
||||
$table_details->style[0] = 'width:35%; font-weight: bold; text-align: left;';
|
||||
$table_details->style[1] = 'text-align: left;';
|
||||
$table_details->class = "databox alternate";
|
||||
|
||||
switch($event['event_type']) {
|
||||
case 'going_unknown':
|
||||
case 'going_up_warning':
|
||||
case 'going_down_warning':
|
||||
case 'going_up_critical':
|
||||
case 'going_down_critical':
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ($event["id_agente"] != 0) {
|
||||
$agent = db_get_row('tagente','id_agente',$event["id_agente"]);
|
||||
}
|
||||
else {
|
||||
$agent = array();
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Agent details');
|
||||
$data[1] = empty($agent) ? '<i>' . __('N/A') . '</i>' : '';
|
||||
$table_details->data[] = $data;
|
||||
|
||||
if (!empty($agent)) {
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Name').'</div>';
|
||||
$data[1] = ui_print_agent_name ($event["id_agente"], true);
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('IP Address').'</div>';
|
||||
$data[1] = empty($agent['url_address']) ? '<i>'.__('N/A').'</i>' : $agent['url_address'];
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('OS').'</div>';
|
||||
$data[1] = ui_print_os_icon ($agent["id_os"], true, true).' ('.$agent["os_version"].')';
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Last contact').'</div>';
|
||||
$data[1] = $agent["ultimo_contacto"];
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Last remote contact').'</div>';
|
||||
if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") {
|
||||
$data[1] .= __('Never');
|
||||
}
|
||||
else {
|
||||
$data[1] .= $agent["ultimo_contacto_remoto"];
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Custom fields').'</div>';
|
||||
$data[1] = html_print_button(__('View custom fields'),'custom_button',false,'$(\'#link_custom_fields\').trigger(\'click\');','class="sub next"',true);
|
||||
$table_details->data[] = $data;
|
||||
}
|
||||
|
||||
if ($event["id_agentmodule"] != 0) {
|
||||
$module = db_get_row_filter('tagente_modulo',array('id_agente_modulo' => $event["id_agentmodule"], 'delete_pending' => 0));
|
||||
}
|
||||
else {
|
||||
$module = array();
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Module details');
|
||||
$data[1] = empty($module) ? '<i>' . __('N/A') . '</i>' : '';
|
||||
$table_details->data[] = $data;
|
||||
|
||||
if (!empty($module)) {
|
||||
// Module name
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Name').'</div>';
|
||||
$data[1] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$event["id_agente"].'&tab=data"><b>';
|
||||
$data[1] .= $module['nombre'];
|
||||
$data[1] .= '</b></a>';
|
||||
$table_details->data[] = $data;
|
||||
|
||||
// Module group
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Module group').'</div>';
|
||||
$id_module_group = $module['id_module_group'];
|
||||
if($id_module_group == 0) {
|
||||
$data[1] = __('No assigned');
|
||||
}
|
||||
else {
|
||||
$module_group = db_get_value('name', 'tmodule_group', 'id_mg', $id_module_group);
|
||||
$data[1] = '<a href="index.php?sec=estado&sec2=operation/agentes/status_monitor&status=-1&modulegroup=' . $id_module_group . '">';
|
||||
$data[1] .= $module_group;
|
||||
$data[1] .= '</a>';
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Graph').'</div>';
|
||||
$data[1] = '<a href="javascript:winopeng(\'operation/agentes/stat_win.php?type=sparse&period=86400&id='.$event["id_agentmodule"].'&label=L2Rldi9zZGE2&refresh=600\',\'day_5f80228c\')">';
|
||||
$data[1] .= html_print_image('images/chart_curve.png',true);
|
||||
$data[1] .= '</a>';
|
||||
$table_details->data[] = $data;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Alert details');
|
||||
$data[1] = $event["id_alert_am"] == 0 ? '<i>' . __('N/A') . '</i>' : '';
|
||||
$table_details->data[] = $data;
|
||||
|
||||
if($event["id_alert_am"] != 0) {
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Source').'</div>';
|
||||
$data[1] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$event["id_agente"].'&tab=alert">';
|
||||
$standby = db_get_value('standby', 'talert_template_modules', 'id', $event["id_alert_am"]);
|
||||
if(!$standby) {
|
||||
$data[1] .= html_print_image ("images/bell.png", true,
|
||||
array ("title" => __('Go to data overview')));
|
||||
}
|
||||
else {
|
||||
$data[1] .= html_print_image ("images/bell_pause.png", true,
|
||||
array ("title" => __('Go to data overview')));
|
||||
}
|
||||
|
||||
$sql = 'SELECT name
|
||||
FROM talert_templates
|
||||
WHERE id IN (SELECT id_alert_template
|
||||
FROM talert_template_modules
|
||||
WHERE id = ' . $event["id_alert_am"] . ');';
|
||||
|
||||
$templateName = db_get_sql($sql);
|
||||
|
||||
$data[1] .= $templateName;
|
||||
|
||||
$data[1] .= '</a>';
|
||||
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Priority').'</div>';
|
||||
|
||||
$priority_code = db_get_value('priority', 'talert_template_modules', 'id', $event["id_alert_am"]);
|
||||
$alert_priority = get_priority_name ($priority_code);
|
||||
$data[1] = html_print_image ($img_sev, true,
|
||||
array ("class" => "image_status",
|
||||
"width" => 12,
|
||||
"height" => 12,
|
||||
"title" => $alert_priority));
|
||||
$data[1] .= ' '.$alert_priority;
|
||||
|
||||
$table_details->data[] = $data;
|
||||
}
|
||||
|
||||
switch($event['event_type']) {
|
||||
case 'going_unknown':
|
||||
$data = array();
|
||||
$data[0] = __('Instructions');
|
||||
if ($event["unknown_instructions"] != '') {
|
||||
$data[1] = $event["unknown_instructions"];
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>' . __('N/A') . '</i>';
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
break;
|
||||
case 'going_up_warning':
|
||||
case 'going_down_warning':
|
||||
$data = array();
|
||||
$data[0] = __('Instructions');
|
||||
if ($event["warning_instructions"] != '') {
|
||||
$data[1] = $event["warning_instructions"];
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>' . __('N/A') . '</i>';
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
break;
|
||||
case 'going_up_critical':
|
||||
case 'going_down_critical':
|
||||
$data = array();
|
||||
$data[0] = __('Instructions');
|
||||
if ($event["critical_instructions"] != '') {
|
||||
$data[1] = $event["critical_instructions"];
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>' . __('N/A') . '</i>';
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
break;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Extra id');
|
||||
if ($event["id_extra"] != '') {
|
||||
$data[1] = $event["id_extra"];
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>' . __('N/A') . '</i>';
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Source');
|
||||
if ($event["source"] != '') {
|
||||
$data[1] = $event["source"];
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>' . __('N/A') . '</i>';
|
||||
}
|
||||
$table_details->data[] = $data;
|
||||
|
||||
$details = '<div id="extended_event_details_page" class="extended_event_pages">'.html_print_table($table_details, true).'</div>';
|
||||
|
||||
return $details;
|
||||
}
|
||||
|
||||
function events_page_general ($event) {
|
||||
global $img_sev;
|
||||
global $config;
|
||||
global $group_rep;
|
||||
/////////
|
||||
// General
|
||||
/////////
|
||||
|
||||
$table_general->width = '100%';
|
||||
$table_general->data = array ();
|
||||
$table_general->head = array ();
|
||||
$table_general->style[0] = 'width:35%; font-weight: bold; text-align: left;';
|
||||
$table_general->style[1] = 'text-align: left;';
|
||||
$table_general->class = "databox alternate";
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Event ID');
|
||||
$data[1] = "#".$event["id_evento"];
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Event name');
|
||||
$data[1] = io_safe_output(io_safe_output($event["evento"]));
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Timestamp');
|
||||
if ($group_rep == 1 && $event["event_rep"] > 0) {
|
||||
$data[1] = __('First event').': '.date ($config["date_format"], $event['timestamp_rep_min']).'<br>'.__('Last event').': '.date ($config["date_format"], $event['timestamp_rep']);
|
||||
}
|
||||
else {
|
||||
$data[1] = date ($config["date_format"], strtotime($event["timestamp"]));
|
||||
}
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Owner');
|
||||
if(empty($event["owner_user"])) {
|
||||
$data[1] = '<i>'.__('N/A').'</i>';
|
||||
}
|
||||
else {
|
||||
$user_owner = db_get_value('fullname', 'tusuario', 'id_user', $event["owner_user"]);
|
||||
$data[1] = $user_owner;
|
||||
}
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Type');
|
||||
$data[1] = events_print_type_img ($event["event_type"], true).' '.events_print_type_description($event["event_type"], true);
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Repeated');
|
||||
if ($group_rep != 0) {
|
||||
if($event["event_rep"] == 0) {
|
||||
$data[1] = __('No');
|
||||
}
|
||||
else {
|
||||
$data[1] = sprintf("%d Times",$event["event_rep"]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data[1] = __('No');
|
||||
}
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Severity');
|
||||
$event_criticity = get_priority_name ($event["criticity"]);
|
||||
$data[1] = html_print_image ($img_sev, true,
|
||||
array ("class" => "image_status",
|
||||
"width" => 12,
|
||||
"height" => 12,
|
||||
"title" => $event_criticity));
|
||||
$data[1] .= ' '.$event_criticity;
|
||||
$table_general->data[] = $data;
|
||||
|
||||
// Get Status
|
||||
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;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Status');
|
||||
$data[1] = html_print_image($img_st,true).' '.$title_st;
|
||||
$table_general->data[] = $data;
|
||||
|
||||
// If event is validated, show who and when acknowleded it
|
||||
$data = array();
|
||||
$data[0] = __('Acknowledged by');
|
||||
|
||||
if($event['estado'] == 1) {
|
||||
$user_ack = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']);
|
||||
$date_ack = date ($config["date_format"], $event['ack_utimestamp']);
|
||||
$data[1] = $user_ack.' ('.$date_ack.')';
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>'.__('N/A').'</i>';
|
||||
}
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Group');
|
||||
$data[1] = ui_print_group_icon ($event["id_grupo"], true);
|
||||
$data[1] .= groups_get_name ($event["id_grupo"]);
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Tags');
|
||||
|
||||
if ($event["tags"] != '') {
|
||||
$tag_array = explode(',', $event["tags"]);
|
||||
$data[1] = '';
|
||||
foreach ($tag_array as $tag_element){
|
||||
$blank_char_pos = strpos($tag_element, ' ');
|
||||
$tag_name = substr($tag_element, 0, $blank_char_pos);
|
||||
$tag_url = substr($tag_element, $blank_char_pos + 1);
|
||||
$data[1] .= ' ' .$tag_name;
|
||||
if (!empty($tag_url)){
|
||||
$data[1] .= ' <a href="javascript: openURLTagWindow(\'' . $tag_url . '\');">' . html_print_image('images/lupa.png', true, array('title' => __('Click here to open a popup window with URL tag'))) . '</a> ';
|
||||
}
|
||||
$data[1] .= ',';
|
||||
}
|
||||
$data[1] = rtrim($table_general, ',');
|
||||
}
|
||||
else {
|
||||
$data[1] = '<i>' . __('N/A') . '</i>';
|
||||
}
|
||||
$table_general->data[] = $data;
|
||||
|
||||
$general = '<div id="extended_event_general_page" class="extended_event_pages">'.html_print_table($table_general,true).'</div>';
|
||||
|
||||
return $general;
|
||||
}
|
||||
|
||||
function events_page_comments ($event) {
|
||||
/////////
|
||||
// Comments
|
||||
/////////
|
||||
|
||||
$table_comments->width = '100%';
|
||||
$table_comments->data = array ();
|
||||
$table_comments->head = array ();
|
||||
$table_comments->style[0] = 'width:35%; vertical-align: top; text-align: left;';
|
||||
$table_comments->style[1] = 'text-align: left;';
|
||||
$table_comments->class = "databox alternate";
|
||||
|
||||
$comments_array = explode('<br>',io_safe_output($event["user_comment"]));
|
||||
|
||||
// Split comments and put in table
|
||||
$col = 0;
|
||||
$data = array();
|
||||
foreach($comments_array as $c) {
|
||||
switch($col) {
|
||||
case 0:
|
||||
$row_text = preg_replace('/\s*--\s*/',"",$c);
|
||||
$row_text = preg_replace('/\<\/b\>/',"</i>",$row_text);
|
||||
$row_text = preg_replace('/\[/',"</b><br><br><i>[",$row_text);
|
||||
$row_text = preg_replace('/[\[|\]]/',"",$row_text);
|
||||
break;
|
||||
case 1:
|
||||
$row_text = preg_replace("/[\r\n|\r|\n]/","<br>",io_safe_output(strip_tags($c)));
|
||||
break;
|
||||
}
|
||||
|
||||
$data[$col] = $row_text;
|
||||
|
||||
$col++;
|
||||
|
||||
if($col == 2) {
|
||||
$col = 0;
|
||||
$table_comments->data[] = $data;
|
||||
$data = array();
|
||||
}
|
||||
}
|
||||
|
||||
if(count($comments_array) == 1 && $comments_array[0] == '') {
|
||||
$table_comments->style[0] = 'text-align:center;';
|
||||
$table_comments->colspan[0][0] = 2;
|
||||
$data = array();
|
||||
$data[0] = __('There are no comments');
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
|
||||
$comments_form = '<br><div id="comments_form" style="width:98%;">'.html_print_textarea("comment", 3, 10, '', 'style="min-height: 15px; width: 100%;"', true);
|
||||
$comments_form .= '<br><div style="text-align:right;">'.html_print_button(__('Add comment'),'comment_button',false,'event_comment();','class="sub next"',true).'</div><br></div>';
|
||||
|
||||
$comments = '<div id="extended_event_comments_page" class="extended_event_pages">'.$comments_form.html_print_table($table_comments, true).'</div>';
|
||||
|
||||
return $comments;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// Show the modal window of an event
|
||||
function show_event_dialog(event_id, group_rep, dialog_page, result) {
|
||||
if(dialog_page == undefined) {
|
||||
dialog_page = 'general';
|
||||
|
@ -10,7 +11,7 @@ function show_event_dialog(event_id, group_rep, dialog_page, result) {
|
|||
"dialog_page": dialog_page,
|
||||
"event_id": event_id},
|
||||
function (data, status) {
|
||||
$("#alert_messages").hide ()
|
||||
$("#event_details_window").hide ()
|
||||
.empty ()
|
||||
.append (data)
|
||||
.dialog ({
|
||||
|
@ -54,7 +55,216 @@ function show_event_dialog(event_id, group_rep, dialog_page, result) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Check the response type and open it in a modal dialog or new window
|
||||
function execute_response(event_id) {
|
||||
var response_id = $('#select_custom_response option:selected').val();
|
||||
|
||||
var response = get_response(response_id);
|
||||
|
||||
// If cannot get response abort it
|
||||
if(response == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
response['target'] = get_response_target(event_id, response_id);
|
||||
|
||||
switch(response['type']) {
|
||||
case 'command':
|
||||
show_response_dialog(event_id, response_id, response);
|
||||
break;
|
||||
case 'url':
|
||||
if(response['new_window'] == 1) {
|
||||
window.open(response['target'],'_blank');
|
||||
}
|
||||
else {
|
||||
show_response_dialog(event_id, response_id, response);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Show the modal window of an event response
|
||||
function show_response_dialog(event_id, response_id, response) {
|
||||
var params = [];
|
||||
params.push("page=include/ajax/events");
|
||||
params.push("dialogue_event_response=1");
|
||||
params.push("event_id="+event_id);
|
||||
params.push("target="+response['target']);
|
||||
params.push("response_id="+response_id);
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
type: 'POST',
|
||||
url: action="ajax.php",
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: 'html',
|
||||
success: function (data) {
|
||||
$("#event_response_window").hide ()
|
||||
.empty ()
|
||||
.append (data)
|
||||
.dialog ({
|
||||
title: $('#select_custom_response option:selected').html(),
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: false,
|
||||
open: function(event, ui) {
|
||||
perform_response(response['target']);
|
||||
},
|
||||
bgiframe: jQuery.browser.msie,
|
||||
width: response['modal_width'],
|
||||
height: response['modal_height']
|
||||
})
|
||||
.show ();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Get an event response from db
|
||||
function get_response(response_id) {
|
||||
var response = '';
|
||||
|
||||
var params = [];
|
||||
params.push("page=include/ajax/events");
|
||||
params.push("get_response=1");
|
||||
params.push("response_id="+response_id);
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
type: 'POST',
|
||||
url: action="ajax.php",
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
response = data;
|
||||
}
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
// Get an event response params from db
|
||||
function get_response_params(response_id) {
|
||||
var response_params;
|
||||
|
||||
var params = [];
|
||||
params.push("page=include/ajax/events");
|
||||
params.push("get_response_params=1");
|
||||
params.push("response_id="+response_id);
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
type: 'POST',
|
||||
url: action="ajax.php",
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
response_params = data;
|
||||
}
|
||||
});
|
||||
|
||||
return response_params;
|
||||
}
|
||||
|
||||
// Get an event response description from db
|
||||
function get_response_description(response_id) {
|
||||
var response_description = '';
|
||||
|
||||
var params = [];
|
||||
params.push("page=include/ajax/events");
|
||||
params.push("get_response_description=1");
|
||||
params.push("response_id="+response_id);
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
type: 'POST',
|
||||
url: action="ajax.php",
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: 'html',
|
||||
success: function (data) {
|
||||
response_description = data;
|
||||
}
|
||||
});
|
||||
|
||||
return response_description;
|
||||
}
|
||||
|
||||
function add_row_param(id_table, param) {
|
||||
$('#'+id_table).append('<tr class="params_rows"><td style="text-align:left; padding-left:40px;">'+param+'</td><td style="text-align:left"><input type="text" name="'+param+'" id="'+param+'"></td></tr>');
|
||||
}
|
||||
|
||||
// Get an event response from db
|
||||
function get_response_target(event_id, response_id) {
|
||||
var target = '';
|
||||
|
||||
// Replace the main macros
|
||||
var params = [];
|
||||
params.push("page=include/ajax/events");
|
||||
params.push("get_response_target=1");
|
||||
params.push("event_id="+event_id);
|
||||
params.push("response_id="+response_id);
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
type: 'POST',
|
||||
url: action="ajax.php",
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: 'html',
|
||||
success: function (data) {
|
||||
target = data;
|
||||
}
|
||||
});
|
||||
|
||||
// Replace the custom params macros
|
||||
var response_params = get_response_params(response_id);
|
||||
|
||||
if(response_params.length > 1 || response_params[0] != '') {
|
||||
for(i=0;i<response_params.length;i++) {
|
||||
target = target.replace('_'+response_params[i]+'_',$('#'+response_params[i]).val());
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
// Perform a response and put the output into a div
|
||||
function perform_response(target) {
|
||||
$('#re_exec_command').hide();
|
||||
$('#response_loading_command').show();
|
||||
$('#response_out').html('');
|
||||
|
||||
var finished = 0;
|
||||
var time = Math.round(+new Date()/1000);
|
||||
var timeout = time + 10;
|
||||
|
||||
var params = [];
|
||||
params.push("page=include/ajax/events");
|
||||
params.push("perform_event_response=1");
|
||||
params.push("target="+target);
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
type: 'POST',
|
||||
url: action="ajax.php",
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
dataType: 'html',
|
||||
success: function (data) {
|
||||
var out = data.replace(/[\n|\r]/g, "<br>");
|
||||
$('#response_out').html(out);
|
||||
$('#response_loading_command').hide();
|
||||
$('#re_exec_command').show();
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Change the status of an event to new, in process or validated
|
||||
function event_change_status() {
|
||||
var event_id = $('#hidden-id_event').val();
|
||||
var new_status = $('#estado').val();
|
||||
|
@ -66,7 +276,8 @@ function event_change_status() {
|
|||
params.push("new_status="+new_status);
|
||||
|
||||
$('#button-status_button').attr('disabled','disabled');
|
||||
|
||||
$('#response_loading').show();
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
type: 'POST',
|
||||
|
@ -76,7 +287,8 @@ function event_change_status() {
|
|||
dataType: 'html',
|
||||
success: function (data) {
|
||||
$('#button-status_button').removeAttr('disabled');
|
||||
show_event_dialog(event_id, $('#hidden-group_rep').val(), 'actions', data);
|
||||
$('#response_loading').hide();
|
||||
show_event_dialog(event_id, $('#hidden-group_rep').val(), 'responses', data);
|
||||
if(data == 'ok') {
|
||||
}
|
||||
else {
|
||||
|
@ -86,6 +298,7 @@ function event_change_status() {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Change te owner of an event to one user of empty
|
||||
function event_change_owner() {
|
||||
var event_id = $('#hidden-id_event').val();
|
||||
var new_owner = $('#id_owner').val();
|
||||
|
@ -97,7 +310,8 @@ function event_change_owner() {
|
|||
params.push("new_owner="+new_owner);
|
||||
|
||||
$('#button-owner_button').attr('disabled','disabled');
|
||||
|
||||
$('#response_loading').show();
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
type: 'POST',
|
||||
|
@ -107,13 +321,16 @@ function event_change_owner() {
|
|||
dataType: 'html',
|
||||
success: function (data) {
|
||||
$('#button-owner_button').removeAttr('disabled');
|
||||
show_event_dialog(event_id, $('#hidden-group_rep').val(), 'actions', data);
|
||||
$('#response_loading').hide();
|
||||
|
||||
show_event_dialog(event_id, $('#hidden-group_rep').val(), 'responses', data);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save a comment into an event
|
||||
function event_comment() {
|
||||
var event_id = $('#hidden-id_event').val();
|
||||
var comment = $('#textarea_comment').val();
|
||||
|
@ -130,7 +347,8 @@ function event_comment() {
|
|||
params.push("comment="+comment);
|
||||
|
||||
$('#button-comment_button').attr('disabled','disabled');
|
||||
|
||||
$('#response_loading').show();
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
type: 'POST',
|
||||
|
@ -140,6 +358,8 @@ function event_comment() {
|
|||
dataType: 'html',
|
||||
success: function (data) {
|
||||
$('#button-comment_button').removeAttr('disabled');
|
||||
$('#response_loading').show();
|
||||
|
||||
show_event_dialog(event_id, $('#hidden-group_rep').val(), 'comments', data);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
color: #ffffff !important;
|
||||
}
|
||||
.ui-state-hover a, .ui-state-hover a:hover {
|
||||
color: #B1B1B1;
|
||||
color: #DFD;
|
||||
text-decoration: none;
|
||||
}
|
||||
.ui-state-active, .ui-widget-content .ui-state-active,
|
||||
|
@ -98,7 +98,7 @@
|
|||
}
|
||||
.ui-state-active a, .ui-state-active a:link,
|
||||
.ui-state-active a:visited {
|
||||
color: #eb8f00;
|
||||
color: #DFD;
|
||||
text-decoration: none; }
|
||||
.ui-widget :active {
|
||||
outline: none;
|
||||
|
|
|
@ -382,6 +382,9 @@ else {
|
|||
}
|
||||
}
|
||||
|
||||
echo "<div id='event_details_window'></div>";
|
||||
echo "<div id='event_response_window'></div>";
|
||||
|
||||
ui_require_jquery_file ('bgiframe');
|
||||
ui_require_javascript_file('pandora_events');
|
||||
|
||||
|
@ -422,6 +425,7 @@ $(document).ready( function() {
|
|||
$tr = $(this).parents ("tr");
|
||||
|
||||
id = this.id.split ("-").pop ();
|
||||
|
||||
var comment = $('#textarea_comment_'+id).val();
|
||||
var select_validate = $('#select_validate_'+id).val(); // 1 validate, 2 in process, 3 add comment
|
||||
var checkbox_standby_alert = $('#checkbox-standby-alert-'+id).attr('checked');
|
||||
|
@ -642,7 +646,7 @@ $(document).ready( function() {
|
|||
);
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
function toggleDiv (divid){
|
||||
if (document.getElementById(divid).style.display == 'none'){
|
||||
document.getElementById(divid).style.display = 'block';
|
||||
|
@ -678,4 +682,15 @@ $(document).ready( function() {
|
|||
$('.event_form_' + id_event).css('display', '');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
// Autoload event giving the id as POST/GET parameter
|
||||
<?php
|
||||
$load_event = get_parameter('load_event',0);
|
||||
|
||||
if($load_event) {
|
||||
?>
|
||||
show_event_dialog(<?php echo $load_event; ?>, 1);
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</script>
|
||||
|
|
|
@ -449,57 +449,14 @@ if ($group_rep == 0) {
|
|||
$sql = oracle_recode_query ($sql, $set);
|
||||
break;
|
||||
}
|
||||
|
||||
//Extract the events by filter (or not) from db
|
||||
$result = db_get_all_rows_sql ($sql);
|
||||
}
|
||||
else {
|
||||
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 '') AS user_comment,
|
||||
MIN(estado) AS min_estado,
|
||||
MAX(estado) AS max_estado,
|
||||
COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep,
|
||||
MIN(utimestamp) AS timestamp_rep_min
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post."
|
||||
GROUP BY evento, id_agentmodule
|
||||
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), '') AS user_comment,
|
||||
MIN(estado) AS min_estado, MAX(estado) AS max_estado, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep,
|
||||
MIN(utimestamp) AS timestamp_rep_min
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post."
|
||||
GROUP BY 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
|
||||
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 tevento WHERE 1=1 ".$sql_post.") a,
|
||||
(SELECT MAX (id_evento) AS id_evento, to_char(evento) AS evento,
|
||||
id_agentmodule, COUNT(*) AS event_rep, MIN(estado) AS min_estado, MAX(estado) AS max_estado,
|
||||
LISTAGG(user_comment, '') AS user_comment, MAX(utimestamp) AS timestamp_rep,
|
||||
MIN(utimestamp) AS timestamp_rep_min
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post."
|
||||
GROUP BY to_char(evento), id_agentmodule) 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;
|
||||
}
|
||||
|
||||
$result = events_get_events_grouped($sql_post, $offset, $pagination);
|
||||
}
|
||||
|
||||
//Extract the events by filter (or not) from db
|
||||
$result = db_get_all_rows_sql ($sql);
|
||||
|
||||
// Delete rnum field generated by oracle_recode_query() function
|
||||
if (($config['dbtype'] == 'oracle') && ($result !== false)) {
|
||||
for ($i=0; $i < count($result); $i++) {
|
||||
|
@ -534,6 +491,9 @@ $show_fields = explode (',', $config['event_fields']);
|
|||
|
||||
//headers
|
||||
$i = 0;
|
||||
$table->head[$i] = __('ID');
|
||||
$table->align[$i] = 'center';
|
||||
$i++;
|
||||
if (in_array('estado', $show_fields)) {
|
||||
$table->head[$i] = __('Status');
|
||||
$table->align[$i] = 'center';
|
||||
|
@ -564,6 +524,11 @@ if (in_array('id_usuario', $show_fields)) {
|
|||
$table->align[$i] = 'center';
|
||||
$i++;
|
||||
}
|
||||
if (in_array('owner_user', $show_fields)) {
|
||||
$table->head[$i] = __('Owner');
|
||||
$table->align[$i] = 'center';
|
||||
$i++;
|
||||
}
|
||||
if (in_array('id_grupo', $show_fields)) {
|
||||
$table->head[$i] = __('Group');
|
||||
$table->align[$i] = 'center';
|
||||
|
@ -610,6 +575,11 @@ if (in_array('id_extra', $show_fields)) {
|
|||
$table->align[$i] = 'center';
|
||||
$i++;
|
||||
}
|
||||
if (in_array('ack_utimestamp', $show_fields)) {
|
||||
$table->head[$i] = __('ACK Timestamp');
|
||||
$table->align[$i] = 'center';
|
||||
$i++;
|
||||
}
|
||||
if ($i != 0) {
|
||||
$table->head[$i] = __('Action');
|
||||
$table->align[$i] = 'center';
|
||||
|
@ -665,6 +635,9 @@ foreach ($result as $event) {
|
|||
|
||||
$i = 0;
|
||||
|
||||
$data[$i] = "#".$event["id_evento"];
|
||||
$i++;
|
||||
|
||||
if (in_array('estado',$show_fields)) {
|
||||
$data[$i] = html_print_image ($img_st, true,
|
||||
array ("class" => "image_status",
|
||||
|
@ -741,8 +714,14 @@ foreach ($result as $event) {
|
|||
$i++;
|
||||
}
|
||||
|
||||
$user_name = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']);
|
||||
if (in_array('owner_user',$show_fields)) {
|
||||
$owner_name = db_get_value('fullname', 'tusuario', 'id_user', $event['owner_user']);
|
||||
$data[$i] = $owner_name;
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (in_array('id_usuario',$show_fields)) {
|
||||
$user_name = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']);
|
||||
$data[$i] = $user_name;
|
||||
$i++;
|
||||
}
|
||||
|
@ -828,12 +807,22 @@ foreach ($result as $event) {
|
|||
$i++;
|
||||
}
|
||||
|
||||
if (in_array('ack_utimestamp',$show_fields)) {
|
||||
if($event["ack_utimestamp"] == 0){
|
||||
$data[$i] = '';
|
||||
}
|
||||
else {
|
||||
$data[$i] = date ($config["date_format"], $event['ack_utimestamp']);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($i != 0) {
|
||||
//Actions
|
||||
$data[$i] = '';
|
||||
// Validate event
|
||||
if (($event["estado"] != 1) and (check_acl ($config["id_user"], $event["id_grupo"], "IW") == 1)) {
|
||||
$data[$i] .= '<a href="javascript: toggleCommentForm(' . $event['id_evento'] . ')" id="validate-'.$event["id_evento"].'">';
|
||||
$data[$i] .= '<a href="javascript:" class="validate_event" id="validate-'.$event["id_evento"].'">';
|
||||
$data[$i] .= html_print_image ("images/ok.png", true,
|
||||
array ("title" => __('Validate event')));
|
||||
$data[$i] .= '</a> ';
|
||||
|
@ -860,20 +849,6 @@ foreach ($result as $event) {
|
|||
$data[$i] .= html_print_image ("images/eye.png", true,
|
||||
array ("title" => __('Show more')));
|
||||
$data[$i] .= '</a> ';
|
||||
|
||||
// Create incident from this event
|
||||
if (check_acl ($config["id_user"], $event["id_grupo"], "IW") == 1) {
|
||||
if(isset($config['integria_enabled']) && $config['integria_enabled'] == 1) {
|
||||
$incidents_path = 'integria_incidents/incident&tab=editor';
|
||||
}
|
||||
else {
|
||||
$incidents_path = 'incidents/incident_detail&insert_form';
|
||||
}
|
||||
$data[$i] .= '<a href="index.php?sec=incidencias&sec2=operation/'.$incidents_path.'&from_event='.$event["id_evento"].'">';
|
||||
$data[$i] .= html_print_image ("images/page_lightning.png", true,
|
||||
array ("title" => __('Create incident from event')));
|
||||
$data[$i] .= '</a>';
|
||||
}
|
||||
$i++;
|
||||
|
||||
if (check_acl ($config["id_user"], $event["id_grupo"], "IW") == 1) {
|
||||
|
@ -883,41 +858,6 @@ foreach ($result as $event) {
|
|||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
//Hiden row with description form
|
||||
$string = '';
|
||||
$string .= '<table border="0" style="width:80%; margin-left: 10%;"><tr><td align="left" valign="top" width="30px">';
|
||||
$string .= '<td align="right"><b>' . __('Comment:') . '</b></td>';
|
||||
$string .= '<td align="left" width="450px"><b>' . html_print_textarea("comment_".$event["id_evento"], 2, 10, '', 'style="min-height: 10px; width: 250px;"', true) . '</b></td>';
|
||||
$string .= '<td align="left" width="200px">';
|
||||
$string .= '<div style="text-align:center;">';
|
||||
|
||||
if($event["estado"] == 0) {
|
||||
$string .= html_print_select(array('1' => __('Validate'), '2' => __('Set in process'), '3' => __('Add comment')), 'select_validate_'.$event["id_evento"], '', '', '', 0, true, false, false, 'select_validate').'<br><br>';
|
||||
}
|
||||
if($event["estado"] == 2) {
|
||||
$string .= html_print_select(array('1' => __('Validate'), '3' => __('Add comment')), 'select_validate_'.$event["id_evento"], '', '', '', 0, true, false, false, 'select_validate').'<br><br>';
|
||||
}
|
||||
|
||||
$string .= '<a class="validate_event" href="javascript: toggleCommentForm(' . $event['id_evento'] . ')" id="validate-'.$event["id_evento"].'">';
|
||||
|
||||
$string .= html_print_button (__('Update'), 'validate', false, '', 'class="sub ok validate_event" id="validate-'.$event["id_evento"].'"', true).'</div>';
|
||||
$string .= '</a>';
|
||||
$string .= '</td><td width="400px">';
|
||||
if($event["id_alert_am"] != 0) {
|
||||
$string .= '<div id="standby_alert_checkbox_' . $event['id_evento']. '" class="standby_alert_checkbox" style="display: none">'.__('Set alert on standby').'<br>'.html_print_checkbox('standby-alert-'.$event["id_evento"], 'ff2', false, true).'</div>';
|
||||
}
|
||||
$string .= '</td></tr></table>';
|
||||
|
||||
$data = array($string);
|
||||
|
||||
$idx++;
|
||||
|
||||
$table->rowclass[$idx] = 'event_form_' . $event["id_evento"].' event_form';
|
||||
$table->colspan[$idx][0] = 10;
|
||||
$table->rowstyle[$idx] = 'display: none;';
|
||||
array_push ($table->data, $data);
|
||||
|
||||
|
||||
$idx++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue