From 250b3b1f8022c5ca864be5ee009f3c0839957dd9 Mon Sep 17 00:00:00 2001 From: kurund Date: Mon, 28 Apr 2014 11:59:18 -0700 Subject: [PATCH] fatal error fixes due to bad merge CRM-14276 ---------------------------------------- * CRM-14276: Hook for display name https://issues.civicrm.org/jira/browse/CRM-14276 --- CRM/Contact/BAO/Contact.php | 39 ++++++++++++++----------------------- CRM/Utils/Hook.php | 16 +++++++++++++++ 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index de1c7827b8..aac6c599c4 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -461,7 +461,7 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { */ static function getDisplayAndImage($id, $type = FALSE) { //CRM-14276 added the * on the civicrm_contact table so that we have all the contact info available - $sql = " + $sql = " SELECT civicrm_contact.*, civicrm_email.email as email FROM civicrm_contact @@ -472,37 +472,28 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); $dao->query($sql); if ($dao->fetch()) { $image = CRM_Contact_BAO_Contact_Utils::getImage($dao->contact_sub_type ? - $dao->contact_sub_type : $dao->contact_type, FALSE, $id + $dao->contact_sub_type : $dao->contact_type, FALSE, $id ); $imageUrl = CRM_Contact_BAO_Contact_Utils::getImage($dao->contact_sub_type ? - $dao->contact_sub_type : $dao->contact_type, TRUE, $id + $dao->contact_sub_type : $dao->contact_type, TRUE, $id ); // use email if display_name is empty if (empty($dao->display_name)) { - $display_name = $dao->email; - } else { - $display_name = $dao->display_name; - } - - /** - * Issue CRM-14276 - * Add a hook for altering the display name - * - * hook_civicrm_contact_get_displayname(&$display_name, $objContact) - * @param String &$disply_name - * @param int $contactId - * @param object $objContact the contact object - */ - $hooks = CRM_Utils_Hook::singleton(); - $hooks->invoke(3, - $display_name, $id, $dao, CRM_Utils_Hook::$_nullObject, CRM_Utils_Hook::$_nullObject, - 'civicrm_contact_get_displayname' - ); + $displayName = $dao->email; + } + else { + $displayName = $dao->display_name; + } + + CRM_Utils_Hook::alterDisplayName($displayName, $id, $dao); return $type ? array( - $dao->display_name, $image, - $dao->contact_type, $dao->contact_sub_type, $imageUrl, + $dao->display_name, + $image, + $dao->contact_type, + $dao->contact_sub_type, + $imageUrl, ) : array($dao->display_name, $image, $imageUrl); } return NULL; diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 22419f4ce4..be3d2d421d 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -1546,4 +1546,20 @@ abstract class CRM_Utils_Hook { static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) { return self::singleton()->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, 'civicrm_post_case_merge'); } + + /** + * Issue CRM-14276 + * Add a hook for altering the display name + * + * hook_civicrm_contact_get_displayname(&$display_name, $objContact) + * @param string $displayName + * @param int $contactId + * @param object $dao the contact object + */ + static function alterDisplayName($displayName, $contactId, $dao) { + return self::singleton()->invoke(3, + $displayName, $contactId, $dao, self::$_nullObject, self::$_nullObject, + self::$_nullObject, 'civicrm_contact_get_displayname' + ); + } } -- 2.25.1