diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index dbf1d10bf6..24f3f8e86a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2010-09-29 Sergio Martin + + * include/javascript/jquery.pandora.controls.js + godmode/groups/group_list.php + godmode/massive/massive_operations.php + godmode/massive/massive_edit_agents.php: Added the massive + agent editor to the massive operations for pending task + #3057662 + 2010-09-29 Sergio Martin * godmode/agentes/fields_manager.php: Fixed the custom fields diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 447a4e58d2..5f8440e921 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -60,6 +60,7 @@ if (is_ajax ()) { if ($get_group_agents) { $id_group = (int) get_parameter ('id_group'); + $disabled = (int) get_parameter ('disabled', 0); if (! give_acl ($config['id_user'], $id_group, "AR")) { audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation", @@ -68,7 +69,7 @@ if (is_ajax ()) { return; } - echo json_encode (get_group_agents ($id_group, false, "none")); + echo json_encode (get_group_agents ($id_group, array('disabled' => $disabled), "none")); return; } diff --git a/pandora_console/godmode/massive/massive_edit_agents.php b/pandora_console/godmode/massive/massive_edit_agents.php new file mode 100644 index 0000000000..a5c3a6632e --- /dev/null +++ b/pandora_console/godmode/massive/massive_edit_agents.php @@ -0,0 +1,482 @@ + 0, + __('Configuration files deleted successfully').'('.$n_deleted.')', + __('Configuration files cannot be deleted')); + } + + if(empty($values) && empty($fields)){ + $id_agents = array(); + } + + $n_edited = 0; + $result = false; + foreach($id_agents as $id_agent) { + if(!empty($values)) { + $result = process_sql_update ('tagente', + $values, + array ('id_agente' => $id_agent)); + } + + // Update Custom Fields + foreach($fields as $field) { + if(get_parameter_post ('customvalue_'.$field['id_field'], '') != '') { + $key = $field['id_field']; + $value = get_parameter_post ('customvalue_'.$field['id_field'], ''); + + $old_value = get_db_all_rows_filter('tagent_custom_data', array('id_agent' => $id_agent, 'id_field' => $key)); + + if($old_value === false) { + // Create custom field if not exist + $result = process_sql_insert ('tagent_custom_data', + array('id_field' => $key,'id_agent' => $id_agent, 'description' => $value)); + }else { + $result = process_sql_update ('tagent_custom_data', + array('description' => $value), + array('id_field' => $key,'id_agent' => $id_agent)); + } + } + } + + $n_edited += (int)$result; + } + print_result_message ($n_edited > 0, + __('Agents updated successfully').'('.$n_edited.')', + __('Agents cannot be updated')); + +} +$id_group = 0; + +$groups = get_user_groups (); + +$table->id = 'delete_table'; +$table->width = '95%'; +$table->data = array (); +$table->style = array (); +$table->style[0] = 'font-weight: bold; vertical-align:top'; +$table->style[2] = 'font-weight: bold'; +$table->size = array (); +$table->size[0] = '15%'; +$table->size[1] = '85%'; + +$table->data = array (); +$table->data[0][0] = __('Group'); +$table->data[0][1] = print_select_groups(false, "AR", true, 'id_group', $id_group, + false, '', '', true); + +$table->data[1][0] = __('Agents'); +$table->data[1][0] .= ''; +$enabled_agents = get_group_agents ($id_group, array('disabled' => 0), "none"); +$all_agents = get_group_agents ($id_group, array('disabled' => 1), "none") + $enabled_agents; + +$table->data[1][1] = print_select ($all_agents, + 'id_agents[]', 0, false, '', '', true, true); + +echo '
'; +print_table ($table); + +$nombre_agente = ""; +$direccion_agente = ""; +$id_agente = 0; +$id_parent = 0; +$cascade_protection = 0; +$group = 0; +$interval = ''; +$id_os = 0; +$server_name = 0; +$description = ""; + +echo '
'; + +require_jquery_file ('form'); +require_jquery_file ('pandora.controls'); + + +require_jquery_file ('pandora.controls'); +require_jquery_file ('ajaxqueue'); +require_jquery_file ('bgiframe'); +require_jquery_file ('autocomplete'); +?> + diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index 0d5ac6dfaa..0177f929fe 100644 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.php @@ -36,7 +36,7 @@ $options_alerts = array('add_alerts' => __('Massive alerts addition'), 'delete_a 'add_action_alerts' => __('Massive alert actions addition'), 'delete_action_alerts' => __('Massive alert actions deletion'), 'enable_disable_alerts' => __('Massive alert enable/disable'), 'standby_alerts' => __('Massive alert setting standby')); -$options_agents = array('delete_agents' => __('Massive agents deletion')); +$options_agents = array('edit_agents' => __('Massive agents edition'), 'delete_agents' => __('Massive agents deletion')); $options_users = array('add_profiles' => __('Massive profiles addition'), 'delete_profiles' => __('Massive profiles deletion')); @@ -130,6 +130,8 @@ echo '
'; echo '

