+ $defaults = [
+ // Set empty default values for these - they will be overwritten when the contact is
+ // loaded in CRM_Contact_BAO_Contact::retrieve if there are real values
+ // but since we are not using apiV4 they will be left unset if empty.
+ // However, the wind up assigned as smarty variables so we ensure they are set to prevent e-notices
+ // used by ContactInfo.tpl
+ 'job_title' => '',
+ 'current_employer_id' => '',
+ 'nick_name' => '',
+ 'legal_name' => '',
+ 'source' => '',
+ 'sic_code' => '',
+ 'external_identifier' => '',
+ // for CommunicationPreferences.tpl
+ 'postal_greeting_custom' => '',
+ 'email_greeting_custom' => '',
+ 'addressee_custom' => '',
+ 'communication_style_display' => '',
+ // for Demographics.tpl
+ 'age' => ['y' => '', 'm' => ''],
+ 'birth_date' => '',
+ // for Website.tpl (the others don't seem to enotice for some reason).
+ 'website' => [],
+ ];
+
+ $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'];
+ }