From 77322a08ce116fee0ea8d38a07534d1b32f46e9a Mon Sep 17 00:00:00 2001 From: Amine Ben hammou Date: Mon, 9 Sep 2019 18:48:34 +0100 Subject: [PATCH] Remove confirmation sender settings and warnings [MAILPOET-2328] --- lib/Services/AuthorizedEmailsController.php | 7 +-- lib/Util/Notices/UnauthorizedEmailNotice.php | 47 ++++---------------- 2 files changed, 9 insertions(+), 45 deletions(-) diff --git a/lib/Services/AuthorizedEmailsController.php b/lib/Services/AuthorizedEmailsController.php index b685b3ce2c..b9611f29c8 100644 --- a/lib/Services/AuthorizedEmailsController.php +++ b/lib/Services/AuthorizedEmailsController.php @@ -53,8 +53,7 @@ class AuthorizedEmailsController { function onSettingsSave($settings) { $sender_address_set = !empty($settings['sender']['address']); - $confirmation_address_set = !empty($settings['signup_confirmation']['from']['address']); - if ($sender_address_set || $confirmation_address_set) { + if ($sender_address_set) { $this->checkAuthorizedEmailAddresses(); } } @@ -73,14 +72,10 @@ class AuthorizedEmailsController { private function validateAddressesInSettings($authorized_emails, $result = []) { $default_sender_address = $this->settings->get('sender.address'); - $signup_confirmation_address = $this->settings->get('signup_confirmation.from.address'); if (!$this->validateAuthorizedEmail($authorized_emails, $default_sender_address)) { $result['invalid_sender_address'] = $default_sender_address; } - if (!$this->validateAuthorizedEmail($authorized_emails, $signup_confirmation_address)) { - $result['invalid_confirmation_address'] = $signup_confirmation_address; - } return $result; } diff --git a/lib/Util/Notices/UnauthorizedEmailNotice.php b/lib/Util/Notices/UnauthorizedEmailNotice.php index e5730fcc50..ba8eca3cb7 100644 --- a/lib/Util/Notices/UnauthorizedEmailNotice.php +++ b/lib/Util/Notices/UnauthorizedEmailNotice.php @@ -26,10 +26,7 @@ class UnauthorizedEmailNotice { function init($should_display) { $validation_error = $this->settings->get(AuthorizedEmailsController::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING); - if ( - $should_display - && (isset($validation_error['invalid_sender_address']) || isset($validation_error['invalid_confirmation_address'])) - ) { + if ($should_display && isset($validation_error['invalid_sender_address'])) { return $this->display($validation_error); } } @@ -44,23 +41,10 @@ class UnauthorizedEmailNotice { } private function getMessageText($validation_error) { - if ( - !empty($validation_error['invalid_sender_address']) - && !empty($validation_error['invalid_confirmation_address']) - && $validation_error['invalid_sender_address'] !== $validation_error['invalid_confirmation_address'] - ) { - $text = $this->wp->_x('Sending all of your emails has been paused because your email addresses %default-sender-address and %signup-confirmation-address have not been authorized yet.', - 'Email addresses have to be authorized to be used to send emails. %default-sender-address and %signup-confirmation-address will be replaced by email addresses.' - ); - $message = str_replace('%default-sender-address', EscapeHelper::escapeHtmlText($validation_error['invalid_sender_address']), $text); - $message = str_replace('%signup-confirmation-address', EscapeHelper::escapeHtmlText($validation_error['invalid_confirmation_address']), $message); - } else { - $text = $this->wp->_x('Sending all of your emails has been paused because your email address %email-address hasn’t been authorized yet.', - 'Email addresses have to be authorized to be used to send emails. %email-address will be replaced by an email address.' - ); - $email = isset($validation_error['invalid_sender_address']) ? $validation_error['invalid_sender_address'] : $validation_error['invalid_confirmation_address']; - $message = str_replace('%email-address', EscapeHelper::escapeHtmlText($email), $text); - } + $text = $this->wp->_x('Sending all of your emails has been paused because your email address %email-address hasn’t been authorized yet.', + 'Email addresses have to be authorized to be used to send emails. %email-address will be replaced by an email address.' + ); + $message = str_replace('%email-address', EscapeHelper::escapeHtmlText($validation_error['invalid_sender_address']), $text); return "

$message

"; } @@ -71,28 +55,13 @@ class UnauthorizedEmailNotice { $button = Helpers::replaceLinkTags("[link]{$button}[/link]", 'admin.php?page=mailpoet-settings', ['class' => 'button button-secondary']); $buttons .= "

$button

"; } - if (!empty($validation_error['invalid_confirmation_address'])) { - $button = $this->wp->_x('Update my Sign-up Confirmation email address', 'Please reuse the current translation of “Sign-up Confirmation”'); - $button = Helpers::replaceLinkTags("[link]{$button}[/link]", 'admin.php?page=mailpoet-settings#signup', ['class' => 'button button-secondary']); - $buttons .= "

$button

"; - } return $buttons; } private function getAuthorizationLink($validation_error) { - if ( - !empty($validation_error['invalid_sender_address']) - && !empty($validation_error['invalid_confirmation_address']) - && $validation_error['invalid_sender_address'] !== $validation_error['invalid_confirmation_address'] - ) { - $authorize_link = $this->wp->_x('Authorize %email1 and %email2', 'Link for user to authorize their email address'); - $authorize_link = str_replace('%email1', EscapeHelper::escapeHtmlText($validation_error['invalid_sender_address']), $authorize_link); - $authorize_link = str_replace('%email2', EscapeHelper::escapeHtmlText($validation_error['invalid_confirmation_address']), $authorize_link); - } else { - $email = isset($validation_error['invalid_sender_address']) ? $validation_error['invalid_sender_address'] : $validation_error['invalid_confirmation_address']; - $authorize_link = $this->wp->_x('Authorize %email', 'Link for user to authorize their email address'); - $authorize_link = str_replace('%email', EscapeHelper::escapeHtmlText($email), $authorize_link); - } + $email = $validation_error['invalid_sender_address']; + $authorize_link = $this->wp->_x('Authorize %email', 'Link for user to authorize their email address'); + $authorize_link = str_replace('%email', EscapeHelper::escapeHtmlText($email), $authorize_link); $authorize_link = Helpers::replaceLinkTags("[link]{$authorize_link}[/link]", 'https://account.mailpoet.com/authorization', ['target' => '_blank']); $html = '

' . $this->wp->_x('OR', 'User has to choose between two options') . '

'; $html .= "

$authorize_link

";