disallow editing module type

This commit is contained in:
alejandro.campos@artica.es 2024-02-27 09:11:28 +01:00
parent f8e2cbd7e0
commit 85794418e2
2 changed files with 16 additions and 7 deletions

View File

@ -1499,6 +1499,7 @@ if ($update_module === true || $create_module === true) {
$old_configuration_data = (string) get_parameter('old_configuration_data');
$new_configuration_data = '';
$custom_string_1_default = '';
$custom_string_2_default = '';
$custom_string_3_default = '';
@ -1964,6 +1965,19 @@ if ($update_module) {
}
}
$def_msg = __('There was a problem updating module. Processing error');
if (preg_match('/module_type\s+([^\\n]+)/', io_safe_output($configuration_data), $matches)) {
$config_module_type = $matches[1];
$type_id = (int) db_get_value('id_tipo', 'ttipo_modulo', 'nombre', $config_module_type);
if ($type_id !== $id_module_type) {
$def_msg = __('There was a problem updating module: module type cannot be edited');
$result = ERR_GENERIC;
}
}
if (is_error($result) === true) {
switch ($result) {
case ERR_EXIST:
@ -1981,7 +1995,7 @@ if ($update_module) {
case ERR_DB:
case ERR_GENERIC:
default:
$msg = __('There was a problem updating module. Processing error');
$msg = $def_msg;
break;
}

View File

@ -657,12 +657,7 @@ sub process_xml_data ($$$$$) {
# Unnamed module
next if ($module_name eq '');
# Read module type from db when module exists within it (skip XML read).
my $module_type = get_db_value ($dbh, 'SELECT ttm.nombre FROM ttipo_modulo ttm INNER JOIN tagente_modulo tam ON tam.id_tipo_modulo = ttm.id_tipo WHERE tam.id_agente = ' . $agent_id . ' AND tam.nombre' . ' = '. $RDBMS_QUOTE_STRING . safe_input($module_name) . $RDBMS_QUOTE_STRING);
if (!defined($module_type)) {
$module_type = get_tag_value ($module_data, 'type', 'generic_data');
}
my $module_type = get_tag_value ($module_data, 'type', 'generic_data');
# Apply timezone offset to module if timestamp is set.
if (defined($module_data->{'timestamp'} && $module_data->{'timestamp'} ne '')) {