Merge branch 'ent-4227-Componentes_de_red_no_funcionan_bien' into 'develop'

fixed error network component plugin

See merge request artica/pandorafms!2581
This commit is contained in:
Daniel Rodriguez 2019-07-09 10:27:08 +02:00
commit 7fa79f2043
3 changed files with 114 additions and 50 deletions

View File

@ -1276,18 +1276,10 @@ if ($update_module || $create_module) {
$m_hide = $m['hide'];
}
if ($update_module) {
if ($m_hide == '1') {
$macros[$k]['value'] = io_input_password(get_parameter($m['macro'], ''));
} else {
$macros[$k]['value'] = get_parameter($m['macro'], '');
}
if ($m_hide == '1') {
$macros[$k]['value'] = io_input_password(get_parameter($m['macro'], ''));
} else {
if ($m_hide == '1') {
$macros[$k]['value'] = io_input_password($macros_names[$k]);
} else {
$macros[$k]['value'] = $macros_names[$k];
}
$macros[$k]['value'] = get_parameter($m['macro'], '');
}
}

View File

@ -1,17 +1,32 @@
<?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;
check_login();
@ -29,7 +44,7 @@ $data[1] = html_print_select_from_sql(
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[2] = __('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');
// 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[0] = 'macro_desc';
$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');
// If there are $macros, we create the form fields
// If there are $macros, we create the form fields.
if (!empty($macros)) {
$macros = json_decode($macros, true);
@ -68,9 +83,23 @@ if (!empty($macros)) {
}
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 {
$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;

View File

@ -536,7 +536,7 @@ function configure_modules_form() {
var obj = jQuery.parseJSON(data["macros"]);
$.each(obj, function(k, macro) {
add_macro_field(macro, "simple-macro");
add_macro_field(macro, "simple-macro", "td", k);
});
}
@ -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, k) {
var macro_desc = macro["desc"];
// Change the carriage returns by html returns <br> in help
var macro_help = macro["help"].replace(/&#x0d;/g, "<br>");
@ -799,7 +799,6 @@ function add_macro_field(macro, row_model_id) {
var macro_value = $("<div />")
.html(macro["value"])
.text();
var macro_hide = macro["hide"];
macro_value.type = "password";
@ -809,6 +808,7 @@ function add_macro_field(macro, row_model_id) {
// Change attributes to be unique and with identificable class
$macro_field.attr("id", row_id);
$macro_field.attr("class", "macro_field");
// Get the number of fields already printed
@ -828,6 +828,19 @@ function add_macro_field(macro, row_model_id) {
);
}
// Only for create module type plugin need rename
// td id "simple-macro_field" + k + "-1" is horrible.
if (k) {
$("#" + row_model_id + "_field" + k + "_ td:eq(0)").attr(
"id",
"simple-macro_field" + k + "-0"
);
$("#" + row_model_id + "_field" + k + "_ td:eq(1)").attr(
"id",
"simple-macro_field" + k + "-1"
);
}
// Change the label
if (macro_help == "") {
$("#" + row_id)
@ -850,16 +863,29 @@ function add_macro_field(macro, row_model_id) {
}
// Change the text box id and value
$("#" + row_id)
.children()
.eq(1)
.attr("id", "text-" + macro_macro);
$("#" + row_id)
.children()
.eq(1)
.attr("name", macro_macro);
if (type_copy == "td") {
$("#" + row_id)
.children()
.eq(1)
.children()
.attr("id", "text-" + macro_macro);
$("#" + row_id)
.children()
.eq(1)
.children()
.attr("name", macro_macro);
} else {
$("#" + row_id)
.children()
.eq(1)
.attr("id", "text-" + macro_macro);
$("#" + row_id)
.children()
.eq(1)
.attr("name", macro_macro);
}
macro_field_hide = false;
var macro_field_hide = false;
if (typeof macro["hide"] == "string") {
if (macro["hide"].length == 0) {
macro_field_hide = false;
@ -872,16 +898,33 @@ function add_macro_field(macro, row_model_id) {
}
}
if (macro_field_hide) {
$("#" + row_id)
.children()
.eq(1)
.attr("type", "password");
if (type_copy == "td") {
if (macro_field_hide) {
$("#" + row_id)
.children()
.eq(1)
.children()
.attr("type", "password");
} else {
$("#" + row_id)
.children()
.eq(1)
.children()
.val(macro_value);
}
} else {
if (macro_field_hide) {
$("#" + row_id)
.children()
.eq(1)
.attr("type", "password");
} else {
$("#" + row_id)
.children()
.eq(1)
.val(macro_value);
}
}
$("#" + row_id)
.children()
.eq(1)
.val(macro_value);
$("#" + row_id).show();
}
@ -908,7 +951,7 @@ function load_plugin_macros_fields(row_model_id) {
$("#hidden-macros").val(data["base64"]);
jQuery.each(data["array"], function(i, macro) {
if (macro["desc"] != "") {
add_macro_field(macro, row_model_id);
add_macro_field(macro, row_model_id, "td");
}
});
//Plugin text can be larger