/** * This Ajax function retrieves the OAuth redirectUrl and help text for based on the SMTP hostname supplied */ function getWizardConfigurationViaAjax() { $this->logger->debug('in getWizardConfiguration'); $originalSmtpServer = $this->getRequestParameter('original_smtp_server'); $queryHostData = $this->getHostDataFromRequest(); $userPortOverride = $this->getUserPortOverride(); $userAuthOverride = $this->getUserAuthOverride(); // determine a configuration recommendation $winningRecommendation = $this->getWinningRecommendation($queryHostData, $userPortOverride, $userAuthOverride, $originalSmtpServer); $this->logger->trace('winning recommendation:'); $this->logger->trace($winningRecommendation); // create user override menu $overrideMenu = $this->createOverrideMenu($queryHostData, $winningRecommendation, $userPortOverride, $userAuthOverride); $this->logger->trace('override menu:'); $this->logger->trace($overrideMenu); // create the reponse $response = array(); $configuration = array(); $response['referer'] = 'wizard'; if (isset($userPortOverride) || isset($userAuthOverride)) { $configuration['user_override'] = true; } if (isset($winningRecommendation)) { // create an appropriate (theoretical) transport $transport = PostmanTransportRegistry::getInstance()->getTransport($winningRecommendation['transport']); $scribe = PostmanConfigTextHelperFactory::createScribe($winningRecommendation['hostname'], $transport); $this->populateResponseFromScribe($scribe, $configuration); $this->populateResponseFromTransport($winningRecommendation, $configuration); $response['override_menu'] = $overrideMenu; $response['configuration'] = $configuration; $this->logger->trace('configuration:'); $this->logger->trace($configuration); wp_send_json_success($response); } else { /* translators: where %s is the URL to the Connectivity Test page */ $configuration['message'] = sprintf(__('Postman can\'t find any way to send mail on your system. Run a <a href="%s">connectivity test</a>.', 'postman-smtp'), PostmanViewController::getPageUrl(PostmanViewController::PORT_TEST_SLUG)); $response['configuration'] = $configuration; $this->logger->trace('configuration:'); $this->logger->trace($configuration); wp_send_json_error($response); } }
/** * Once the Port Tests have run, the results are analyzed. * The Transport place bids on the sockets and highest bid becomes the recommended * The UI response is built so the user may choose a different socket with different options. */ function getWizardConfigurationViaAjax() { $this->logger->debug('in getWizardConfiguration'); $originalSmtpServer = $this->getRequestParameter('original_smtp_server'); $queryHostData = $this->getHostDataFromRequest(); $sockets = array(); foreach ($queryHostData as $id => $datum) { array_push($sockets, new PostmanWizardSocket($datum)); } $this->logger->error($sockets); $userPortOverride = $this->getUserPortOverride(); $userAuthOverride = $this->getUserAuthOverride(); // determine a configuration recommendation $winningRecommendation = $this->getWinningRecommendation($sockets, $userPortOverride, $userAuthOverride, $originalSmtpServer); if ($this->logger->isTrace()) { $this->logger->trace('winning recommendation:'); $this->logger->trace($winningRecommendation); } // create the reponse $response = array(); $configuration = array(); $response['referer'] = 'wizard'; if (isset($userPortOverride) || isset($userAuthOverride)) { $configuration['user_override'] = true; } if (isset($winningRecommendation)) { // create an appropriate (theoretical) transport $transport = PostmanTransportRegistry::getInstance()->getTransport($winningRecommendation['transport']); // create user override menu $overrideMenu = $this->createOverrideMenus($sockets, $winningRecommendation, $userPortOverride, $userAuthOverride); if ($this->logger->isTrace()) { $this->logger->trace('override menu:'); $this->logger->trace($overrideMenu); } $queryHostName = $winningRecommendation['hostname']; if ($this->logger->isDebug()) { $this->logger->debug('Getting scribe for ' . $queryHostName); } $generalConfig1 = $transport->populateConfiguration($queryHostName); $generalConfig2 = $transport->populateConfigurationFromRecommendation($winningRecommendation); $configuration = array_merge($configuration, $generalConfig1, $generalConfig2); $response['override_menu'] = $overrideMenu; $response['configuration'] = $configuration; if ($this->logger->isTrace()) { $this->logger->trace('configuration:'); $this->logger->trace($configuration); $this->logger->trace('response:'); $this->logger->trace($response); } wp_send_json_success($response); } else { /* translators: where %s is the URL to the Connectivity Test page */ $configuration['message'] = sprintf(__('Postman can\'t find any way to send mail on your system. Run a <a href="%s">connectivity test</a>.', Postman::TEXT_DOMAIN), PostmanViewController::getPageUrl(PostmanViewController::PORT_TEST_SLUG)); $response['configuration'] = $configuration; if ($this->logger->isTrace()) { $this->logger->trace('configuration:'); $this->logger->trace($configuration); } wp_send_json_error($response); } }