Merge branch 'JohnFF-patch-1'
[civicrm-core.git] / CRM / Admin / Form / Setting / Smtp.php
index 3b82e6a315a62225adb3f467421d0c99a9dc0ad7..cb3947617f40d759f524cb0a4c258faaf5615d45 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -43,7 +43,7 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting {
   /**
    * Function to build the form
    *
-   * @return None
+   * @return void
    * @access public
    */
   public function buildQuickForm() {
@@ -53,8 +53,7 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting {
       CRM_Mailing_Config::OUTBOUND_OPTION_SMTP => ts('SMTP'),
       CRM_Mailing_Config::OUTBOUND_OPTION_SENDMAIL => ts('Sendmail'),
       CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED => ts('Disable Outbound Email'),
-      // CRM-13445 Suppressing the Redirect to DB option pending further evaluation
-      // CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB => ts('Redirect to Database'),
+      CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB => ts('Redirect to Database'),
     );
     $this->addRadio('outBound_option', ts('Select Mailer'), $outBoundOption);
 
@@ -80,7 +79,7 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting {
    *
    * @access public
    *
-   * @return None
+   * @return void
    */
   public function postProcess() {
     // flush caches so we reload details for future requests
@@ -169,9 +168,9 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting {
 
         $mailer = Mail::factory($mailerName, $params);
 
-        CRM_Core_Error::ignoreException();
+        $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
         $result = $mailer->send($toEmail, $headers, $message);
-        CRM_Core_Error::setCallback();
+        unset($errorScope);
         if (!is_a($result, 'PEAR_Error')) {
           CRM_Core_Session::setStatus($testMailStatusMsg . ts('Your %1 settings are correct. A test email has been sent to your email address.', array(1 => strtoupper($mailerName))), ts("Mail Sent"), "success");
         }
@@ -212,17 +211,17 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting {
    */
   static function formRule($fields) {
     if ($fields['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SMTP) {
-      if (!CRM_Utils_Array::value('smtpServer', $fields)) {
+      if (empty($fields['smtpServer'])) {
         $errors['smtpServer'] = 'SMTP Server name is a required field.';
       }
-      if (!CRM_Utils_Array::value('smtpPort', $fields)) {
+      if (empty($fields['smtpPort'])) {
         $errors['smtpPort'] = 'SMTP Port is a required field.';
       }
-      if (CRM_Utils_Array::value('smtpAuth', $fields)) {
-        if (!CRM_Utils_Array::value('smtpUsername', $fields)) {
+      if (!empty($fields['smtpAuth'])) {
+        if (empty($fields['smtpUsername'])) {
           $errors['smtpUsername'] = 'If your SMTP server requires authentication please provide a valid user name.';
         }
-        if (!CRM_Utils_Array::value('smtpPassword', $fields)) {
+        if (empty($fields['smtpPassword'])) {
           $errors['smtpPassword'] = 'If your SMTP server requires authentication, please provide a password.';
         }
       }
@@ -245,7 +244,7 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting {
    *
    * @access public
    *
-   * @return None
+   * @return void
    */
   function setDefaultValues() {
     if (!$this->_defaults) {