From d3fcfec4bbefa847c65c1d80ab36da5e9d0b8f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 28 May 2014 09:26:35 +0200 Subject: [PATCH] Consistent message strings and types for error submission MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can share more strings on the failed error reporting and also the messages should have same type regardless it was manual or automatic submission. Signed-off-by: Michal Čihař --- error_report.php | 102 ++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 63 deletions(-) diff --git a/error_report.php b/error_report.php index 78f909e098..327a5a8d9b 100644 --- a/error_report.php +++ b/error_report.php @@ -19,74 +19,50 @@ if (isset($_REQUEST['send_error_report']) $success = false; } else { $decoded_response = json_decode($server_response, true); - $success = !empty($decoded_response) ? $decoded_response["success"] : false; - } + $success = !empty($decoded_response) ? $decoded_response["success"] : false; } - if (isset($_REQUEST['automatic']) - && $_REQUEST['automatic'] === "true" - ) { - if ($success) { - $response->addJSON( - 'message', - PMA_Message::error( - __( - 'An error has been detected and an error report has been ' - . 'automatically submitted based on your settings.' - ) - . '
' - . __('You may want to refresh the page.') - ) + /* Message to show to the user */ + if ($success) { + if (isset($_REQUEST['automatic']) + && $_REQUEST['automatic'] === "true" + ) { + $message = __( + 'An error has been detected and an error report has been ' + . 'automatically submitted based on your settings.' ); } else { - $response->addJSON( - 'message', - PMA_Message::error( - __( - 'An error has been detected and an error report has been ' - . 'generated but failed to be sent.' - ) - . ' ' - . __( - 'If you experience any ' - . 'problems please submit a bug report manually.' - ) - . '
' - . __('You may want to refresh the page.') - ) - ); + $message = __('Thank you for submitting this report.'); } } else { - if ($success) { - $response->addJSON( - 'message', - PMA_Message::success( - __('Thank you for submitting this report.') - . '
' - . __('You may want to refresh the page.') - ) - ); - } else { - $response->addJSON( - 'message', - PMA_Message::error( - __('Thank you for submitting this report.') - . ' ' - . __('Unfortunately the submission failed.') - . ' ' - . __( - 'If you experience any ' - . 'problems please submit a bug report manually.' - ) - . '
' - . __('You may want to refresh the page.') - ) - ); - } - if (isset($_REQUEST['always_send']) - && $_REQUEST['always_send'] === "true" - ) { - PMA_persistOption("SendErrorReports", "always", "ask"); - } + $message = __( + 'An error has been detected and an error report has been ' + . 'generated but failed to be sent.' + ) + . ' ' + . __( + 'If you experience any ' + . 'problems please submit a bug report manually.' + ); + } + $message .= ' ' . __('You may want to refresh the page.'); + + /* Create message object */ + if ($success) { + $message = PMA_Message::notice($message); + } else { + $message = PMA_Message::error($message); + } + + /* Add message to JSON response */ + $response->addJSON('message', $message); + + /* Persist always send settings */ + if (! isset($_REQUEST['automatic']) + && $_REQUEST['automatic'] !== "true" + && isset($_REQUEST['always_send']) + && $_REQUEST['always_send'] === "true" + ) { + PMA_persistOption("SendErrorReports", "always", "ask"); } } elseif (! empty($_REQUEST['get_settings'])) { $response->addJSON('report_setting', $GLOBALS['cfg']['SendErrorReports']);