From 8cbf72e24650055a7aea73efa5446e82389732df Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 14 May 2013 15:23:57 +0000 Subject: [PATCH] 2013-05-14 Miguel de Dios * godmode/alerts/alert_commands.php: fixed the ajax of "get_alert_command". Fixes: #2214 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8133 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 ++ .../godmode/alerts/alert_commands.php | 72 ++++++++++--------- 2 files changed, 46 insertions(+), 33 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index f25cdf0fa2..4119d928f9 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2013-05-14 Miguel de Dios + + * godmode/alerts/alert_commands.php: fixed the ajax of + "get_alert_command". + + Fixes: #2214 + 2013-05-14 Ramon Novoa * include/config_process.php, diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index b3123281ec..c5c5c809ab 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -33,8 +33,8 @@ if (defined('METACONSOLE')) $sec = 'advanced'; else $sec = 'galertas'; - -$pure = get_parameter('pure', 0); + +$pure = get_parameter('pure', 0); if (is_ajax ()) { $get_alert_command = (bool) get_parameter ('get_alert_command'); @@ -42,7 +42,7 @@ if (is_ajax ()) { $id = (int) get_parameter ('id', 0); // If command ID is not provided, check for action id - if($id == 0) { + if ($id == 0) { $id_action = (int) get_parameter ('id_action'); $id = alerts_get_alert_action_alert_command_id($id_action); } @@ -50,7 +50,7 @@ if (is_ajax ()) { $command = alerts_get_alert_command ($id); // If is setted a description, we change the carriage return by
tags - if(isset($command['description'])) { + if (isset($command['description'])) { $command['description'] = io_safe_input(str_replace("\r\n","
", io_safe_output($command['description']))); } @@ -58,39 +58,40 @@ if (is_ajax ()) { // Descriptions are stored in json $fields_descriptions = empty($command['fields_descriptions']) ? '' : json_decode(io_safe_output($command['fields_descriptions']), true); - + // Fields values are stored in json $fields_values = empty($command['fields_values']) ? '' : json_decode(io_safe_output($command['fields_values']), true); - + $fields_rows = array(); - for($i=1;$i<=10;$i++) { - if(!empty($fields_descriptions[$i-1])) { - $fdesc = $fields_descriptions[$i-1].'
'.sprintf(__('Field %s'), $i).''; + for ($i = 1; $i <= 10; $i++) { + if (!empty($fields_descriptions[$i - 1])) { + $fdesc = $fields_descriptions[$i - 1] . + '
' . sprintf(__('Field %s'), $i) . ''; } else { // If the macro hasn't description and doesnt appear in command, set with empty description to dont show it - if(substr_count($command['command'], "_field$i_") > 0) { + if (substr_count($command['command'], "_field" . $i . "_") > 0) { $fdesc = sprintf(__('Field %s'), $i); } else { $fdesc = ''; } } - - if(!empty($fields_values[$i-1])) { + + if (!empty($fields_values[$i-1])) { $fields_value_select = array(); $fv = $fields_values[$i-1]; $fv = explode(';', $fv); - if(empty($fv)) { + if (empty($fv)) { $fv = array(); } - foreach($fv as $fv_option) { + foreach ($fv as $fv_option) { $fv_option = explode(',', $fv_option); $fields_value_select[$fv_option[0]] = $fv_option[1]; } - + $ffield = html_print_select($fields_value_select, 'field'.$i.'_value', '', '', '', 0, true, false, false); } else { @@ -98,18 +99,19 @@ if (is_ajax ()) { } // The empty descriptions will be ignored - if($fdesc == '') { + if ($fdesc == '') { $fields_rows[$i] = ''; } else { - $fields_rows[$i] = ' - - '.$fdesc.' - - - '.$ffield.' - - '; + $fields_rows[$i] = + ' + + ' . $fdesc . ' + + + ' . $ffield . ' + + '; } } @@ -134,17 +136,17 @@ if ($create_command) { $name = (string) get_parameter ('name'); $command = (string) get_parameter ('command'); $description = (string) get_parameter ('description'); - + $fields_descriptions = array(); $fields_values = array(); $info_fields = ''; $values = array(); - for($i=1;$i<=10;$i++) { + for ($i=1;$i<=10;$i++) { $fields_descriptions[] = (string) get_parameter ('field'.$i.'_description'); $fields_values[] = (string) get_parameter ('field'.$i.'_values'); $info_fields .= ' Field'.$i.': ' . $fields_values[$i - 1]; } - + $values['fields_values'] = json_encode($fields_values); $values['fields_descriptions'] = json_encode($fields_descriptions); $values['description'] = $description; @@ -190,7 +192,7 @@ if ($update_command) { $fields_values = array(); $info_fields = ''; $values = array(); - for($i=1;$i<=10;$i++) { + for ($i=1;$i<=10;$i++) { $fields_descriptions[] = (string) get_parameter ('field'.$i.'_description'); $fields_values[] = (string) get_parameter ('field'.$i.'_values'); $info_fields .= ' Field'.$i.': ' . $fields_values[$i - 1]; @@ -279,12 +281,14 @@ foreach ($commands as $command) { $data[0] .= $command['name']; $data[0] .= ''; $data[1] = $command['id']; - $data[2] = str_replace("\r\n","
",io_safe_output($command['description'])); + $data[2] = str_replace("\r\n","
", + io_safe_output($command['description'])); $data[3] = ''; - if (! $command['internal']) + if (! $command['internal']) { $data[3] = ''. html_print_image("images/cross.png", true) . ''; + } array_push ($table->data, $data); } @@ -293,11 +297,13 @@ if (isset($data)) { html_print_table ($table); } else { - echo "
".__('No alert commands configured')."
"; + echo "
" . + __('No alert commands configured') . + "
"; } -echo '
'; -echo '
'; +echo '
'; +echo ''; html_print_submit_button (__('Create'), 'create', false, 'class="sub next"'); html_print_input_hidden ('create_alert', 1); echo '';