diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9379967cd4..adbf1eca04 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2012-08-16 Sergio Martin + + * include/functions_ui.php: Improve help tip centering the text + + * general/login_help_dialog.php: Fix a typo + + * godmode/agentes/module_manager_editor_plugin.php + godmode/servers/plugin.php + godmode/modules/manage_network_components_form_plugin.php: Clean plugin forms + of unecessary fields and improve the plugin editor form locking the command + configuration when a plugin is used by any modules + 2012-08-16 Vanessa Gil * pandoradb.data.oracle.sql diff --git a/pandora_console/general/login_help_dialog.php b/pandora_console/general/login_help_dialog.php index 5d6db188de..4b75fe02dd 100644 --- a/pandora_console/general/login_help_dialog.php +++ b/pandora_console/general/login_help_dialog.php @@ -38,7 +38,7 @@ if (is_ajax()) { echo '
'; echo '
'; - echo '' . __('If this is your first time with Pandora FMS, we propose you a few links to learn more about Pandora FMS. Monitoring could be overhelm, but take your time to learn how to use the power of Pandora!') . ''; + echo '' . __('If this is your first time with Pandora FMS, we propose you a few links to learn more about Pandora FMS. Monitoring could be overwhelm, but take your time to learn how to use the power of Pandora!') . ''; echo '
'; echo '
'; diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index 1aa9ff1b9c..826da32564 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -62,23 +62,6 @@ $data[2] = ''.$preloa push_table_simple ($data, 'plugin_1'); -$data = array (); -$data[0] = __('Target IP'); -$data[1] = html_print_input_text ('ip_target', $ip_target, '', 50, 60, true); -$data[2] = __('Port'); -$data[3] = html_print_input_text ('tcp_port', $tcp_port, '', 15, 20, true); - -push_table_simple ($data, 'target_ip'); - -$data = array (); -$data[0] = __('Username'); -$data[1] = html_print_input_text ('plugin_user', $plugin_user, '', 30, 60, true); - -$data[2] = __('Password'); -$data[3] = html_print_input_password ('plugin_pass', $plugin_pass, '', 15, 60, true); - -push_table_simple ($data, 'plugin_2'); - // A hidden "model row" to clone it from javascript to add fields dynamicly $data = array (); $data[0] = 'macro_desc'; diff --git a/pandora_console/godmode/modules/manage_network_components_form_plugin.php b/pandora_console/godmode/modules/manage_network_components_form_plugin.php index 5c848c93fa..20dac5998f 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_plugin.php +++ b/pandora_console/godmode/modules/manage_network_components_form_plugin.php @@ -20,13 +20,6 @@ check_login (); echo "

".__('Plugin component').'

'; -$data = array (); -$data[0] = __('Port'); -$data[1] = html_print_input_text ('tcp_port', $tcp_port, '', 5, 20, true); -$table->colspan['plugin_0'][1] = 3; - -push_table_row ($data, 'plugin_0'); - $data = array (); $data[0] = __('Plugin'); $data[1] = html_print_select_from_sql ('SELECT id, name FROM tplugin ORDER BY name', @@ -38,14 +31,6 @@ $data[3] = html_print_input_text ('post_process', $post_process, '', 12, 25, tru push_table_row ($data, 'plugin_1'); -$data = array (); -$data[0] = __('Username'); -$data[1] = html_print_input_text ('plugin_user', $plugin_user, '', 15, 60, true); -$data[2] = _('Password'); -$data[3] = html_print_input_password ('plugin_pass', $plugin_pass, '', 15, 60, true); - -push_table_row ($data, 'plugin_2'); - // A hidden "model row" to clone it from javascript to add fields dynamicly $data = array (); $data[0] = 'macro_desc'; diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 5ede55a93c..68697a7360 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -55,7 +55,7 @@ if ($view != "") { if ($create != "") { $form_name = ""; $form_description = ""; - $form_max_timeout = ""; + $form_max_timeout = 15; $form_execute = ""; $form_plugin_type = 0; $form_parameters = ""; @@ -100,7 +100,7 @@ if (($create != "") OR ($view != "")) { $fields[0]= __("Standard"); $fields[1]= __("Nagios"); $data[1] = html_print_select ($fields, "form_plugin_type", $form_plugin_type, '', '', 0, true); - $data[2] = __('Max. timeout'); + $data[2] = __('Max. timeout').ui_print_help_tip (__('This value only will be applied if is minor than the server general configuration plugin timeout').'.

'.__('If you set a 0 seconds timeout, the server plugin timeout will be used'), true); $data[3] = ''; $data[3] = html_print_extended_select_for_time ('form_max_timeout', $form_max_timeout, '', '', '0', false, true); $table->data['plugin_type_timeout'] = $data; @@ -117,14 +117,42 @@ if (($create != "") OR ($view != "")) { $table->data = array(); + $plugin_id = get_parameter ("view", 0); + + $locked = true; + + // If we have plugin id (update mode) and this plugin used by any module or component + // The command configuration will be locked + if($plugin_id > 0) { + $modules_using_plugin = db_get_value_filter('count(*)','tagente_modulo', array('delete_pending' => 0, 'id_plugin' => $plugin_id)); + $components_using_plugin = db_get_value_filter('count(*)','tnetwork_component', array('id_plugin' => $plugin_id)); + if(($components_using_plugin + $modules_using_plugin) == 0) { + $locked = false; + } + } + else { + $locked = false; + } + + $disabled = ''; + if($locked) { + $disabled = 'readonly="readonly"'; + } + $data = array(); $data[0] = __('Plugin command'); - $data[1] = ''; + $data[1] = ''; + if($locked) { + $data[1] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf')); + } $table->data['plugin_command'] = $data; $data = array(); $data[0] = __('Plug-in parameters').ui_print_help_icon ('plugin_parameters', true); - $data[1] = ''; + $data[1] = ''; + if($locked) { + $data[1] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf')); + } $table->data['plugin_parameters'] = $data; $data = array(); @@ -174,10 +202,17 @@ if (($create != "") OR ($view != "")) { $datam = array (); $datam[0] = __('Description')." ($macro_name)"; $datam[0] .= html_print_input_hidden($macro_name_name, $macro_name, true); - $datam[1] = html_print_input_text ($macro_desc_name, $macro_desc_value, '', 30, 255, true); + $datam[1] = html_print_input_text_extended ($macro_desc_name, $macro_desc_value, 'text-'.$macro_desc_name, '', 30, 255, $locked, '', "class='command_advanced_conf'", true); + if($locked) { + $datam[1] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf')); + } + $datam[2] = __('Default value')." ($macro_name)"; - $datam[3] = html_print_input_text_extended ($macro_value_name, $macro_value_value, 'text-'.$macro_value_name, '', 30, 255, false, '', "class='command_component'", true); - + $datam[3] = html_print_input_text_extended ($macro_value_name, $macro_value_value, 'text-'.$macro_value_name, '', 30, 255, $locked, '', "class='command_component command_advanced_conf'", true); + if($locked) { + $datam[3] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf')); + } + $table->data['plugin_'.$next_name_number] = $datam; $next_name_number++; @@ -186,27 +221,33 @@ if (($create != "") OR ($view != "")) { $datam = array (); $datam[0] = __('Help')." ($macro_name)


"; - $datam[1] = html_print_input_text ($macro_help_name, $macro_help_value, '', 100, 255, true)."


"; - + $datam[1] = html_print_input_text_extended ($macro_help_name, $macro_help_value, 'text-'.$macro_help_name, '', 100, 255, $locked, '', "class='command_advanced_conf'", true); + if($locked) { + $datam[1] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf')); + } + $datam[1] .= "


"; + $table->data['plugin_'.$next_name_number] = $datam; $next_name_number++; $i++; } - $datam = array (); - $datam[0] = ''.__('Add macro').' '.html_print_image('images/add.png',true).''; - $datam[0] .= ''; - $datam[0] .= ''; - $delete_macro_style = ''; - if($i <= 2) { - $delete_macro_style = 'display:none;'; + if(!$locked) { + $datam = array (); + $datam[0] = ''.__('Add macro').' '.html_print_image('images/add.png',true).''; + $datam[0] .= ''; + $datam[0] .= ''; + $delete_macro_style = ''; + if($i <= 2) { + $delete_macro_style = 'display:none;'; + } + $datam[2] = ''; + + $table->colspan['plugin_action'][0] = 2; + $table->rowstyle['plugin_action'] = 'text-align:center'; + $table->colspan['plugin_action'][2] = 2; + $table->data['plugin_action'] = $datam; } - $datam[2] = ''; - - $table->colspan['plugin_action'][0] = 2; - $table->rowstyle['plugin_action'] = 'text-align:center'; - $table->colspan['plugin_action'][2] = 2; - $table->data['plugin_action'] = $datam; echo '
'.__('Parameters macros').ui_print_help_icon ('macros', true).''; html_print_table($table); @@ -290,12 +331,36 @@ else { $plugin_plugin_type = get_parameter ("form_plugin_type", "0"); $plugin_parameters = get_parameter ("form_parameters", "0"); + // Get macros + $i = 1; + $macros = array(); + while(1) { + $macro = (string)get_parameter ('field'.$i.'_macro'); + if($macro == '') { + break; + } + + $desc = (string)get_parameter ('field'.$i.'_desc'); + $help = (string)get_parameter ('field'.$i.'_help'); + $value = (string)get_parameter ('field'.$i.'_value'); + + $macros[$i]['macro'] = $macro; + $macros[$i]['desc'] = $desc; + $macros[$i]['help'] = $help; + $macros[$i]['value'] = $value; + $i++; + } + + $macros = json_encode($macros); + $values = array( 'name' => $plugin_name, 'description' => $plugin_description, 'max_timeout' => $plugin_max_timeout, 'execute' => $plugin_execute, - 'plugin_type' => $plugin_plugin_type); + 'plugin_type' => $plugin_plugin_type, + 'parameters' => $plugin_parameters, + 'macros' => $macros); $result = false; if ($values['name'] != '' && $values['execute'] != '') @@ -410,4 +475,15 @@ $(document).ready(function() { }); }); + + + $('.command_advanced_conf').click(function() { + alert(''); + }); + + diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index e590706949..a48069d63a 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1483,7 +1483,7 @@ function ui_pagination ($count, $url = false, $offset = 0, $pagination = 0, $ret * @return string HTML code if return parameter is true. */ function ui_print_help_tip ($text, $return = false, $img = 'images/tip.png') { - $output = '' . html_print_image ($img, true) . ''.$text.''; + $output = '' . html_print_image ($img, true) . ''.$text.''; if ($return) return $output;