'.__('Massive options').':

'; echo '
'; print_select($options, 'option', $option, 'this.form.submit()', '', 0, false, false, false); +if($option == 'edit_agents') + echo ' ' . __("The blank fields will not be updated") . ''; echo '
'; echo ''; @@ -161,6 +163,9 @@ switch ($option) { case 'delete_agents': require_once ('godmode/massive/massive_delete_agents.php'); break; + case 'edit_agents': + require_once ('godmode/massive/massive_edit_agents.php'); + break; case 'delete_modules': require_once ('godmode/massive/massive_delete_modules.php'); break; diff --git a/pandora_console/include/javascript/jquery.pandora.controls.js b/pandora_console/include/javascript/jquery.pandora.controls.js index bbd2681c9e..9f0a0a7d37 100644 --- a/pandora_console/include/javascript/jquery.pandora.controls.js +++ b/pandora_console/include/javascript/jquery.pandora.controls.js @@ -56,6 +56,60 @@ } }); + $.extend ({ + pandoraSelectGroupAgentDisabled: new function() { + this.defaults = { + agentSelect: "select#id_agent", + loading: "#agent_loading", + callbackBefore: dummyFunc, + callbackPre: dummyFunc, + callbackPost: dummyFunc, + callbackAfter: dummyFunc, + debug: false + }; + + /* public methods */ + this.construct = function (settings) { + return this.each (function() { + this.config = {}; + + this.config = $.extend (this.config, $.pandoraSelectGroupAgentDisabled.defaults, settings); + var config = this.config; + + $(this).change (function () { + var $select = $(config.agentSelect).disable (); + $(config.loading).show (); + $("option[value!=0]", $select).remove (); + if (! config.callbackBefore (this)) + return; + + jQuery.post ("ajax.php", + {"page" : "godmode/groups/group_list", + "get_group_agents" : 1, + "disabled" : 1, + "id_group" : this.value + }, + function (data, status) { + jQuery.each (data, function (id, value) { + config.callbackPre (); + option = $("") + .attr ("value", id) + .html (value); + config.callbackPost (id, value, option); + $(config.agentSelect).append (option); + }); + $(config.loading).hide (); + $select.enable (); + config.callbackAfter (); + }, + "json" + ); + }); + }); + }; + } + }); + $.extend ({ pandoraSelectAgentModule: new function() { this.defaults = { @@ -253,6 +307,7 @@ $.fn.extend({ pandoraSelectGroupAgent: $.pandoraSelectGroupAgent.construct, + pandoraSelectGroupAgentDisabled: $.pandoraSelectGroupAgentDisabled.construct, pandoraSelectAgentModule: $.pandoraSelectAgentModule.construct, pandoraSelectAgentAlert: $.pandoraSelectAgentAlert.construct, pandoraSelectOS: $.pandoraSelectOS.construct,