', $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');
$server_id = get_parameter ('server_id', 0);
$event_response = db_get_row('tevent_response','id',$response_id);
if(empty($event_response)) {
return;
}
echo events_get_response_target($event_id, $response_id, $server_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 = "
> ";
switch($event_response['type']) {
case 'command':
echo "
";
echo $prompt.sprintf(__('Executing command: %s',$command));
echo "
";
echo "".html_print_image('images/spinner.gif', true)."
";
echo "
";
echo "
";
html_print_button(__('Execute again'),'btn_str',false,'perform_response(\''.$command.'\');', "class='sub next'");
echo "
";
break;
case 'url':
echo "";
break;
}
}
if($add_comment) {
$comment = get_parameter ('comment');
$event_id = get_parameter ('event_id');
$return = events_comment ($event_id, $comment, 'Added comment', $meta);
if ($return)
echo 'comment_ok';
else
echo 'comment_error';
return;
}
if($change_status) {
$event_ids = get_parameter ('event_ids');
$new_status = get_parameter ('new_status');
$return = events_change_status (explode(',',$event_ids), $new_status, $meta);
if ($return)
echo 'status_ok';
else
echo 'status_error';
return;
}
if($change_owner) {
$new_owner = get_parameter ('new_owner');
$event_id = get_parameter ('event_id');
$similars = true;
if($new_owner == -1) {
$new_owner = '';
}
$return = events_change_owner($event_id, $new_owner, true);
if ($return)
echo 'owner_ok';
else
echo 'owner_error';
return;
}
if($get_extended_event) {
global $config;
$event_id = get_parameter('event_id',false);
if($meta) {
$event = events_meta_get_event($event_id);
}
else {
$event = events_get_event($event_id);
}
// If the event is not found, we abort
if(empty($event)) {
ui_print_error_message('Event not found');
return false;
}
$dialog_page = get_parameter('dialog_page','general');
$similar_ids = get_parameter('similar_ids', $event_id);
$group_rep = get_parameter('group_rep',false);
$event_rep = get_parameter('event_rep',1);
$timestamp_first = get_parameter('timestamp_first', $event['utimestamp']);
$timestamp_last = get_parameter('timestamp_last', $event['utimestamp']);
$server_id = get_parameter('server_id', 0);
$event['similar_ids'] = $similar_ids;
$event['timestamp_first'] = $timestamp_first;
$event['timestamp_last'] = $timestamp_last;
$event['event_rep'] = $event_rep;
// 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;
}
}
// Print group_rep in a hidden field to recover it from javascript
html_print_input_hidden('group_rep',(int)$group_rep);
if($event === false) {
return;
}
// Tabs
$tabs = "";
// Get criticity image
switch ($event["criticity"]) {
default:
case 0:
$img_sev = "images/status_sets/default/severity_maintenance.png";
break;
case 1:
$img_sev = "images/status_sets/default/severity_informational.png";
break;
case 2:
$img_sev = "images/status_sets/default/severity_normal.png";
break;
case 3:
$img_sev = "images/status_sets/default/severity_warning.png";
break;
case 4:
$img_sev = "images/status_sets/default/severity_critical.png";
break;
case 5:
$img_sev = "images/status_sets/default/severity_minor.png";
break;
case 6:
$img_sev = "images/status_sets/default/severity_major.png";
break;
}
$responses = events_page_responses($event);
$console_url = '';
// If metaconsole switch to node to get details and custom fields
if($meta) {
$server = metaconsole_get_connection_by_id ($server_id);
metaconsole_connect($server);
}
$details = events_page_details($event, $server);
$custom_fields = events_page_custom_fields($event);
if($meta) {
metaconsole_restore_db_force();
}
$general = events_page_general($event);
$comments = events_page_comments($event);
$notifications = '';
$notifications .= '';
$notifications .= ''.ui_print_error_message(__('Error changing event status'),'',true).'
';
$notifications .= ''.ui_print_success_message(__('Event status changed successfully'),'',true).'
';
$notifications .= ''.ui_print_error_message(__('Error changing event owner'),'',true).'
';
$notifications .= ''.ui_print_success_message(__('Event owner changed successfully'),'',true).'
';
$loading = ''.html_print_image('images/spinner.gif',true).'
';
$out = ''.
$tabs.
$notifications.
$loading.
$general.
$details.
$custom_fields.
$comments.
$responses.
html_print_input_hidden('id_event',$event['id_evento']).
'
';
$js = '';
echo $out.$js;
}
if($get_events_details) {
$event_ids = explode(',',get_parameter ('event_ids'));
$events = db_get_all_rows_filter ('tevento',
array ('id_evento' => $event_ids,
'order' => 'utimestamp ASC'),
array ('evento', 'utimestamp', 'estado', 'criticity'));
$out = '';
$out .= ' | |
';
foreach($events as $event) {
switch($event["estado"]) {
case 0:
$img = "../../images/star.png";
$title = __('New event');
break;
case 1:
$img = "../../images/tick.png";
$title = __('Event validated');
break;
case 2:
$img = "../../images/hourglass.png";
$title = __('Event in process');
break;
}
$out .= '';
$out .= '';
$out .= ' | ';
$out .= io_safe_output($event['evento']);
$out .= ' |
| ';
$out .= ' |
| ';
$out .= ' |
';
}
$out .= '
';
echo $out;
}
?>