fixed error network component plugin

This commit is contained in:
Daniel Barbero 2019-07-05 13:46:48 +02:00
parent da110f1d33
commit 6e7dfb38fd
2 changed files with 100 additions and 37 deletions

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* Extension to manage a list of gateways and the node address where they should
* point to.
*
* @category Network components Plugins
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global variables
global $config; global $config;
check_login(); check_login();
@ -29,7 +44,7 @@ $data[1] = html_print_select_from_sql(
false, false,
false false
); );
// Store the macros in base64 into a hidden control to move between pages // Store the macros in base64 into a hidden control to move between pages.
$data[1] .= html_print_input_hidden('macros', base64_encode($macros), true); $data[1] .= html_print_input_hidden('macros', base64_encode($macros), true);
$data[2] = __('Post process'); $data[2] = __('Post process');
$data[3] = html_print_extended_select_for_post_process( $data[3] = html_print_extended_select_for_post_process(
@ -46,7 +61,7 @@ $data[3] = html_print_extended_select_for_post_process(
push_table_row($data, 'plugin_1'); push_table_row($data, 'plugin_1');
// A hidden "model row" to clone it from javascript to add fields dynamicly // A hidden "model row" to clone it from javascript to add fields dynamicly.
$data = []; $data = [];
$data[0] = 'macro_desc'; $data[0] = 'macro_desc';
$data[0] .= ui_print_help_tip('macro_help', true); $data[0] .= ui_print_help_tip('macro_help', true);
@ -56,7 +71,7 @@ $table->rowstyle['macro_field'] = 'display:none';
push_table_row($data, 'macro_field'); push_table_row($data, 'macro_field');
// If there are $macros, we create the form fields // If there are $macros, we create the form fields.
if (!empty($macros)) { if (!empty($macros)) {
$macros = json_decode($macros, true); $macros = json_decode($macros, true);
@ -68,9 +83,23 @@ if (!empty($macros)) {
} }
if ($m['hide'] == 1) { if ($m['hide'] == 1) {
$data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 1024, true); $data[1] = html_print_input_text(
$m['macro'],
io_output_password($m['value']),
'',
100,
1024,
true
);
} else { } else {
$data[1] = html_print_input_text($m['macro'], io_output_password($m['value']), '', 100, 1024, true); $data[1] = html_print_input_text(
$m['macro'],
$m['value'],
'',
100,
1024,
true
);
} }
$table->colspan['macro'.$m['macro']][1] = 3; $table->colspan['macro'.$m['macro']][1] = 3;

View File

@ -791,7 +791,7 @@ function new_macro(prefix, callback) {
} }
} }
function add_macro_field(macro, row_model_id) { function add_macro_field(macro, row_model_id, type_copy) {
var macro_desc = macro["desc"]; var macro_desc = macro["desc"];
// Change the carriage returns by html returns <br> in help // Change the carriage returns by html returns <br> in help
var macro_help = macro["help"].replace(/&#x0d;/g, "<br>"); var macro_help = macro["help"].replace(/&#x0d;/g, "<br>");
@ -850,6 +850,20 @@ function add_macro_field(macro, row_model_id) {
} }
// Change the text box id and value // Change the text box id and value
if (type_copy == "td") {
$("#" + row_id)
.children()
.eq(1)
.children()
.eq(0)
.attr("id", "text-" + macro_macro);
$("#" + row_id)
.children()
.eq(1)
.children()
.eq(0)
.attr("name", macro_macro);
} else {
$("#" + row_id) $("#" + row_id)
.children() .children()
.eq(1) .eq(1)
@ -858,8 +872,9 @@ function add_macro_field(macro, row_model_id) {
.children() .children()
.eq(1) .eq(1)
.attr("name", macro_macro); .attr("name", macro_macro);
}
macro_field_hide = false; var macro_field_hide = false;
if (typeof macro["hide"] == "string") { if (typeof macro["hide"] == "string") {
if (macro["hide"].length == 0) { if (macro["hide"].length == 0) {
macro_field_hide = false; macro_field_hide = false;
@ -872,16 +887,35 @@ function add_macro_field(macro, row_model_id) {
} }
} }
if (type_copy == "td") {
if (macro_field_hide) {
$("#" + row_id)
.children()
.eq(1)
.children()
.eq(0)
.attr("type", "password");
} else {
$("#" + row_id)
.children()
.eq(1)
.children()
.eq(0)
.val(macro_value);
}
} else {
if (macro_field_hide) { if (macro_field_hide) {
$("#" + row_id) $("#" + row_id)
.children() .children()
.eq(1) .eq(1)
.attr("type", "password"); .attr("type", "password");
} } else {
$("#" + row_id) $("#" + row_id)
.children() .children()
.eq(1) .eq(1)
.val(macro_value); .val(macro_value);
}
}
$("#" + row_id).show(); $("#" + row_id).show();
} }
@ -908,7 +942,7 @@ function load_plugin_macros_fields(row_model_id) {
$("#hidden-macros").val(data["base64"]); $("#hidden-macros").val(data["base64"]);
jQuery.each(data["array"], function(i, macro) { jQuery.each(data["array"], function(i, macro) {
if (macro["desc"] != "") { if (macro["desc"] != "") {
add_macro_field(macro, row_model_id); add_macro_field(macro, row_model_id, "td");
} }
}); });
//Plugin text can be larger //Plugin text can be larger