From 46237d46000f04a964dc02d55040f2f604ad3311 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Fri, 6 Aug 2010 08:39:34 +0000 Subject: [PATCH] 2010-08-06 Sergio Martin * include/functions_alerts.php godmode/alerts/alert_actions.php: Added the duplicate alert action feature for pending task 3038715 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3107 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++++++ .../godmode/alerts/alert_actions.php | 21 +++++++++++++++++-- pandora_console/include/functions_alerts.php | 15 +++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 01e33870fd..a28142186a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2010-08-06 Sergio Martin + + * include/functions_alerts.php + godmode/alerts/alert_actions.php: Added the duplicate alert action + feature for pending task 3038715 + 2010-08-04 Miguel de Dios * include/functions_filemanager.php: added parameter $readOnly in the function "file_explorer". diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index ae61e9c2f3..acb00006be 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -45,6 +45,17 @@ print_page_header (__('Alerts').' » '.__('Alert actions'), "images/god2.pn $update_action = (bool) get_parameter ('update_action'); $create_action = (bool) get_parameter ('create_action'); $delete_action = (bool) get_parameter ('delete_action'); +$copy_action = (bool) get_parameter ('copy_action'); + +if ($copy_action) { + $id = get_parameter ('id'); + + $result = clone_alert_action ($id); + + print_result_message ($result, + __('Successfully copied'), + __('Could not be copied')); +} if ($create_action) { $name = (string) get_parameter ('name'); @@ -104,13 +115,16 @@ $table->data = array (); $table->head = array (); $table->head[0] = __('Name'); $table->head[1] = __('Group'); -$table->head[2] = __('Delete'); +$table->head[2] = __('Copy'); +$table->head[3] = __('Delete'); $table->style = array (); $table->style[0] = 'font-weight: bold'; $table->size = array (); $table->size[2] = '40px'; +$table->size[3] = '40px'; $table->align = array (); $table->align[2] = 'center'; +$table->align[3] = 'center'; $actions = get_db_all_rows_in_table ('talert_actions'); if ($actions === false) @@ -131,7 +145,10 @@ foreach ($actions as $action) { $data[0] = ''. $action['name'].''; $data[1] = print_group_icon ($action["id_group"], true) .' '. get_group_name ($action["id_group"], true); - $data[2] = ''. + ''; + $data[3] = ''. ''; diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index e108ddacaf..bd1618e664 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -138,6 +138,21 @@ function delete_alert_action ($id_alert_action) { array ('id' => $id_alert_action))) !== false; } + +function clone_alert_action ($id_alert_action) { + $id_alert_action = safe_int ($id_alert_action, 1); + if (empty ($id_alert_action)) + return false; + + $action = get_alert_action($id_alert_action); + + if (empty ($action)) + return false; + + unset($action['id']); + $result = create_alert_action ($action['name']." ".__('copy'), $action['id_alert_command'], $action); +} + function get_alert_actions ($only_names = true) { $all_actions = get_db_all_rows_in_table ('talert_actions');