Merge pull request #23008 from eileenmcnaughton/temp_selected
[civicrm-core.git] / CRM / Contact / Page / View / Summary.php
index 0408f9a1143e869b6cc9e090eb554292241dd736..d49f41c691d1da7982793cb254e1425e810d0f2a 100644 (file)
@@ -103,6 +103,8 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
 
   /**
    * View summary details of a contact.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function view() {
     // Add js for tabs, in-place editing, and jstree for tags
@@ -146,9 +148,21 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
       'website' => [],
     ];
 
-    $params['id'] = $params['contact_id'] = $this->_contactId;
-    $params['noRelationships'] = $params['noNotes'] = $params['noGroups'] = TRUE;
-    $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, TRUE);
+    $params['contact_id'] = $this->_contactId;
+
+    CRM_Contact_BAO_Contact::getValues(array_merge(['id' => $this->_contactId], $params), $defaults);
+    $defaults['im'] = CRM_Core_BAO_IM::getValues(['contact_id' => $params['contact_id']]);
+    $defaults['email'] = CRM_Core_BAO_Email::getValues(['contact_id' => $params['contact_id']]);
+    $defaults['openid'] = CRM_Core_BAO_OpenID::getValues(['contact_id' => $params['contact_id']]);
+    $defaults['phone'] = CRM_Core_BAO_Phone::getValues(['contact_id' => $params['contact_id']]);
+    $defaults['address'] = CRM_Core_BAO_Address::getValues(['contact_id' => $params['contact_id']], TRUE);
+    CRM_Core_BAO_Website::getValues($params, $defaults);
+    // Copy employer fields to the current_employer keys.
+    if (($defaults['contact_type'] === 'Individual') && !empty($defaults['employer_id']) && !empty($defaults['organization_name'])) {
+      $defaults['current_employer'] = $defaults['organization_name'];
+      $defaults['current_employer_id'] = $defaults['employer_id'];
+    }
+
     // Let summary page know if outbound mail is disabled so email links can be built conditionally
     $mailingBackend = Civi::settings()->get('mailing_backend');
     $this->assign('mailingOutboundOption', $mailingBackend['outBound_option']);
@@ -258,14 +272,6 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
     }
     $this->assign('sharedAddresses', $sharedAddresses);
 
-    //get the current employer name
-    if (CRM_Utils_Array::value('contact_type', $defaults) == 'Individual') {
-      if ($contact->employer_id && $contact->organization_name) {
-        $defaults['current_employer'] = $contact->organization_name;
-        $defaults['current_employer_id'] = $contact->employer_id;
-      }
-    }
-
     $this->assign($defaults);
 
     // FIXME: when we sort out TZ isssues with DATETIME/TIMESTAMP, we can skip next query