From 1d37ef99b30e5cffc817c00f1b7563a945f92963 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 5 Nov 2012 12:52:26 +0000 Subject: [PATCH] 2012-11-05 Miguel de Dios * 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 --- pandora_console/ChangeLog | 7 + pandora_console/operation/events/events.php | 152 ++++++++++-------- .../operation/events/events_list.php | 75 ++++----- 3 files changed, 127 insertions(+), 107 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 76f67e78b2..cf9c1c6243 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2012-11-05 Miguel de Dios + + * 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 * operation/reporting/reporting_xml.php: Moved functions diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 6c874b076b..cdd3d69ed7 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -45,8 +45,8 @@ if (is_ajax ()) { if ($event === false) return; - echo '

'.__('Event').'

'; - echo ''.__('Type').':
'; + echo '

' . __('Event') . '

'; + echo '' . __('Type') . ':
'; events_print_type_img ($event["event_type"]); echo ' '; @@ -61,11 +61,11 @@ if (is_ajax ()) { echo ''; } echo '
'; - echo ''.__('Timestamp').':
'; + echo '' . __('Timestamp') . ':
'; ui_print_timestamp ($event['utimestamp']); echo '
'; - echo ''.__('Description').':
'; + echo '' . __('Description') . ':
'; 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&sec2=operation/events/events&search=" . $id_agent . "&id_event=" . $id_event . "&pagination=" . $pagination . "&group_rep=" . $group_rep . "&event_view_hr=" . $event_view_hr . "&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); ?> ".__('Events')." » ".__('Main event view'). " "; + echo "

" . __('Events') . " » " . __('Main event view') . " "; echo ui_print_help_icon ("eventview", true); echo " "; - echo ''; - html_print_image ("images/normalscreen.png", false, array ("title" => __('Back to normal mode'))); + echo ''; + html_print_image ("images/normalscreen.png", false, + array("title" => __('Back to normal mode'))); echo ''; echo "

"; } @@ -291,8 +299,8 @@ echo ""; 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(); @@ -472,12 +481,14 @@ $(document).ready( function() { $("#status_img_"+id).attr ("alt", ); // 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(); @@ -537,7 +548,7 @@ $(document).ready( function() { $("#status_img_"+id).attr ("alt", ); // 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(""); - 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(); @@ -687,7 +697,7 @@ $(document).ready( function() { $("#status_img_"+id).attr ("title", ); $("#status_img_"+id).attr ("alt", ); } // In process - else if (new_status == 2){ + else if (new_status == 2) { // Change status description $("#status_row_"+id).html(); @@ -707,12 +717,13 @@ $(document).ready( function() { $("#status_img_"+id).attr ("alt", ); // 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 - show_event_dialog(, 1); - - + show_event_dialog(, 1); + + /* ]]> */ + \ No newline at end of file diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 6b0f52a1ad..b56084f95d 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -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&sec2=operation/events/events&search=" . echo "
"; //Link to toggle filter -if (!empty($id_name)){ +if (!empty($id_name)) { echo ''.__('Event control filter').' '.html_print_image ("images/go.png", true, array ("title" => __('Toggle filter(s)'), "id" => 'toggle_arrow')).'

'; } else{ @@ -292,7 +293,8 @@ html_print_select ($fields, 'status', $status, '', '', ''); echo ""; // Free search -echo "".__('Free search').""; +echo "" . __('Free search') . ""; +echo ""; html_print_input_text ('search', io_safe_output($search), '', 15); echo ''; @@ -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 ''; @@ -327,14 +330,14 @@ echo ""; html_print_select ($lpagination, "pagination", $pagination, '', __('Default'), $config["block_size"]); echo ""; -echo "".__('Max. hours old').""; +echo "" . __('Max. hours old') . ""; echo ""; html_print_input_text ('event_view_hr', $event_view_hr, '', 5); echo ""; echo ""; -echo "".__('User ack.').""; +echo "" . __('User ack.') . ""; echo ""; $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] .= '' . ui_print_truncate_text (io_safe_output($event["evento"]), 160) . ''; $data[$i] .= ''; $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] = '' - .db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $event["id_agentmodule"]).''; + . db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $event["id_agentmodule"]).''; $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] .= ' ' . html_print_image('images/lupa.png', true, array('title' => __('Click here to open a popup window with URL tag'))) . ' '; } $data[$i] .= ','; @@ -913,8 +915,7 @@ unset ($table); ?>