/**
  * (non-PHPdoc)
  *
  * @see PostmanAbstractZendModuleTransport::validateTransportConfiguration()
  */
 protected function validateTransportConfiguration()
 {
     $messages = parent::validateTransportConfiguration();
     if (empty($messages)) {
         $this->setReadyForOAuthGrant();
         if ($this->isPermissionNeeded()) {
             /* translators: %1$s is the Client ID label, and %2$s is the Client Secret label */
             $message = sprintf(__('You have configured OAuth 2.0 authentication, but have not received permission to use it.', Postman::TEXT_DOMAIN), $this->getScribe()->getClientIdLabel(), $this->getScribe()->getClientSecretLabel());
             $message .= sprintf(' <a href="%s">%s</a>.', PostmanUtils::getGrantOAuthPermissionUrl(), $this->getScribe()->getRequestPermissionLinkText());
             array_push($messages, $message);
             $this->setNotConfiguredAndReady();
         }
     }
     return $messages;
 }
 /**
  */
 private function displayTopNavigation()
 {
     screen_icon();
     printf('<h2>%s</h2>', _x('Postman Setup', 'Page Title', 'postman-smtp'));
     print '<div id="postman-main-menu" class="welcome-panel">';
     print '<div class="welcome-panel-content">';
     print '<div class="welcome-panel-column-container">';
     print '<div class="welcome-panel-column">';
     printf('<h4>%s</h4>', _x('Settings', 'The configuration page of the plugin', 'postman-smtp'));
     printf('<a class="button button-primary button-hero" href="%s">%s</a>', $this->getPageUrl(self::CONFIGURATION_WIZARD_SLUG), __('Start the Wizard', 'postman-smtp'));
     printf('<p class="">or, <a href="%s" class="configure_manually">%s</a>. </p>', $this->getPageUrl(self::CONFIGURATION_SLUG), _x('configure manually', 'Adjust the Postman settings by hand', 'postman-smtp'));
     print '</div>';
     print '<div class="welcome-panel-column">';
     printf('<h4>%s</h4>', _x('Actions', 'Main Menu', 'postman-smtp'));
     print '<ul>';
     if (PostmanTransportRegistry::getInstance()->isRequestOAuthPermissionAllowed($this->options, $this->authorizationToken)) {
         printf('<li><a href="%s" class="welcome-icon send-test-email">%s</a></li>', PostmanUtils::getGrantOAuthPermissionUrl(), $this->oauthScribe->getRequestPermissionLinkText());
     } else {
         printf('<li><div class="welcome-icon send_test_email">%s</div></li>', $this->oauthScribe->getRequestPermissionLinkText());
     }
     if (PostmanTransportRegistry::getInstance()->isPostmanReadyToSendEmail($this->options, $this->authorizationToken)) {
         printf('<li><a href="%s" class="welcome-icon send_test_email">%s</a></li>', $this->getPageUrl(self::EMAIL_TEST_SLUG), __('Send a Test Email', 'postman-smtp'));
     } else {
         printf('<li><div class="welcome-icon send_test_email">%s</div></li>', __('Send a Test Email', 'postman-smtp'));
     }
     $purgeLinkPattern = '<li><a href="%1$s" class="welcome-icon oauth-authorize">%2$s</a></li>';
     if ($this->options->isNew()) {
         $purgeLinkPattern = '<li>%2$s</li>';
     }
     printf($purgeLinkPattern, $this->getPageUrl(PostmanAdminController::PURGE_DATA_SLUG), __('Delete plugin settings', 'postman-smtp'));
     print '</ul>';
     print '</div>';
     print '<div class="welcome-panel-column welcome-panel-last">';
     printf('<h4>%s</h4>', _x('Troubleshooting', 'Main Menu', 'postman-smtp'));
     print '<ul>';
     printf('<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl(self::PORT_TEST_SLUG), __('Connectivity Test', 'postman-smtp'));
     printf('<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl(self::DIAGNOSTICS_SLUG), __('Diagnostic Test', 'postman-smtp'));
     printf('<li><a href="https://wordpress.org/support/plugin/postman-smtp" class="welcome-icon postman_support">%s</a></li>', __('Online Support', 'postman-smtp'));
     print '</ul></div></div></div></div>';
 }
 public function getMisconfigurationMessage(PostmanConfigTextHelper $scribe, PostmanOptionsInterface $options, PostmanOAuthToken $token)
 {
     if ($this->isOAuthCredentialsNeeded($options)) {
         return sprintf(__('OAuth 2.0 authentication requires a Client ID and Client Secret.', 'postman-smtp'));
     } else {
         if (!$this->isSenderConfigured($options)) {
             return __('Envelope From Address and Message From Address can not be empty.', 'postman-smtp');
         } else {
             if ($this->isPermissionNeeded($token)) {
                 $message = sprintf(__('You have configured OAuth 2.0 authentication, but have not received permission to use it.', 'postman-smtp'), $scribe->getClientIdLabel(), $scribe->getClientSecretLabel());
                 $message .= sprintf(' <a href="%s">%s</a>.', PostmanUtils::getGrantOAuthPermissionUrl(), $scribe->getRequestPermissionLinkText());
                 return $message;
             }
         }
     }
 }
 /**
  */
 public function printActionMenuItem()
 {
     if ($this->readyForOAuthGrant && $this->getAuthenticationType() == PostmanOptions::AUTHENTICATION_TYPE_OAUTH2) {
         printf('<li><a href="%s" class="welcome-icon send-test-email">%s</a></li>', PostmanUtils::getGrantOAuthPermissionUrl(), $this->getScribe()->getRequestPermissionLinkText());
     } else {
         parent::printActionMenuItem();
     }
 }
 /**
  * (non-PHPdoc)
  *
  * @see PostmanTransport::getMisconfigurationMessage()
  */
 protected function validateTransportConfiguration()
 {
     $messages = parent::validateTransportConfiguration();
     if (!$this->isHostConfigured($this->options)) {
         array_push($messages, __('Outgoing Mail Server Hostname and Port can not be empty.', Postman::TEXT_DOMAIN));
         $this->setNotConfiguredAndReady();
     }
     if (!$this->isEnvelopeFromConfigured()) {
         array_push($messages, __('Envelope-From Email Address can not be empty', Postman::TEXT_DOMAIN) . '.');
         $this->setNotConfiguredAndReady();
     }
     if ($this->options->isAuthTypePassword() && !$this->isPasswordAuthenticationConfigured($this->options)) {
         array_push($messages, __('Username and password can not be empty.', Postman::TEXT_DOMAIN));
         $this->setNotConfiguredAndReady();
     }
     if ($this->getAuthenticationType() == PostmanOptions::AUTHENTICATION_TYPE_OAUTH2) {
         if (!$this->isOAuth2SupportedHostConfigured()) {
             /* translators: %1$s is the Client ID label, and %2$s is the Client Secret label (e.g. Warning: OAuth 2.0 authentication requires an OAuth 2.0-capable Outgoing Mail Server, Sender Email Address, Client ID, and Client Secret.) */
             array_push($messages, sprintf(__('OAuth 2.0 authentication requires a supported OAuth 2.0-capable Outgoing Mail Server.', Postman::TEXT_DOMAIN)));
             $this->setNotConfiguredAndReady();
         }
     }
     if (empty($messages)) {
         $this->setReadyForOAuthGrant();
         if ($this->isPermissionNeeded($this->options, $this->getOAuthToken())) {
             /* translators: %1$s is the Client ID label, and %2$s is the Client Secret label */
             $message = sprintf(__('You have configured OAuth 2.0 authentication, but have not received permission to use it.', Postman::TEXT_DOMAIN), $this->getScribe()->getClientIdLabel(), $this->getScribe()->getClientSecretLabel());
             $message .= sprintf(' <a href="%s">%s</a>.', PostmanUtils::getGrantOAuthPermissionUrl(), $this->getScribe()->getRequestPermissionLinkText());
             array_push($messages, $message);
             $this->setNotConfiguredAndReady();
         }
     }
     return $messages;
 }
 public function getMisconfigurationMessage(PostmanConfigTextHelper $scribe, PostmanOptionsInterface $options, PostmanOAuthToken $token)
 {
     if (!$this->isHostConfigured($options)) {
         return __('Outgoing Mail Server Hostname and Port can not be empty.', 'postman-smtp');
     } else {
         if (!$this->isSenderConfigured($options)) {
             return __('Envelope From Address and Message From Address can not be empty.', 'postman-smtp');
         } else {
             if ($options->isAuthTypePassword() && !$this->isPasswordAuthenticationConfigured($options)) {
                 return __('Password authentication (Plain/Login/CRAM-MD5) requires a username and password.', 'postman-smtp');
             } else {
                 if ($options->isAuthTypeOAuth2() && !$this->isOAuthAuthenticationConfigured($options)) {
                     /* translators: %1$s is the Client ID label, and %2$s is the Client Secret label (e.g. Warning: OAuth 2.0 authentication requires an OAuth 2.0-capable Outgoing Mail Server, Sender Email Address, Client ID, and Client Secret.) */
                     return sprintf(__('OAuth 2.0 authentication requires a supported OAuth 2.0-capable Outgoing Mail Server, %1$s, and %2$s.', 'postman-smtp'), $scribe->getClientIdLabel(), $scribe->getClientSecretLabel());
                 } else {
                     if ($this->isPermissionNeeded($options, $token)) {
                         /* translators: %1$s is the Client ID label, and %2$s is the Client Secret label */
                         $message = sprintf(__('You have configured OAuth 2.0 authentication, but have not received permission to use it.', 'postman-smtp'), $scribe->getClientIdLabel(), $scribe->getClientSecretLabel());
                         $message .= sprintf(' <a href="%s">%s</a>.', PostmanUtils::getGrantOAuthPermissionUrl(), $scribe->getRequestPermissionLinkText());
                         return $message;
                     }
                 }
             }
         }
     }
 }