Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Deprecate BAO_Contact::retrieve #22966

Merged
merged 1 commit into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CRM/Contact/BAO/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,9 @@ public static function resolveDefaults(&$defaults, $reverse = FALSE) {
/**
* Fetch object based on array of properties.
*
* @deprecated This is called from a few places but creates rather than solves
* complexity.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
* @param array $defaults
Expand Down
16 changes: 7 additions & 9 deletions CRM/Contact/Form/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,13 @@ public function preProcess() {
$this->_values = $values;
}
else {
$params = [
'id' => $this->_contactId,
'contact_id' => $this->_contactId,
'noRelationships' => TRUE,
'noNotes' => TRUE,
'noGroups' => TRUE,
];

$contact = CRM_Contact_BAO_Contact::retrieve($params, $this->_values, TRUE);
CRM_Contact_BAO_Contact::getValues(['contact_id' => $this->_contactId], $this->_values);
$this->_values['im'] = CRM_Core_BAO_IM::getValues(['contact_id' => $this->_contactId]);
$this->_values['email'] = CRM_Core_BAO_Email::getValues(['contact_id' => $this->_contactId]);
$this->_values['openid'] = CRM_Core_BAO_OpenID::getValues(['contact_id' => $this->_contactId]);
$this->_values['phone'] = CRM_Core_BAO_Phone::getValues(['contact_id' => $this->_contactId]);
$this->_values['address'] = CRM_Core_BAO_Address::getValues(['contact_id' => $this->_contactId], TRUE);
CRM_Core_BAO_Website::getValues(['contact_id' => $this->_contactId], $this->_values);
$this->set('values', $this->_values);
}
}
Expand Down
28 changes: 17 additions & 11 deletions CRM/Contact/Page/View/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public function edit() {

/**
* View summary details of a contact.
*
* @throws \CRM_Core_Exception
*/
public function view() {
// Add js for tabs, in-place editing, and jstree for tags
Expand Down Expand Up @@ -146,9 +148,21 @@ public function 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($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') && $defaults['employer_id'] && $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']);
Expand Down Expand Up @@ -258,14 +272,6 @@ public function 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
Expand Down