Fixed error to create a module plugin with cli. Ticket #2549

(cherry picked from commit 494420aa68)
This commit is contained in:
Arturo Gonzalez Diaz 2015-08-04 11:18:39 +02:00
parent 44835298fa
commit 09cce73c76
1 changed files with 23 additions and 2 deletions

View File

@ -1597,8 +1597,29 @@ sub cli_create_plugin_module($) {
$parameters{'id_plugin'} = $plugin_id;
$parameters{'plugin_user'} = $user;
$parameters{'plugin_pass'} = $password;
$parameters{'plugin_parameter'} = safe_input($params);
#$parameters{'plugin_parameter'} = safe_input($params);
my @user_params = split(/\s+/, $params);
my $plug_params = get_db_value ($dbh, 'SELECT macros FROM tplugin WHERE id =?', $plugin_id);
if ($plug_params eq undef) {
print "[ERROR] Error to create module\n\n";
help_screen();
}
my $decode_params = decode_json($plug_params);
my $user_params_size = scalar(@user_params);
foreach (my $i=1; $i <= $user_params_size; $i++){
$decode_params->{$i}->{'value'} = $user_params[$i-1];
}
my $p_params = encode_json($decode_params);
$parameters{'macros'} = $p_params;
# Optional parameters
$parameters{'id_module_group'} = $module_group_id unless !defined ($module_group);
$parameters{'min_warning'} = $warning_min unless !defined ($warning_min);