Set a data limit in the forms of massive operations. TICKET: #1700

This commit is contained in:
mdtrooper 2015-02-04 11:18:34 +01:00
parent ae8d6d993c
commit ba0e54aebb
11 changed files with 195 additions and 74 deletions

View File

@ -37,7 +37,7 @@ if (is_ajax ()) {
return;
}
if(is_array($id_agents) && count($id_agents) == 1 && $id_agents[0] == '') {
if (is_array($id_agents) && count($id_agents) == 1 && $id_agents[0] == '') {
$id_agents = false;
}
@ -56,7 +56,7 @@ $recursion = get_parameter ('recursion');
$add = (bool) get_parameter_post ('add');
if ($add) {
if(empty($id_agents) || $id_agents[0] == 0)
if (empty($id_agents) || $id_agents[0] == 0)
ui_print_result_message (false, '', __('Could not be added').". ".__('No agents selected'));
else {
$actions = get_parameter ('action');
@ -76,9 +76,9 @@ if ($add) {
$options = array();
if($fires_min > 0)
if ($fires_min > 0)
$options['fires_min'] = $fires_min;
if($fires_max > 0)
if ($fires_max > 0)
$options['fires_max'] = $fires_max;
if (empty($agent_alerts_id)) {
@ -87,9 +87,9 @@ if ($add) {
else {
$results = true;
foreach ($agent_alerts_id as $agent_alert_id) {
foreach($actions as $action) {
foreach ($actions as $action) {
$result = alerts_add_alert_agent_module_action($agent_alert_id, $action, $options);
if($result === false)
if ($result === false)
$results = false;
}
}
@ -169,14 +169,14 @@ html_print_table ($table);
$sql = 'SELECT id_agente FROM tagente_modulo WHERE id_agente_modulo IN (SELECT id_agent_module FROM talert_template_modules)';
$agents_with_templates = db_get_all_rows_sql($sql);
$agents_with_templates_json = array();
foreach($agents_with_templates as $ag) {
foreach ($agents_with_templates as $ag) {
$agents_with_templates_json[] = $ag['id_agente'];
}
$agents_with_templates_json = json_encode($agents_with_templates_json);
echo "<input type='hidden' id='hidden-agents_with_templates' value='$agents_with_templates_json'>";
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
echo '<div class="action-buttons" style="width: '. $table->width . '" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
html_print_input_hidden ('add', 1);
html_print_submit_button (__('Add'), 'go', false, 'class="sub add"');
echo '</div>';
@ -189,7 +189,24 @@ ui_require_jquery_file ('pandora.controls');
?>
<script type="text/javascript">
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
$(document).ready (function () {
$("#form_alerts").submit(function() {
var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_alerts").serializeArray().length;
var count_parameters =
get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false;
}
});
update_alerts();
var recursion;

17
pandora_console/godmode/massive/massive_add_alerts.php Normal file → Executable file
View File

@ -205,7 +205,24 @@ ui_require_jquery_file ('pandora.controls');
<script type="text/javascript">
/* <![CDATA[ */
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
$(document).ready (function () {
$("#form_alerts").submit(function() {
var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_alerts").serializeArray().length;
var count_parameters =
get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false;
}
});
$("#checkbox-recursion").click(function () {
$("#id_group").trigger("change");
});

View File

@ -38,6 +38,8 @@ $destiny_recursion = get_parameter ('destiny_recursion');
$do_operation = (bool) get_parameter ('do_operation');
if ($do_operation) {
$result = agents_process_manage_config($source_id_agent,
$destiny_id_agents);
@ -92,12 +94,20 @@ $agents = ( $source_id_group ?
agents_get_group_agents (array_keys (users_get_groups ($config["id_user"], "AW", false))) );
$table->data[0][7] = html_print_select ($agents, 'source_id_agent', $source_id_agent, false, __('Select'), 0, true);
echo '<form action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=copy_modules" id="manage_config_form" method="post">';
echo '<form ' .
'action="index.php?' .
'sec=gmassive&' .
'sec2=godmode/massive/massive_operations&' .
'option=copy_modules" ' .
'id="manage_config_form" ' .
'method="post">';
echo '<fieldset id="fieldset_source">';
echo '<legend><span>'.__('Source');
ui_print_help_icon ('manageconfig');
echo '</span></legend>';
echo '<legend>';
echo '<span>' .
__('Source') . ui_print_help_icon('manageconfig', true) .
'</span>';
echo '</legend>';
html_print_table ($table);
echo '</fieldset>';
@ -166,12 +176,14 @@ $table->size[0] = '20%';
$table->size[1] = '30%';
$table->size[2] = '20%';
$table->size[3] = '30%';
$table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select_groups(false, "AW", true, 'destiny_id_group',
$destiny_id_group, false, '', '', true);
$table->data[0][2] = __('Group recursion');
$table->data[0][3] = html_print_checkbox ("destiny_recursion", 1,
$destiny_recursion, true, false);
$status_list = array ();
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
$status_list[AGENT_STATUS_WARNING] = __('Warning');
@ -182,6 +194,7 @@ $status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
$table->data[1][0] = __('Status');
$table->data[1][1] = html_print_select($status_list,
'status_agents_destiny', 'selected', '', __('All'), AGENT_STATUS_ALL, true);
$table->data[2][0] = __('Agent');
$table->data[2][0] .= '<span id="destiny_agent_loading" class="invisible">';
$table->data[2][0] .= html_print_image ("images/spinner.png", true);
@ -204,6 +217,7 @@ html_print_table ($table);
echo '</fieldset>';
echo '<div class="action-buttons" style="width: ' . $table->width . '">';
html_print_input_hidden ('do_operation', 1);
html_print_submit_button (__('Copy'), 'go', false, 'class="sub wand"');
echo '</div>';
@ -219,6 +233,9 @@ ui_require_jquery_file ('pandora.controls');
<script type="text/javascript">
/* <![CDATA[ */
var module_alerts;
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
$(document).ready (function () {
var source_recursion;
$("#checkbox-source_recursion").click(function () {
@ -394,7 +411,23 @@ $(document).ready (function () {
});
$("#manage_config_form").submit (function () {
var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#manage_config_form").serializeArray().length;
var count_parameters =
get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false;
}
$("h3:not([id=message])").remove ();
if ($("#source_id_agent").attr ("value") == 0) {
$("#message").showMessage ("<?php echo __('No source agent to copy') ?>");
return false;
@ -419,6 +452,7 @@ $(document).ready (function () {
}
$("#message").hide ();
return true;
});
});

View File

@ -143,7 +143,24 @@ ui_require_jquery_file ('pandora.controls');
?>
<script type="text/javascript">
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
$(document).ready (function () {
$("#form_agents").submit(function() {
var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_agents").serializeArray().length;
var count_parameters =
get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false;
}
});
var recursion;
$("#checkbox-recursion").click(function () {

View File

@ -248,7 +248,25 @@ ui_require_jquery_file ('pandora.controls');
<script type="text/javascript">
/* <![CDATA[ */
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
$(document).ready (function () {
$("#form_alerts").submit(function() {
var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_alerts").serializeArray().length;
var count_parameters =
get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false;
}
});
$("#id_agents").change(agent_changed_by_multiple_agents_with_alerts);
$("#id_alert_template").change (function () {

View File

@ -372,6 +372,9 @@ else {
<script type="text/javascript">
/* <![CDATA[ */
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
$(document).ready (function () {
$("#id_agents").change(agent_changed_by_multiple_agents);
$("#module_name").change(module_changed_by_multiple_modules);
@ -542,6 +545,20 @@ $(document).ready (function () {
$("#status_agents").change(function() {
$("#groups_select").trigger("change");
});
$("#form_modules").submit(function() {
var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_modules").serializeArray().length;
var count_parameters =
get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false;
}
});
});
/* ]]> */
</script>

49
pandora_console/godmode/massive/massive_edit_agents.php Normal file → Executable file
View File

@ -404,8 +404,7 @@ foreach ($fields as $field) {
$custom_value = '';
}
$data[1] = html_print_textarea ('customvalue_' . $field['id_field'],
2, 65, $custom_value, 'style="min-height: 30px;"', true);
$data[1] = html_print_textarea ('customvalue_'.$field['id_field'], 2, 65, $custom_value, 'style="min-height: 30px;"', true);
array_push ($table->data, $data);
}
@ -434,14 +433,30 @@ ui_require_jquery_file ('pandora.controls');
ui_require_jquery_file ('pandora.controls');
ui_require_jquery_file ('ajaxqueue');
ui_require_jquery_file ('bgiframe');
ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
?>
<script type="text/javascript">
/* <![CDATA[ */
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
//Use this function for change 3 icons when change the selectbox
$(document).ready (function () {
$("#form_agent").submit(function() {
var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_agent").serializeArray().length;
var count_parameters =
get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false;
}
});
$("#id_agents").change (function () {
var idAgents = Array();
jQuery.each ($("#id_agents option:selected"), function (i, val) {
@ -533,29 +548,7 @@ function changeIcons() {
$("#icon_bad").attr("style", "");
$("#icon_warning").attr("style", "");
}
//$("#icon_default").attr("src", "<?php echo $path; ?>" + icon +
}
$(document).ready(function() {
tinyMCE.init({
mode : "exact",
elements: <?php
$elements = array('description');
foreach ($fields as $field) {
$elements[] = 'customvalue_' . $field['id_field'];
}
echo '"' . implode(', ', $elements) . '"';
?>,
width: 300,
theme : "advanced",
theme_advanced_path : false,
statusbar : false,
plugins: "bbcode",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1 : "undo, redo, | , link, unlink"
});
});
</script>

View File

@ -524,7 +524,9 @@ $table->data['edit11'][3] = html_print_input_text(
ui_print_help_tip (
__('Seconds that agent will wait for the execution of the module.'), true);
echo '<form method="post" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=edit_modules" id="form_edit">';
echo '<form method="post" ' .
'action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=edit_modules" ' .
'id="form_edit">';
html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
@ -551,7 +553,24 @@ else {
<script type="text/javascript">
/* <![CDATA[ */
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
$(document).ready (function () {
$("#form_edit").submit(function() {
var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_edit").serializeArray().length;
var count_parameters =
get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false;
}
});
$("#id_agents").change(agent_changed_by_multiple_agents);
$("#module_name").change(module_changed_by_multiple_modules);

43
pandora_console/godmode/massive/massive_operations.php Normal file → Executable file
View File

@ -40,11 +40,6 @@ $options_alerts = array(
'enable_disable_alerts' => __('Massive alert enable/disable'),
'standby_alerts' => __('Massive alert setting standby'));
$options_tags = array(
'add_tags' => __('Massive tags addition'),
'delete_tags' => __('Massive tags deletion')
);
$options_agents = array(
'edit_agents' => __('Massive agents edition'),
'delete_agents' => __('Massive agents deletion'));
@ -94,9 +89,6 @@ if ($satellite_options != ENTERPRISE_NOT_HOOK) {
if (in_array($option, array_keys($options_alerts))) {
$tab = 'massive_alerts';
}
elseif (in_array($option, array_keys($options_tags))) {
$tab = 'massive_tags';
}
elseif (in_array($option, array_keys($options_agents))) {
$tab = 'massive_agents';
}
@ -120,9 +112,6 @@ else {
}
switch ($tab) {
case 'massive_tags':
$options = $options_tags;
break;
case 'massive_alerts':
$options = $options_alerts;
break;
@ -151,29 +140,24 @@ if ($option == '') {
$option = array_shift(array_keys($options));
}
$tagstab = array('text' =>
'<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_tags">' .
html_print_image ('images/tag.png', true,
array('title' => __('Tags operations'))) . '</a>',
'active' => $tab == 'massive_tags');
$alertstab = array('text' =>
'<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_alerts">' .
html_print_image ('images/op_alerts.png', true,
array('title' => __('Alerts operations'))) . '</a>',
'active' => $tab == 'massive_alerts');
$alertstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_alerts">'
. html_print_image ('images/op_alerts.png', true,
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">'
. html_print_image ('images/op_workspace.png', true, array ('title' => __('Users operations')))
. html_print_image ('images/op_workspace.png', true,
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">'
. html_print_image ('images/bricks.png', true, array ('title' => __('Agents operations')))
. html_print_image ('images/bricks.png', true,
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">'
. html_print_image ('images/brick.png', true, array ('title' => __('Modules operations')))
. html_print_image ('images/brick.png', true,
array ('title' => __('Modules operations')))
. '</a>', 'active' => $tab == 'massive_modules');
@ -200,7 +184,6 @@ $onheader['massive_modules'] = $modulestab;
if (check_acl ($config['id_user'], 0, "PM")) {
$onheader['user_agents'] = $userstab;
}
$onheader['massive_tags'] = $tagstab;
$onheader['massive_alerts'] = $alertstab;
$onheader['policies'] = $policiestab;
$onheader['snmp'] = $snmptab;
@ -313,12 +296,6 @@ switch ($option) {
case 'copy_modules':
require_once ('godmode/massive/massive_copy_modules.php');
break;
case 'add_tags':
require_once ('godmode/massive/massive_add_tags.php');
break;
case 'delete_tags':
require_once ('godmode/massive/massive_delete_tags.php');
break;
default:
if (!enterprise_hook('massive_operations', array($option))) {
require_once ('godmode/massive/massive_config.php');

View File

@ -259,6 +259,12 @@ $table->data[33][0] = __('Allow create planned downtimes in the past') .
$table->data[33][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('past_planned_downtimes', 1, '', $config["past_planned_downtimes"], true).'&nbsp;&nbsp;';
$table->data[33][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('past_planned_downtimes', 0, '', $config["past_planned_downtimes"], true);
$table->data[34][0] = __('Limit parameters massive') .
ui_print_help_tip(__('Your PHP environment is setted with %d max_input_vars. Maybe you must not set this value with upper values.', ini_get("max_input_vars")), true);
$table->data[34][1] = html_print_input_text('limit_parameters_massive',
$config['limit_parameters_massive'], '', 10, 10, true);
echo '<form id="form_setup" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=general&amp;pure='.$config['pure'].'">';
echo "<fieldset>";

View File

@ -186,6 +186,8 @@ function config_update_config () {
$error_update[] = __('Tutorial mode');
if (!config_update_value ('past_planned_downtimes', get_parameter('past_planned_downtimes')))
$error_update[] = __('Allow create planned downtimes in the past');
if (!config_update_value ('limit_parameters_massive', get_parameter('limit_parameters_massive')))
$error_update[] = __('Limit parameters massive');
break;
case 'enterprise':
if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) {
@ -773,6 +775,10 @@ function config_process_config () {
config_update_value ('font_size', 6);
}
if (!isset ($config["limit_parameters_massive"])) {
config_update_value ('limit_parameters_massive', ini_get("max_input_vars") / 2);
}
/*
*Parse the ACL IP list for access API
*/