Fixed the masive operations for modules when the name has white spaces. TICKET: #2328

(cherry picked from commit 737e085a81215566319484897f3b501c53fd7c43)
This commit is contained in:
mdtrooper 2015-06-23 12:15:09 +02:00
parent 4f9f8d2449
commit 8b518ae9b2
2 changed files with 97 additions and 51 deletions

View File

@ -112,7 +112,8 @@ if ($update) {
$module_name = array(); $module_name = array();
} }
foreach($module_name as $mod_name) { foreach($module_name as $mod_name) {
$result = process_manage_edit($mod_name['nombre'], $id_agent); $result = process_manage_edit($mod_name['nombre'],
$id_agent);
$count ++; $count ++;
$success += (int)$result; $success += (int)$result;
} }
@ -123,6 +124,8 @@ if ($update) {
$agents_ = array(); $agents_ = array();
} }
foreach ($agents_ as $agent_) { foreach ($agents_ as $agent_) {
if ($modules_ == false) { if ($modules_ == false) {
@ -141,12 +144,15 @@ if ($update) {
"(" . $success . "/" . $count . ")", "(" . $success . "/" . $count . ")",
__('Could not be updated')); __('Could not be updated'));
$info = 'Modules: ' . json_encode($modules_) . ' Agents: ' . json_encode($agents_); $info = 'Modules: ' . json_encode($modules_) .
' Agents: ' . json_encode($agents_);
if ($success > 0) { if ($success > 0) {
db_pandora_audit("Massive management", "Edit module", false, false, $info); db_pandora_audit("Massive management", "Edit module", false,
false, $info);
} }
else { else {
db_pandora_audit("Massive management", "Fail try to edit module", false, false, $info); db_pandora_audit("Massive management",
"Fail try to edit module", false, false, $info);
} }
} }
@ -173,7 +179,8 @@ if (! $module_type) {
$table->rowstyle['edit6'] = 'display: none'; $table->rowstyle['edit6'] = 'display: none';
$table->rowstyle['edit7'] = 'display: none'; $table->rowstyle['edit7'] = 'display: none';
} }
$agents = agents_get_group_agents (array_keys (users_get_groups ()), false, "none"); $agents = agents_get_group_agents (array_keys (users_get_groups ()),
false, "none");
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
case "oracle": case "oracle":
@ -216,10 +223,12 @@ $table->data = array ();
$table->data['selection_mode'][0] = __('Selection mode'); $table->data['selection_mode'][0] = __('Selection mode');
$table->data['selection_mode'][1] = __('Select modules first') . ' ' . $table->data['selection_mode'][1] = __('Select modules first') . ' ' .
html_print_radio_button_extended ("selection_mode", 'modules', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true); html_print_radio_button_extended ("selection_mode", 'modules', '',
$selection_mode, false, '', 'style="margin-right: 40px;"', true);
$table->data['selection_mode'][2] = ''; $table->data['selection_mode'][2] = '';
$table->data['selection_mode'][3] = __('Select agents first') . ' ' . $table->data['selection_mode'][3] = __('Select agents first') . ' ' .
html_print_radio_button_extended ("selection_mode", 'agents', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true); html_print_radio_button_extended ("selection_mode", 'agents', '',
$selection_mode, false, '', 'style="margin-right: 40px;"', true);
@ -235,7 +244,8 @@ $table->data['form_modules_1'][1] = html_print_select ($types,
'module_type', '', false, __('Select'), -1, true, false, true); 'module_type', '', false, __('Select'), -1, true, false, true);
$table->data['form_modules_1'][3] = __('Select all modules of this type') . ' ' . $table->data['form_modules_1'][3] = __('Select all modules of this type') . ' ' .
html_print_checkbox_extended ("force_type", 'type', '', '', false, '', 'style="margin-right: 40px;"', true); html_print_checkbox_extended ("force_type", 'type', '', '', false,
'', 'style="margin-right: 40px;"', true);
$modules = array (); $modules = array ();
if ($module_type != '') { if ($module_type != '') {
@ -263,7 +273,8 @@ $table->data['form_agents_1'][1] = html_print_select ($groups, 'groups_select',
' ' . __('Group recursion') . ' ' . ' ' . __('Group recursion') . ' ' .
html_print_checkbox ("recursion", 1, false, true, false); html_print_checkbox ("recursion", 1, false, true, false);
$table->data['form_agents_1'][3] = __('Select all modules of this group') . ' ' . $table->data['form_agents_1'][3] = __('Select all modules of this group') . ' ' .
html_print_checkbox_extended ("force_group", 'group', '', '', false, '', 'style="margin-right: 40px;"', true); html_print_checkbox_extended ("force_group", 'group', '', '', false,
'', 'style="margin-right: 40px;"', true);
@ -327,8 +338,8 @@ $table->data['edit1'][1] = '<table width="100%">';
$table->data['edit1'][1] .= '<em>' . __('Min.') . '</em>'; $table->data['edit1'][1] .= '<em>' . __('Min.') . '</em>';
$table->data['edit1'][1] .= '</td>'; $table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '<td align="right">'; $table->data['edit1'][1] .= '<td align="right">';
$table->data['edit1'][1] .= html_print_input_text('min_warning', $table->data['edit1'][1] .= html_print_input_text(
'', '', 5, 15, true); 'min_warning', '', '', 5, 15, true);
$table->data['edit1'][1] .= '</td>'; $table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '</tr>'; $table->data['edit1'][1] .= '</tr>';
$table->data['edit1'][1] .= '<tr>'; $table->data['edit1'][1] .= '<tr>';
@ -336,25 +347,29 @@ $table->data['edit1'][1] = '<table width="100%">';
$table->data['edit1'][1] .= '<em>' . __('Max.') . '</em>'; $table->data['edit1'][1] .= '<em>' . __('Max.') . '</em>';
$table->data['edit1'][1] .= '</td>'; $table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '<td align="right">'; $table->data['edit1'][1] .= '<td align="right">';
$table->data['edit1'][1] .= html_print_input_text ('max_warning', '', '', 5, 15, true); $table->data['edit1'][1] .= html_print_input_text (
'max_warning', '', '', 5, 15, true);
$table->data['edit1'][1] .= '</td>'; $table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '</tr>'; $table->data['edit1'][1] .= '</tr>';
$table->data['edit1'][1] .= '<tr>'; $table->data['edit1'][1] .= '<tr>';
$table->data['edit1'][1] .= '<td>'; $table->data['edit1'][1] .= '<td>';
$table->data['edit1'][1] .= '<em>'.__('Str.').'</em>'; $table->data['edit1'][1] .= '<em>' . __('Str.') . '</em>';
$table->data['edit1'][1] .= '</td>'; $table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '<td align="right">'; $table->data['edit1'][1] .= '<td align="right">';
$table->data['edit1'][1] .= html_print_input_text ('str_warning', '', '', 5, 15, true); $table->data['edit1'][1] .= html_print_input_text (
'str_warning', '', '', 5, 15, true);
$table->data['edit1'][1] .= '</td>'; $table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '</tr>'; $table->data['edit1'][1] .= '</tr>';
$table->data['edit1'][1] .= '<tr>'; $table->data['edit1'][1] .= '<tr>';
$table->data['edit1'][1] .= '<td>'; $table->data['edit1'][1] .= '<td>';
$table->data['edit1'][1] .= '<em>'.__('Inverse interval').'</em>'; $table->data['edit1'][1] .= '<em>' .
__('Inverse interval') . '</em>';
$table->data['edit1'][1] .= '</td>'; $table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '<td align="right">'; $table->data['edit1'][1] .= '<td align="right">';
$table->data['edit1'][1] .= $table->data['edit1'][1] .=
html_print_select( html_print_select(
array('' => __('No change'), array(
'' => __('No change'),
'1' => __('Yes'), '1' => __('Yes'),
'0' => __('No')), '0' => __('No')),
'warning_inverse','','','', '', true); 'warning_inverse','','','', '', true);
@ -369,8 +384,8 @@ $table->data['edit1'][3] = '<table width="100%">';
$table->data['edit1'][3] .= '<em>' . __('Min.') . '</em>'; $table->data['edit1'][3] .= '<em>' . __('Min.') . '</em>';
$table->data['edit1'][3] .= '</td>'; $table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '<td align="right">'; $table->data['edit1'][3] .= '<td align="right">';
$table->data['edit1'][3] .= html_print_input_text('min_critical', $table->data['edit1'][3] .= html_print_input_text(
'', '', 5, 15, true); 'min_critical', '', '', 5, 15, true);
$table->data['edit1'][3] .= '</td>'; $table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '</tr>'; $table->data['edit1'][3] .= '</tr>';
$table->data['edit1'][3] .= '<tr>'; $table->data['edit1'][3] .= '<tr>';
@ -378,7 +393,8 @@ $table->data['edit1'][3] = '<table width="100%">';
$table->data['edit1'][3] .= '<em>' . __('Max.') . '</em>'; $table->data['edit1'][3] .= '<em>' . __('Max.') . '</em>';
$table->data['edit1'][3] .= '</td>'; $table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '<td align="right">'; $table->data['edit1'][3] .= '<td align="right">';
$table->data['edit1'][3] .= html_print_input_text ('max_critical', '', '', 5, 15, true); $table->data['edit1'][3] .= html_print_input_text(
'max_critical', '', '', 5, 15, true);
$table->data['edit1'][3] .= '</td>'; $table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '</tr>'; $table->data['edit1'][3] .= '</tr>';
$table->data['edit1'][3] .= '<tr>'; $table->data['edit1'][3] .= '<tr>';
@ -386,12 +402,14 @@ $table->data['edit1'][3] = '<table width="100%">';
$table->data['edit1'][3] .= '<em>'.__('Str.').'</em>'; $table->data['edit1'][3] .= '<em>'.__('Str.').'</em>';
$table->data['edit1'][3] .= '</td>'; $table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '<td align="right">'; $table->data['edit1'][3] .= '<td align="right">';
$table->data['edit1'][3] .= html_print_input_text ('str_critical', '', '', 5, 15, true); $table->data['edit1'][3] .= html_print_input_text(
'str_critical', '', '', 5, 15, true);
$table->data['edit1'][3] .= '</td>'; $table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '</tr>'; $table->data['edit1'][3] .= '</tr>';
$table->data['edit1'][3] .= '<tr>'; $table->data['edit1'][3] .= '<tr>';
$table->data['edit1'][3] .= '<td>'; $table->data['edit1'][3] .= '<td>';
$table->data['edit1'][3] .= '<em>'.__('Inverse interval').'</em>'; $table->data['edit1'][3] .= '<em>' .
__('Inverse interval') . '</em>';
$table->data['edit1'][3] .= '</td>'; $table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '<td align="right">'; $table->data['edit1'][3] .= '<td align="right">';
$table->data['edit1'][3] .= $table->data['edit1'][3] .=
@ -405,27 +423,40 @@ $table->data['edit1'][3] = '<table width="100%">';
$table->data['edit1'][3] .= '</table>'; $table->data['edit1'][3] .= '</table>';
$table->data['edit1_1'][0] = '<b>'.__('Description'). '</b>'; $table->data['edit1_1'][0] = '<b>'.__('Description'). '</b>';
$table->data['edit1_1'][1] = html_print_textarea ('descripcion', 2, 50, '', '', true); $table->data['edit1_1'][1] = html_print_textarea ('descripcion', 2, 50,
'', '', true);
$table->colspan['edit1_1'][1] = 3; $table->colspan['edit1_1'][1] = 3;
$table->data['edit2'][0] = __('Interval'); $table->data['edit2'][0] = __('Interval');
$table->data['edit2'][1] = html_print_extended_select_for_time ('module_interval', 0, '', __('No change'), '0', 10, true, 'width: 150px'); $table->data['edit2'][1] = html_print_extended_select_for_time(
'module_interval', 0, '', __('No change'), '0', 10, true, 'width: 150px');
$table->data['edit2'][2] = __('Disabled'); $table->data['edit2'][2] = __('Disabled');
$table->data['edit2'][3] = html_print_select(array('' => __('No change'), '1' => __('Yes'), '0' => __('No')),'disabled','','','', '', true); $table->data['edit2'][3] = html_print_select(
array(
'' => __('No change'),
'1' => __('Yes'),
'0' => __('No')),
'disabled', '', '', '', '', true);
$table->data['edit3'][0] = __('Post process') . $table->data['edit3'][0] = __('Post process') .
ui_print_help_icon ('postprocess', true); ui_print_help_icon ('postprocess', true);
$table->data['edit3'][1] = html_print_input_text ('post_process', '', '', 10, 15, true); $table->data['edit3'][1] = html_print_input_text ('post_process', '',
'', 10, 15, true);
$table->data['edit3'][2] = __('SMNP community'); $table->data['edit3'][2] = __('SMNP community');
$table->data['edit3'][3] = html_print_input_text ('snmp_community', '', '', 10, 15, true); $table->data['edit3'][3] = html_print_input_text ('snmp_community', '',
'', 10, 15, true);
$table->data['edit35'][0] = __('Target IP'); $table->data['edit35'][0] = __('Target IP');
$table->data['edit35'][1] = html_print_input_text ('ip_target', '', '', 15, 60, true); $table->data['edit35'][1] = html_print_input_text ('ip_target', '', '',
15, 60, true);
$table->data['edit35'][2] = __('SNMP version'); $table->data['edit35'][2] = __('SNMP version');
$table->data['edit35'][3] = html_print_select ($snmp_versions, 'tcp_send', '', '', __('No change'), '', true, false, false, ''); $table->data['edit35'][3] = html_print_select ($snmp_versions,
'tcp_send', '', '', __('No change'), '', true, false, false, '');
$table->data['edit36'][0] = __('Auth user'); $table->data['edit36'][0] = __('Auth user');
$table->data['edit36'][1] = html_print_input_text ('plugin_user_snmp', '', '', 15, 60, true); $table->data['edit36'][1] = html_print_input_text ('plugin_user_snmp',
$table->data['edit36'][2] = __('Auth password') . ui_print_help_tip(__("The pass length must be eight character minimum."), true); '', '', 15, 60, true);
$table->data['edit36'][2] = __('Auth password') .
ui_print_help_tip(__("The pass length must be eight character minimum."), true);
$table->data['edit36'][3] = html_print_input_text ('plugin_pass_snmp', '', '', 15, 60, true); $table->data['edit36'][3] = html_print_input_text ('plugin_pass_snmp', '', '', 15, 60, true);
$table->data['edit37'][0] = __('Privacy method'); $table->data['edit37'][0] = __('Privacy method');
$table->data['edit37'][1] = html_print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'custom_string_1', '', '', __('No change'), '', true); $table->data['edit37'][1] = html_print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'custom_string_1', '', '', __('No change'), '', true);
@ -922,6 +953,7 @@ $(document).ready (function () {
</script> </script>
<?php <?php
function process_manage_edit ($module_name, $agents_select = null) { function process_manage_edit ($module_name, $agents_select = null) {
if (is_int ($module_name) && $module_name < 0) { if (is_int ($module_name) && $module_name < 0) {
ui_print_error_message(__('No modules selected')); ui_print_error_message(__('No modules selected'));
@ -1026,7 +1058,7 @@ function process_manage_edit ($module_name, $agents_select = null) {
else { else {
$modules = db_get_all_rows_filter ('tagente_modulo', $modules = db_get_all_rows_filter ('tagente_modulo',
array ('id_agente' => $agents_select, array ('id_agente' => $agents_select,
'nombre' => io_safe_input($module_name)), 'nombre' => $module_name),
array ('id_agente_modulo')); array ('id_agente_modulo'));
} }
} }

View File

@ -140,25 +140,33 @@ if ($option == '') {
$option = array_shift(array_keys($options)); $option = array_shift(array_keys($options));
} }
$alertstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_alerts">' $alertstab = array(
. html_print_image ('images/op_alerts.png', true, 'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_alerts">'
array ('title' => __('Alerts operations'))) . html_print_image ('images/op_alerts.png', true,
. '</a>', 'active' => $tab == 'massive_alerts'); array ('title' => __('Alerts operations')))
. '</a>',
'active' => $tab == 'massive_alerts');
$userstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users">' $userstab = array(
. html_print_image ('images/op_workspace.png', true, 'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users">'
array ('title' => __('Users operations'))) . html_print_image ('images/op_workspace.png', true,
. '</a>', 'active' => $tab == 'massive_users'); array ('title' => __('Users operations')))
. '</a>',
'active' => $tab == 'massive_users');
$agentstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_agents">' $agentstab = array(
. html_print_image ('images/bricks.png', true, 'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_agents">'
array ('title' => __('Agents operations'))) . html_print_image ('images/bricks.png', true,
. '</a>', 'active' => $tab == 'massive_agents'); array ('title' => __('Agents operations')))
. '</a>',
'active' => $tab == 'massive_agents');
$modulestab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_modules">' $modulestab = array(
. html_print_image ('images/brick.png', true, 'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_modules">'
array ('title' => __('Modules operations'))) . html_print_image ('images/brick.png', true,
. '</a>', 'active' => $tab == 'massive_modules'); array ('title' => __('Modules operations')))
. '</a>',
'active' => $tab == 'massive_modules');
@ -213,7 +221,8 @@ $submit_template_standby = get_parameter('id_alert_template_standby');
$submit_add = get_parameter('crtbutton'); $submit_add = get_parameter('crtbutton');
echo '<div id="loading" display="none">'; echo '<div id="loading" display="none">';
echo html_print_image("images/wait.gif", true, array("border" => '0')) . '<br />'; echo html_print_image("images/wait.gif", true, array("border" => '0')) .
'<br />';
echo '<strong>' . __('Please wait...') . '</strong>'; echo '<strong>' . __('Please wait...') . '</strong>';
echo '</div>'; echo '</div>';
?> ?>
@ -245,14 +254,19 @@ echo '</div>';
<?php <?php
echo "<br />"; echo "<br />";
echo '<form method="post" id="form_options" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations">'; echo '<form method="post" id="form_options" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations">';
echo '<table border="0"><tr><td>'; echo '<table border="0">';
echo '<tr>';
echo '<td>';
echo __("Action"); echo __("Action");
echo '</td><td>'; echo '</td>';
echo '<td>';
html_print_select($options, 'option', $option, 'this.form.submit()', '', html_print_select($options, 'option', $option, 'this.form.submit()', '',
0, false, false, false); 0, false, false, false);
if ($option == 'edit_agents' || $option == 'edit_modules') if ($option == 'edit_agents' || $option == 'edit_modules')
ui_print_help_tip(__("The blank fields will not be updated")); ui_print_help_tip(__("The blank fields will not be updated"));
echo '</td></tr></table>'; echo '</td>';
echo '</tr>';
echo '</table>';
echo '</form>'; echo '</form>';
echo "<br />"; echo "<br />";