2012-11-05 Miguel de Dios <miguel.dedios@artica.es>

* operation/events/events.php: cleaned source code style.
	
	* operation/events/events_list.php: cleaned source code style and
	fixed the lost id_agent when reload.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7129 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-11-05 12:52:26 +00:00
parent cdabd8f2fd
commit 32fd0fd87c
3 changed files with 127 additions and 107 deletions

View File

@ -1,3 +1,10 @@
2012-11-05 Miguel de Dios <miguel.dedios@artica.es>
* operation/events/events.php: cleaned source code style.
* operation/events/events_list.php: cleaned source code style and
fixed the lost id_agent when reload.
2012-11-05 Vanessa Gil <vanessa.gil@artica.es>
* operation/reporting/reporting_xml.php: Moved functions

View File

@ -45,8 +45,8 @@ if (is_ajax ()) {
if ($event === false)
return;
echo '<h3>'.__('Event').'</h3>';
echo '<strong>'.__('Type').': </strong><br />';
echo '<h3>' . __('Event') . '</h3>';
echo '<strong>' . __('Type') . ': </strong><br />';
events_print_type_img ($event["event_type"]);
echo ' ';
@ -61,11 +61,11 @@ if (is_ajax ()) {
echo '';
}
echo '<br />';
echo '<strong>'.__('Timestamp').': </strong><br />';
echo '<strong>' . __('Timestamp') . ': </strong><br />';
ui_print_timestamp ($event['utimestamp']);
echo '<br />';
echo '<strong>'.__('Description').': </strong><br />';
echo '<strong>' . __('Description') . ': </strong><br />';
echo $event['evento'];
return;
@ -88,12 +88,13 @@ if (is_ajax ()) {
$new_status = get_parameter ('new_status');
// Set off the standby mode when close an event
if($new_status == 1) {
if ($new_status == 1) {
$event = events_get_event ($id);
alerts_agent_module_standby ($event['id_alert_am'], 0);
}
$return = events_validate_event ($id, $similars, $comment, $new_status);
$return = events_validate_event ($id, $similars, $comment,
$new_status);
if ($return)
echo 'ok';
else
@ -123,25 +124,31 @@ if (is_ajax ()) {
$type = array();
$alert = get_parameter('alert_fired');
if ($alert == 'true') {
$resultAlert = alerts_get_event_status_group($idGroup, 'alert_fired', $query);
$resultAlert = alerts_get_event_status_group($idGroup,
'alert_fired', $query);
}
$critical = get_parameter('critical');
if ($critical == 'true') {
$resultCritical = alerts_get_event_status_group($idGroup, 'going_up_critical', $query);
$resultCritical = alerts_get_event_status_group($idGroup,
'going_up_critical', $query);
}
$warning = get_parameter('warning');
if ($warning == 'true') {
$resultWarning = alerts_get_event_status_group($idGroup, 'going_up_warning', $query);
$resultWarning = alerts_get_event_status_group($idGroup,
'going_up_warning', $query);
}
if ($resultAlert) {
$return = array('fired' => $resultAlert, 'sound' => $config['sound_alert']);
$return = array('fired' => $resultAlert,
'sound' => $config['sound_alert']);
}
else if ($resultCritical) {
$return = array('fired' => $resultCritical, 'sound' => $config['sound_critical']);
$return = array('fired' => $resultCritical,
'sound' => $config['sound_critical']);
}
else if ($resultWarning) {
$return = array('fired' => $resultWarning, 'sound' => $config['sound_warning']);
$return = array('fired' => $resultWarning,
'sound' => $config['sound_warning']);
}
else {
$return = array('fired' => 0);
@ -187,7 +194,7 @@ $url = "index.php?sec=eventos&amp;sec2=operation/events/events&amp;search=" .
$id_agent . "&amp;id_event=" . $id_event . "&amp;pagination=" .
$pagination . "&amp;group_rep=" . $group_rep . "&amp;event_view_hr=" .
$event_view_hr . "&amp;id_user_ack=" . $id_user_ack;
// Header
if ($config["pure"] == 0) {
$pss = get_user_info($config['id_user']);
@ -245,7 +252,7 @@ if ($config["pure"] == 0) {
'sound_event' => $sound_event) ;
}
switch ($section){
switch ($section) {
case 'sound_event':
$onheader['sound_event']['active'] = true;
break;
@ -254,33 +261,34 @@ if ($config["pure"] == 0) {
break;
}
ui_print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false, $onheader);
ui_print_page_header (__("Events"), "images/lightning_go.png",
false, "eventview", false, $onheader);
?>
<script type="text/javascript">
function openSoundEventWindow() {
url = '<?php
echo ui_get_full_url('operation/events/sound_events.php');
?>';
function openSoundEventWindow() {
url = '<?php
echo ui_get_full_url('operation/events/sound_events.php');
?>';
window.open(url, '<?php __('Sound Alerts'); ?>','width=300, height=300, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes');
}
window.open(url, '<?php __('Sound Alerts'); ?>','width=300, height=300, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes');
}
function openURLTagWindow(url) {
window.open(url, '','width=300, height=300, toolbar=no, location=no, directories=no, status=no, menubar=no');
}
function openURLTagWindow(url) {
window.open(url, '','width=300, height=300, toolbar=no, location=no, directories=no, status=no, menubar=no');
}
</script>
<?php
}
else {
// Fullscreen
echo "<h2>".__('Events')." &raquo; ".__('Main event view'). "&nbsp;";
echo "<h2>" . __('Events') . " &raquo; " . __('Main event view') . "&nbsp;";
echo ui_print_help_icon ("eventview", true);
echo "&nbsp;";
echo '<a target="_top" href="'.$url.'&amp;pure=0">';
html_print_image ("images/normalscreen.png", false, array ("title" => __('Back to normal mode')));
echo '<a target="_top" href="' . $url . '&amp;pure=0">';
html_print_image ("images/normalscreen.png", false,
array("title" => __('Back to normal mode')));
echo '</a>';
echo "</h2>";
}
@ -291,8 +299,8 @@ echo "</div>";
if (($section == 'validate') && ($ids[0] == -1)) {
$section = 'list';
ui_print_error_message (__('No events selected'));
$section = 'list';
ui_print_error_message (__('No events selected'));
}
//Process validation (pass array or single value)
@ -304,23 +312,24 @@ if ($validate) {
$standby_alert = (bool) get_parameter("standby-alert");
// Avoid to re-set inprocess events
if($new_status == 2) {
foreach($ids as $key => $id) {
if ($new_status == 2) {
foreach ($ids as $key => $id) {
$event = events_get_event($id);
if($event['estado'] == 2) {
if ($event['estado'] == 2) {
unset($ids[$key]);
}
}
}
if(isset($ids[0]) && $ids[0] != -1){
$return = events_validate_event ($ids, ($group_rep == 1), $comment, $new_status);
if($new_status == 1) {
if (isset($ids[0]) && $ids[0] != -1) {
$return = events_validate_event ($ids, ($group_rep == 1),
$comment, $new_status);
if ($new_status == 1) {
ui_print_result_message ($return,
__('Successfully validated'),
__('Could not be validated'));
}
else if($new_status == 2) {
elseif ($new_status == 2) {
ui_print_result_message ($return,
__('Successfully set in process'),
__('Could not be set in process'));
@ -328,7 +337,7 @@ if ($validate) {
}
if ($standby_alert) {
foreach($ids as $id) {
foreach ($ids as $id) {
$event = events_get_event ($id);
if ($event !== false) {
alerts_agent_module_standby ($event['id_alert_am'], 1);
@ -350,7 +359,7 @@ if ($delete) {
require_once('operation/events/events_list.php');
}
else {
switch($section) {
switch ($section) {
case 'list':
require_once('operation/events/events_list.php');
break;
@ -400,7 +409,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');
@ -440,7 +449,7 @@ $(document).ready( function() {
// Refresh interface elements, don't reload (awfull)
// Validate
if (select_validate == 1){
if (select_validate == 1) {
$("#status_img_"+id).attr ("src", "images/spinner.gif");
// Change status description
$("#status_row_"+id).html(<?php echo "'" . __('Event validated') . "'"; ?>);
@ -472,12 +481,14 @@ $(document).ready( function() {
$("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event validated') . "'"; ?>);
// Remove row due to new state
if (($("#status").val() == 2) || ($("#status").val() == 0) || ($("#status").val() == 3)){
if (($("#status").val() == 2)
|| ($("#status").val() == 0)
|| ($("#status").val() == 3)) {
$.each($tr, function(index, value){
$.each($tr, function(index, value) {
row = value;
if ($(row).attr('id') != ''){
if ($(row).attr('id') != '') {
row_id_name = $(row).attr('id').split('-').shift();
row_id_number = $(row).attr('id').split('-').pop() - 1;
@ -496,7 +507,7 @@ $(document).ready( function() {
}
} // In process
else if (select_validate == 2){
else if (select_validate == 2) {
$("#status_img_"+id).attr ("src", "images/spinner.gif");
// Change status description
$("#status_row_"+id).html(<?php echo "'" . __('Event in process') . "'"; ?>);
@ -537,7 +548,7 @@ $(document).ready( function() {
$("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event in process') . "'"; ?>);
// Remove row due to new state
if (($("#status").val() == 0) || ($("#status").val() == 1)){
if (($("#status").val() == 0) || ($("#status").val() == 1)) {
$.each($tr, function(index, value){
row = value;
@ -561,7 +572,7 @@ $(document).ready( function() {
}
} // Add comment
else if (select_validate == 3){
else if (select_validate == 3) {
// Get event comment
jQuery.post ("ajax.php",
{"page" : "operation/events/events",
@ -597,7 +608,7 @@ $(document).ready( function() {
$("a.delete_event").click (function () {
confirmation = confirm("<?php echo __('Are you sure?'); ?>");
if (!confirmation){
if (!confirmation) {
return;
}
$tr = $(this).parents ("tr");
@ -620,9 +631,9 @@ $(document).ready( function() {
);
return false;
});
function toggleDiv (divid){
if (document.getElementById(divid).style.display == 'none'){
function toggleDiv (divid) {
if (document.getElementById(divid).style.display == 'none') {
document.getElementById(divid).style.display = 'block';
}
else {
@ -630,7 +641,6 @@ $(document).ready( function() {
}
}
});
/* ]]> */
function toggleCommentForm(id_event) {
display = $('.event_form_' + id_event).css('display');
@ -659,14 +669,14 @@ $(document).ready( function() {
function validate_event_advanced(id, new_status) {
$tr = $('#validate-'+id).parents ("tr");
var grouped = $('#group_rep').val();
var similar_ids;
similar_ids = $('#hidden-similar_ids_'+id).val();
$("#status_img_"+id).attr ("src", "images/spinner.gif");
jQuery.post ("ajax.php",
{"page" : "include/ajax/events",
"change_status" : 1,
@ -674,10 +684,10 @@ $(document).ready( function() {
"new_status" : new_status
},
function (data, status) {
if (data == "status_ok") {
if (data == "status_ok") {
// Refresh interface elements, don't reload (awful)
// Validate
if (new_status == 1){
if (new_status == 1) {
// Change status description
$("#status_row_"+id).html(<?php echo "'" . __('Event validated') . "'"; ?>);
@ -687,7 +697,7 @@ $(document).ready( function() {
$("#status_img_"+id).attr ("title", <?php echo "'" . __('Event validated') . "'"; ?>);
$("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event validated') . "'"; ?>);
} // In process
else if (new_status == 2){
else if (new_status == 2) {
// Change status description
$("#status_row_"+id).html(<?php echo "'" . __('Event in process') . "'"; ?>);
@ -707,12 +717,13 @@ $(document).ready( function() {
$("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event in process') . "'"; ?>);
// Remove row due to new state
if (($("#status").val() == 0) || ($("#status").val() == 1)){
if (($("#status").val() == 0)
|| ($("#status").val() == 1)) {
$.each($tr, function(index, value){
$.each($tr, function(index, value) {
row = value;
if ($(row).attr('id') != ''){
if ($(row).attr('id') != '') {
row_id_name = $(row).attr('id').split('-').shift();
row_id_number = $(row).attr('id').split('-').pop() - 1;
@ -745,12 +756,13 @@ $(document).ready( function() {
// 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
}
$load_event = get_parameter('load_event',0);
if ($load_event) {
?>
</script>
show_event_dialog(<?php echo $load_event; ?>, 1);
<?php
}
?>
/* ]]> */
</script>

View File

@ -41,13 +41,13 @@ if (is_ajax()) {
$save_event_filter = get_parameter('save_event_filter', 0);
$update_event_filter = get_parameter('update_event_filter', 0);
$get_event_filters = get_parameter('get_event_filters', 0);
// Get db values of a single filter
if ($get_filter_values) {
$id_filter = get_parameter('id');
$event_filter = events_get_event_filter($id_filter);
$event_filter['tag'] = io_safe_output($event_filter['tag']);
$event_filter['id_name'] = io_safe_output($event_filter['id_name']);
@ -74,7 +74,7 @@ if (is_ajax()) {
$result = db_process_sql_insert('tevent_filter', $values);
if ($result === false){
if ($result === false) {
echo 'error';
}
else {
@ -129,7 +129,7 @@ $tag = get_parameter("tag", "");
if ($id_agent == 0) {
$text_agent = (string) get_parameter("text_agent", __("All"));
if($text_agent != __('All')) {
if ($text_agent != __('All')) {
$id_agent = -1;
}
}
@ -157,7 +157,7 @@ if (!check_acl ($config["id_user"], 0, "PM")) {
$sql_post .= " AND id_grupo != 0";
}
switch($status) {
switch ($status) {
case 0:
case 1:
case 2:
@ -175,7 +175,8 @@ if ($search != "") {
if ($event_type != "") {
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
// for the user so for him is presented only "warning, critical and normal"
if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
if ($event_type == "warning" || $event_type == "critical"
|| $event_type == "normal") {
$sql_post .= " AND event_type LIKE '%$event_type%' ";
}
elseif ($event_type == "not_normal") {
@ -189,7 +190,7 @@ if ($event_type != "") {
if ($severity != -1)
$sql_post .= " AND criticity = ".$severity;
switch($id_agent) {
switch ($id_agent) {
case 0:
break;
case -1:
@ -237,7 +238,7 @@ $url = "index.php?sec=eventos&amp;sec2=operation/events/events&amp;search=" .
echo "<br>";
//Link to toggle filter
if (!empty($id_name)){
if (!empty($id_name)) {
echo '<a href="#" id="tgl_event_control"><b>'.__('Event control filter').'</b>&nbsp;'.html_print_image ("images/go.png", true, array ("title" => __('Toggle filter(s)'), "id" => 'toggle_arrow')).'</a><br><br>';
}
else{
@ -292,7 +293,8 @@ html_print_select ($fields, 'status', $status, '', '', '');
echo "</td></tr><tr>";
// Free search
echo "<td>".__('Free search')."</td><td>";
echo "<td>" . __('Free search') . "</td>";
echo "<td>";
html_print_input_text ('search', io_safe_output($search), '', 15);
echo '</td>';
@ -305,6 +307,7 @@ $params['input_name'] = 'text_agent';
$params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_name'] = 'id_agent';
$params['value'] = $text_agent;
$params['hidden_input_idagent_value'] = $id_agent;
ui_print_agent_autocomplete_input($params);
echo '</td>';
@ -327,14 +330,14 @@ echo "<td>";
html_print_select ($lpagination, "pagination", $pagination, '', __('Default'), $config["block_size"]);
echo "</td>";
echo "<td>".__('Max. hours old')."</td>";
echo "<td>" . __('Max. hours old') . "</td>";
echo "<td>";
html_print_input_text ('event_view_hr', $event_view_hr, '', 5);
echo "</td>";
echo "</tr><tr>";
echo "<td>".__('User ack.')."</td>";
echo "<td>" . __('User ack.') . "</td>";
echo "<td>";
$users = users_get_info ();
html_print_select ($users, "id_user_ack", $id_user_ack, '', __('Any'), 0);
@ -602,7 +605,7 @@ foreach ($result as $event) {
//print status
$estado = $event["estado"];
// Colored box
switch($estado) {
case 0:
@ -642,9 +645,9 @@ foreach ($result as $event) {
$data[$i] .= html_print_input_hidden('event_rep_'.$event["id_evento"], $event['event_rep'], true);
// Store concat comments to show in extended view
$data[$i] .= html_print_input_hidden('user_comment_'.$event["id_evento"], base64_encode($event['user_comment']), true);
$i++;
if (in_array('estado',$show_fields)) {
$data[$i] = html_print_image ($img_st, true,
array ("class" => "image_status",
@ -691,7 +694,6 @@ foreach ($result as $event) {
$data[$i] .= '<span class="'.$myclass.'" style="font-size: 7.5pt;">' . ui_print_truncate_text (io_safe_output($event["evento"]), 160) . '</span>';
$data[$i] .= '</a></span>';
$i++;
}
if (in_array('id_agente', $show_fields)) {
@ -750,7 +752,7 @@ foreach ($result as $event) {
if (in_array('id_agentmodule',$show_fields)) {
$data[$i] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$event["id_agente"].'&amp;tab=data">'
.db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $event["id_agentmodule"]).'</a>';
. db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $event["id_agentmodule"]).'</a>';
$i++;
}
@ -785,12 +787,12 @@ foreach ($result as $event) {
if ($event["tags"] != '') {
$tag_array = explode(',', $event["tags"]);
$data[$i] = '';
foreach ($tag_array as $tag_element){
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[$i] .= ' ' .$tag_name;
if (!empty($tag_url)){
if (!empty($tag_url)) {
$data[$i] .= ' <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[$i] .= ',';
@ -913,8 +915,7 @@ unset ($table);
?>
<script language="javascript" type="text/javascript">
/*
<![CDATA[ */
/*<![CDATA[ */
$(document).ready( function() {
// Don't collapse filter if update button has been pushed
if ($("#hidden-toogle_filter").val() == 'false'){
@ -1026,7 +1027,7 @@ $(document).ready( function() {
"search" : $("#text-search").val(),
"text_agent" : $("#text_id_agent").val(),
"pagination" : $("#pagination").val(),
"event_view_hr" : $("#text-event_view_hr").val(),
"event_view_hr" : $("#text-event_view_hr").val(),
"id_user_ack" : $("#id_user_ack").val(),
"group_rep" : $("#group_rep").val(),
"tag" : $("#tag").val(),
@ -1119,22 +1120,22 @@ $(document).ready( function() {
$('#filter_id').append ($('<option></option>').html ( <?php echo "'" . __('none') . "'" ?> ).attr ("value", 0));
// Reload filters select
jQuery.post ("ajax.php",
{"page" : "operation/events/events_list",
"get_event_filters" : 1
},
function (data) {
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
if (i == id_filter_update) {
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
}
else {
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
}
});
},
"json"
);
{"page" : "operation/events/events_list",
"get_event_filters" : 1
},
function (data) {
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
if (i == id_filter_update) {
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
}
else {
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
}
});
},
"json"
);
return false;
});