From 2ec9a602733ab9502f84dd5629b3634f5f1980a8 Mon Sep 17 00:00:00 2001 From: Esteban Sanchez Date: Wed, 21 Jan 2009 09:06:03 +0000 Subject: [PATCH] 2009-01-21 Esteban Sanchez * godmode/agentes/alert_manager.php: Added the hability to delete actions and alert (only when it has no actions). * include/functions_alerts.php: Added delete_alert_agent_module() and delete_alert_agent_module_action(). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1377 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 ++++ .../godmode/agentes/alert_manager.php | 46 +++++++++++++++++-- pandora_console/include/functions_alerts.php | 25 ++++++++++ 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index c59460c110..2aa5edbfc6 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2009-01-21 Esteban Sanchez + + * godmode/agentes/alert_manager.php: Added the hability to delete + actions and alert (only when it has no actions). + + * include/functions_alerts.php: Added delete_alert_agent_module() and + delete_alert_agent_module_action(). + 2009-01-21 Esteban Sanchez * godmode/alerts/configure_alert_template.php, diff --git a/pandora_console/godmode/agentes/alert_manager.php b/pandora_console/godmode/agentes/alert_manager.php index e019126068..46949073df 100644 --- a/pandora_console/godmode/agentes/alert_manager.php +++ b/pandora_console/godmode/agentes/alert_manager.php @@ -28,6 +28,8 @@ echo "

".__('Agent configuration')." > ".__('Alerts')."

"; $create_alert = (bool) get_parameter ('create_alert'); $add_action = (bool) get_parameter ('add_action'); +$delete_action = (bool) get_parameter ('delete_action'); +$delete_alert = (bool) get_parameter ('delete_alert'); if ($create_alert) { $id_alert_template = (int) get_parameter ('template'); @@ -50,6 +52,14 @@ if ($create_alert) { } } +if ($delete_alert) { + $id_alert_agent_module = (int) get_parameter ('id_alert'); + + $result = delete_alert_agent_module ($id_alert_agent_module); + print_error_message ($id, __('Successfully deleted'), + __('Could not be deleted')); +} + if ($add_action) { $id_action = (int) get_parameter ('action'); $id_alert_module = (int) get_parameter ('id_alert_module'); @@ -66,6 +76,15 @@ if ($add_action) { __('Could not be added')); } +if ($delete_action) { + $id_action = (int) get_parameter ('id_action'); + $id_alert = (int) get_parameter ('id_alert'); + + $result = delete_alert_agent_module_action ($id_alert, $id_action); + print_error_message ($id, __('Successfully deleted'), + __('Could not be deleted')); +} + $modules = get_agent_modules ($id_agente, array ('id_tipo_modulo', 'nombre', 'id_agente')); @@ -132,7 +151,16 @@ foreach ($modules as $id_agent_module => $module) { $alert_data[0] = get_alert_template_name ($alert['id_alert_template']); $alert_data[0] .= ''; $alert_data[1] .= ' '; - $alert_data[1] .= ''; - $alert_data[1] .= ''; + $alert_data[1] .= ''; $alert_data[1] .= ''; $alert_data[1] .= ''; $alert_data[1] .= ''; @@ -323,5 +354,10 @@ $(document).ready (function () { "ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template=" + this.value); $(this).after (details); }); + $("form.delete_link").submit (function () { + if (! confirm ("")) + return false; + return true; + }); }); diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 767eae53d5..d49674056f 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -590,6 +590,17 @@ function update_alert_agent_module ($id_alert_agent_module, $values = false) { return process_sql ($sql) !== false; } +function delete_alert_agent_module ($id_alert_agent_module) { + if (empty ($id_alert_agent_module)) + return false; + + $sql = sprintf ('DELETE FROM talert_template_modules + WHERE id = %d', + $id_alert_agent_module); + + return process_sql ($sql) !== false; +} + function get_alert_agent_module ($id_alert_agent_module) { $id_alert_agent_module = safe_int ($id_alert_agent_module, 1); if (empty ($id_alert_agent_module)) @@ -655,6 +666,20 @@ function add_alert_agent_module_action ($id_alert_agent_module, $id_alert_action return process_sql ($sql) !== false; } +function delete_alert_agent_module_action ($id_alert_agent_module, $id_alert_action) { + if (empty ($id_alert_agent_module)) + return false; + if (empty ($id_alert_action)) + return false; + + $sql = sprintf ('DELETE FROM talert_template_module_actions + WHERE id_alert_template_module = %d + AND id_alert_action = %d', + $id_alert_agent_module, $id_alert_action); + + return process_sql ($sql) !== false; +} + function get_alert_agent_module_actions ($id_alert_agent_module) { if (empty ($id_alert_agent_module)) return false;