11094-Fix plugin data recovery

This commit is contained in:
Pablo Aragon 2023-05-16 16:00:17 +02:00
parent a6212c2777
commit f4cf8e769a
3 changed files with 33 additions and 3 deletions

View File

@ -146,10 +146,12 @@ foreach ($password_fields as $k => $p) {
return;
}
const moduleId = <?php echo $id_agent_module; ?>;
load_plugin_description($("#id_plugin").val());
load_plugin_macros_fields('simple-macro');
load_plugin_macros_fields('simple-macro', moduleId);
forced_title_callback();

View File

@ -38,6 +38,7 @@ if (check_login()) {
enterprise_include_once('include/functions_metaconsole.php');
$get_plugin_macros = get_parameter('get_plugin_macros');
$get_module_macros = get_parameter('get_module_macros');
$search_modules = get_parameter('search_modules');
$get_module_detail = get_parameter('get_module_detail', 0);
$get_module_autocomplete_input = (bool) get_parameter(
@ -118,6 +119,28 @@ if (check_login()) {
return;
}
if ($get_module_macros && $get_module_macros > 0) {
if (https_is_running()) {
header('Content-type: application/json');
}
$module_id = $get_module_macros;
$module_macros = db_get_value(
'macros',
'tagente_modulo',
'id_agente_modulo',
$module_id
);
$macros = [];
$macros['base64'] = base64_encode($module_macros);
$macros['array'] = json_decode($module_macros, true);
echo json_encode($macros);
return;
}
if ($search_modules) {
if (https_is_running()) {
header('Content-type: application/json');

View File

@ -997,13 +997,18 @@ function add_macro_field(macro, row_model_id, type_copy, k) {
$("#" + row_id).show();
}
function load_plugin_macros_fields(row_model_id) {
function load_plugin_macros_fields(row_model_id, moduleId = 0) {
// Get plugin macros when selected and load macros fields
var id_plugin = $("#id_plugin").val();
var params = [];
params.push("page=include/ajax/module");
params.push("get_plugin_macros=1");
if (moduleId > 0) {
params.push("get_module_macros=" + moduleId);
} else {
params.push("get_plugin_macros=1");
}
params.push("id_plugin=" + id_plugin);
jQuery.ajax({