From 61a3d147afbada7342ac5c88829aff81d024a1d8 Mon Sep 17 00:00:00 2001 From: "tatiana.llorente@artica.es" Date: Wed, 3 Oct 2018 16:41:58 +0200 Subject: [PATCH 1/2] Added descriptive error messages - #2858 --- .../godmode/alerts/alert_actions.php | 18 ++++++++++++-- .../godmode/alerts/alert_commands.php | 17 +++++++++++-- pandora_console/godmode/alerts/alert_list.php | 20 ++++++++++++++-- .../godmode/alerts/alert_special_days.php | 24 +++++++++++++++---- .../alerts/configure_alert_template.php | 16 +++++++++++-- 5 files changed, 82 insertions(+), 13 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index 3bad38b982..a80ba40a23 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -179,9 +179,23 @@ if ($create_action) { db_pandora_audit("Command management", "Fail try to create alert action", false, false); } - ui_print_result_message ($result, + + /* Show errors */ + if (!isset($messageAction)) { + $messageAction = __('Could not be created'); + } + + if ($name == "") { + $messageAction = __('No name specified'); + } + + if ($id_alert_command == "") { + $messageAction = __('No command specified'); + } + + $messageAction = ui_print_result_message ($result, __('Successfully created'), - __('Could not be created')); + $messageAction); } if ($update_action) { diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 09e868f951..9ca4ea501a 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -307,9 +307,22 @@ if ($create_command) { db_pandora_audit("Command management", "Fail try to create alert command", false, false); } - ui_print_result_message ($result, + /* Show errors */ + if (!isset($messageAction)) { + $messageAction = __('Could not be created'); + } + + if ($name == "") { + $messageAction = __('No name specified'); + } + + if ($command == "") { + $messageAction = __('No command specified'); + } + + $messageAction = ui_print_result_message ($result, __('Successfully created'), - __('Could not be created')); + $messageAction); } diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index 9a6badcc24..4d61925550 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -126,9 +126,25 @@ if ($create_alert) { "Fail Added alert '$unsafe_alert_template_name' for module '$unsafe_module_name' in agent '$unsafe_agent_alias'"); } - $messageAction = ui_print_result_message ($id, - __('Successfully created'), __('Could not be created'), '', true); + + /* Show errors */ + if (!isset($messageAction)) { + $messageAction = __('Could not be created'); + } + if ($id_alert_template == "") { + $messageAction = __('No template specified'); + } + + if ($id_agent_module == "") { + $messageAction = __('No module specified'); + } + + $messageAction = ui_print_result_message ($id, + __('Successfully created'), + $messageAction); + + if ($id !== false) { $action_select = get_parameter('action_select'); diff --git a/pandora_console/godmode/alerts/alert_special_days.php b/pandora_console/godmode/alerts/alert_special_days.php index c221f963af..0e4ce10a38 100644 --- a/pandora_console/godmode/alerts/alert_special_days.php +++ b/pandora_console/godmode/alerts/alert_special_days.php @@ -130,6 +130,7 @@ if ($create_special_day) { $date_check = db_get_value_filter ('date', 'talert_special_days', $filter); if ($date_check == $date) { $result = ''; + $messageAction = __('Could not be created, it already exists'); } else { $result = alerts_create_alert_special_day ($date, $same_day, $values); @@ -143,10 +144,16 @@ if ($create_special_day) { else { db_pandora_audit("Command management", "Fail try to create special day", false, false); } - - ui_print_result_message ($result, + + + /* Show errors */ + if (!isset($messageAction)) { + $messageAction = __('Could not be created'); + } + + $messageAction = ui_print_result_message ($result, __('Successfully created'), - __('Could not be created')); + $messageAction); } if ($update_special_day) { @@ -183,6 +190,7 @@ if ($update_special_day) { $date_check = db_get_value_filter ('date', 'talert_special_days', $filter); if ($date_check == $date) { $result = ''; + $messageAction = __('Could not be updated, it already exists'); } else { $result = alerts_update_alert_special_day ($id, $values); @@ -202,9 +210,15 @@ if ($update_special_day) { db_pandora_audit("Command management", "Fail to update special day " . $id, false, false); } - ui_print_result_message ($result, + + /* Show errors */ + if (!isset($messageAction)) { + $messageAction = __('Could not be updated'); + } + + $messageAction = ui_print_result_message ($result, __('Successfully updated'), - __('Could not be updated')); + $messageAction); } if ($delete_special_day) { diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index 5fc232490a..b75b26561f 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -428,9 +428,21 @@ if ($create_template) { json_encode($values)); } - ui_print_result_message ($result, + + /* Show errors */ + if (!isset($messageAction)) { + $messageAction = __('Could not be created'); + } + + if ($name == "") { + $messageAction = __('No template name specified'); + } + + $messageAction = ui_print_result_message ($result, __('Successfully created'), - __('Could not be created')); + $messageAction); + + /* Go to previous step in case of error */ if ($result === false) $step = $step - 1; From 0855d091562e16fb3074e3621dd635014f1ce5b5 Mon Sep 17 00:00:00 2001 From: "tatiana.llorente@artica.es" Date: Wed, 3 Oct 2018 16:46:35 +0200 Subject: [PATCH 2/2] Fixed a minor mistake - #2858 --- pandora_console/godmode/alerts/alert_list.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index 4d61925550..4df1ec4be5 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -141,9 +141,8 @@ if ($create_alert) { } $messageAction = ui_print_result_message ($id, - __('Successfully created'), - $messageAction); - + __('Successfully created'), $messageAction, '', true); + if ($id !== false) { $action_select = get_parameter('action_select');