Merge branch 'ent-6169-10444-Bulk-Operations-sobre-modulo-SNMP-no-funciona' into 'develop'

fix snmp version update

See merge request artica/pandorafms!3426
This commit is contained in:
Daniel Rodriguez 2020-09-18 09:25:46 +02:00
commit 957eae39f7
1 changed files with 34 additions and 7 deletions

View File

@ -767,7 +767,7 @@ $table->data['edit1'][1] = '<table width="100%">';
$table->data['edit35'][2] = __('SNMP version'); $table->data['edit35'][2] = __('SNMP version');
$table->data['edit35'][3] = html_print_select( $table->data['edit35'][3] = html_print_select(
$snmp_versions, $snmp_versions,
'tcp_send', 'snmp_version',
'', '',
'', '',
__('No change'), __('No change'),
@ -1933,6 +1933,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
'command_text', 'command_text',
'command_credential_identifier', 'command_credential_identifier',
'command_os', 'command_os',
'snmp_version',
]; ];
$values = []; $values = [];
@ -2028,9 +2029,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
break; break;
case 'tcp_send2': case 'tcp_send2':
if ($value != '') { $tcp_send2 = $value;
$values['tcp_send'] = $value;
}
break; break;
case 'plugin_parameter_text': case 'plugin_parameter_text':
@ -2039,6 +2038,10 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
} }
break; break;
case 'snmp_version':
$snmp_version = $value;
break;
default: default:
if ($value != '') { if ($value != '') {
$values[$field] = $value; $values[$field] = $value;
@ -2096,7 +2099,10 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
$modules = db_get_all_rows_filter( $modules = db_get_all_rows_filter(
'tagente_modulo', 'tagente_modulo',
$filter_modules, $filter_modules,
['id_agente_modulo'] [
'id_agente_modulo',
'id_tipo_modulo',
]
); );
} else { } else {
if ($module_name == '0') { if ($module_name == '0') {
@ -2104,7 +2110,10 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
$modules = db_get_all_rows_filter( $modules = db_get_all_rows_filter(
'tagente_modulo', 'tagente_modulo',
['id_agente' => $agents_select], ['id_agente' => $agents_select],
['id_agente_modulo'] [
'id_agente_modulo',
'id_tipo_modulo',
]
); );
} else { } else {
$modules = db_get_all_rows_filter( $modules = db_get_all_rows_filter(
@ -2113,7 +2122,10 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
'id_agente' => $agents_select, 'id_agente' => $agents_select,
'nombre' => $module_name, 'nombre' => $module_name,
], ],
['id_agente_modulo'] [
'id_agente_modulo',
'id_tipo_modulo',
]
); );
} }
} }
@ -2137,6 +2149,21 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
} }
foreach ($modules as $module) { foreach ($modules as $module) {
// Set tcp_send value according to module type since the purpose of this field in database varies in case of SNMP modules.
if ($module['id_tipo_modulo'] >= 15 && $module['id_tipo_modulo'] <= 18) {
if ($snmp_version != '') {
$values['tcp_send'] = $snmp_version;
} else {
unset($values['tcp_send']);
}
} else {
if ($tcp_send2 != '') {
$values['tcp_send'] = $tcp_send2;
} else {
unset($values['tcp_send']);
}
}
$result = modules_update_agent_module( $result = modules_update_agent_module(
$module['id_agente_modulo'], $module['id_agente_modulo'],
$values, $values,