Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-03-14-00-44-17
[civicrm-core.git] / CRM / Contact / BAO / Contact.php
index fafe395c9a32d47670f6a0a9739c145c6db20b7e..a253462abd86685f76287991f38f630e3909743d 100644 (file)
@@ -223,21 +223,11 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact {
       );
     }
 
-    if ($contact->contact_type == 'Individual' &&
-      (isset($params['current_employer']) ||
-      isset($params['employer_id'])
-    )
-    ) {
+    if ($contact->contact_type == 'Individual' && (isset($params['current_employer']) || isset($params['employer_id']))) {
+      $newEmployer = !empty($params['employer_id']) ? $params['employer_id'] : CRM_Utils_Array::value('current_employer', $params);
       // create current employer
-      if (isset($params['employer_id'])) {
-        CRM_Contact_BAO_Contact_Utils::createCurrentEmployerRelationship($contact->id,
-          $params['employer_id'], $employerId
-        );
-      }
-      elseif ($params['current_employer']) {
-        CRM_Contact_BAO_Contact_Utils::createCurrentEmployerRelationship($contact->id,
-          $params['current_employer']
-        );
+      if ($newEmployer) {
+        CRM_Contact_BAO_Contact_Utils::createCurrentEmployerRelationship($contact->id, $newEmployer, $employerId);
       }
       else {
         //unset if employer id exits
@@ -2381,7 +2371,8 @@ AND       civicrm_openid.is_primary = 1";
       $values['preferred_communication_method'] = $preffComm;
       $values['preferred_communication_method_display'] = CRM_Utils_Array::value('preferred_communication_method_display', $temp);
 
-      CRM_Contact_DAO_Contact::addDisplayEnums($values);
+      $preferredMailingFormat = CRM_Core_SelectValues::pmf();
+      $values['preferred_mail_format'] = $preferredMailingFormat[$contact->preferred_mail_format];
 
       // get preferred languages
       if (!empty($contact->preferred_language)) {