Update Copywrite year to be 2019
[civicrm-core.git] / CRM / Admin / Form / Options.php
index f68718d881b5886a5e55b02c36c8232390f1170e..9c64cd9b55e98d829cd695b2db962da7eec214dd 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
  */
 
 /**
@@ -464,9 +464,9 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
           $params['reset_default_for'] = array('filter' => "0, " . $params['filter']);
         }
 
-        //make sure we should has to have space, CRM-6977
+        //make sure we only have a single space, CRM-6977 and dev/mail/15
         if ($this->_gName == 'from_email_address') {
-          $params['label'] = str_replace('"<', '" <', $params['label']);
+          $params['label'] = $this->sanitizeFromEmailAddress($params['label']);
         }
       }
 
@@ -484,20 +484,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
         $params['color'] = 'null';
       }
 
-      $groupParams = array('name' => ($this->_gName));
-      $optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id);
-
-      // CRM-11516
-      if (!empty($params['financial_account_id'])) {
-        $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
-        $params = array(
-          'entity_table' => 'civicrm_option_value',
-          'entity_id' => $optionValue->id,
-          'account_relationship' => $relationTypeId,
-          'financial_account_id' => $params['financial_account_id'],
-        );
-        CRM_Financial_BAO_FinancialTypeAccount::add($params);
-      }
+      $optionValue = CRM_Core_OptionValue::addOptionValue($params, $this->_gName, $this->_action, $this->_id);
 
       CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(
             1 => $this->_gLabel,
@@ -508,4 +495,9 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
     }
   }
 
+  public function sanitizeFromEmailAddress($email) {
+    preg_match("/^\"(.*)\" *<([^@>]*@[^@>]*)>$/", $email, $parts);
+    return "\"{$parts[1]}\" <$parts[2]>";
+  }
+
 }