From 87c4d63bc36aa8d8d5a183ecab2dd1d367657416 Mon Sep 17 00:00:00 2001 From: esanchezm Date: Tue, 19 May 2009 09:57:38 +0000 Subject: [PATCH] 2009-05-19 Esteban Sanchez * include/functions_alerts.php: Added get_agents_with_alert_template(). Added extra filter to delete_alert_agent_module(). * godmode/agentes/massive_delete_alerts.php: Completely changed the way it works. Fixes #2707976. * images/mod_keepalive.png: Replaced with tango icon. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1694 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 ++ .../godmode/agentes/massive_delete_alerts.php | 117 ++++++++++++------ pandora_console/images/mod_keepalive.png | Bin 740 -> 647 bytes pandora_console/include/functions_alerts.php | 24 +++- 4 files changed, 107 insertions(+), 44 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index f5969806ea..34dee668fd 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2009-05-19 Esteban Sanchez + + * include/functions_alerts.php: Added get_agents_with_alert_template(). + Added extra filter to delete_alert_agent_module(). + + * godmode/agentes/massive_delete_alerts.php: Completely changed the way it + works. Fixes #2707976. + + * images/mod_keepalive.png: Replaced with tango icon. + 2009-05-18 Esteban Sanchez * images/mod_async_string.png, images/mod_async_inc.png, diff --git a/pandora_console/godmode/agentes/massive_delete_alerts.php b/pandora_console/godmode/agentes/massive_delete_alerts.php index 549e1b1eb4..605df98c35 100644 --- a/pandora_console/godmode/agentes/massive_delete_alerts.php +++ b/pandora_console/godmode/agentes/massive_delete_alerts.php @@ -29,25 +29,43 @@ if (! give_acl ($config['id_user'], 0, "AW")) { require_once ('include/functions_agents.php'); require_once ('include/functions_alerts.php'); -echo '

'.__('Massive alerts deletion').'

'; +if (is_ajax ()) { + $get_agents = (bool) get_parameter ('get_agents'); + + if ($get_agents) { + $id_group = (int) get_parameter ('id_group'); + $id_alert_template = (int) get_parameter ('id_alert_template'); + + $agents_alerts = get_agents_with_alert_template ($id_alert_template, $id_group, + false, array ('tagente.nombre', 'tagente.id_agente')); + + echo json_encode (index_array ($agents_alerts, 'id_agente', 'nombre')); + return; + } + return; +} -function process_manage_delete ($id_alerts) { - if (empty ($id_alerts)) { - echo '

'.__('No alerts selected').'

'; +echo '

'.__('Massive alerts deletion').'

'; +function process_manage_delete ($id_alert_template, $id_agents) { + if (empty ($id_alert_template)) { + echo '

'.__('No alert selected').'

'; return false; } - process_sql_begin (); - - foreach ($id_alerts as $id_alert) { - $success = delete_alert_agent_module ($id_alert); - if (! $success) - break; + if (empty ($id_agents)) { + echo '

'.__('No agents selected').'

'; + return false; } + $modules = get_agent_modules ($id_agents, 'id_agente_modulo', false, true); + + process_sql_begin (); + $success = delete_alert_agent_module (false, + array ('id_agent_module' => $modules, + 'id_alert_template' => $id_alert_template)); if (! $success) { echo '

'.__('There was an error deleting the alert, the operation has been cancelled').'

'; - echo '

'.__('Could not delete alert').' '.get_agentmodule_name ($id_module).'

'; + echo '

'.__('Could not delete alert in agent %s', get_agent_name ($id_agent)).'

'; process_sql_rollback (); } else { echo '

'.__('Successfully deleted').'

'; @@ -56,13 +74,13 @@ function process_manage_delete ($id_alerts) { } $id_group = (int) get_parameter ('id_group'); -$id_agent = (int) get_parameter ('id_agent'); -$id_alerts = get_parameter ('id_alerts'); +$id_agents = (array) get_parameter ('id_agents'); +$id_alert_template = (int) get_parameter ('id_alert_template'); $delete = (bool) get_parameter_post ('delete'); if ($delete) { - process_manage_delete ($id_alerts); + process_manage_delete ($id_alert_template, $id_agents); } $groups = get_user_groups (); @@ -78,34 +96,23 @@ $table->size[0] = '15%'; $table->size[1] = '85%'; $table->data = array (); -$table->data[0][0] = __('Group'); -$table->data[0][1] = print_select ($groups, 'id_group', $id_group, - false, '', '', true); -$table->data[1][0] = __('Agent'); -$table->data[1][0] .= ''; -$table->data[1][1] = print_select (get_group_agents ($id_group, false, "none"), - 'id_agent', $id_agent, false, __('None'), 0, true); +$table->data[0][0] = __('Alert template'); +$table->data[0][1] = print_select (get_alert_templates (), + 'id_alert_template', $id_alert_template, false, __('Select'), 0, true); + +$table->data[1][0] = __('Group'); +$table->data[1][1] = print_select ($groups, 'id_group', $id_group, + '', '', '', true, false, true, '', $id_alert_template == 0); -$table->data[2][0] = __('Alerts'); -$table->data[2][0] .= '