From cff0c9aa28a2333fabce5030790b55dd07455f09 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Tue, 17 Apr 2018 22:12:51 -0500 Subject: [PATCH] Fix the contact merge form on Drupal 8 --- CRM/Contact/Form/Merge.php | 22 ++++------------------ CRM/Utils/System/Drupal8.php | 10 ++++++++++ CRM/Utils/System/Joomla.php | 10 ++++++++++ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/CRM/Contact/Form/Merge.php b/CRM/Contact/Form/Merge.php index ba9cfce432..3066e68bf3 100644 --- a/CRM/Contact/Form/Merge.php +++ b/CRM/Contact/Form/Merge.php @@ -120,16 +120,9 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $mainUfId = CRM_Core_BAO_UFMatch::getUFId($this->_cid); $mainUser = NULL; if ($mainUfId) { - // d6 compatible - if ($config->userSystem->is_drupal == '1') { - $mainUser = user_load($mainUfId); - } - elseif ($config->userFramework == 'Joomla') { - $mainUser = JFactory::getUser($mainUfId); - } - + $mainUser = $config->userSystem->getUser($this->_cid); $this->assign('mainUfId', $mainUfId); - $this->assign('mainUfName', $mainUser ? $mainUser->name : NULL); + $this->assign('mainUfName', $mainUser ? $mainUser['name'] : NULL); } $flipParams = array_merge($urlParams, ['action' => 'update', 'cid' => $this->_oid, 'oid' => $this->_cid]); if (!$flip) { @@ -164,16 +157,9 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $otherUser = NULL; if ($otherUfId) { - // d6 compatible - if ($config->userSystem->is_drupal == '1') { - $otherUser = user_load($otherUfId); - } - elseif ($config->userFramework == 'Joomla') { - $otherUser = JFactory::getUser($otherUfId); - } - + $otherUser = $config->userSystem->getUser($this->_oid); $this->assign('otherUfId', $otherUfId); - $this->assign('otherUfName', $otherUser ? $otherUser->name : NULL); + $this->assign('otherUfName', $otherUser ? $otherUser['name'] : NULL); } $cmsUser = ($mainUfId && $otherUfId) ? TRUE : FALSE; diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index 9eaf10a912..a042a227fd 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -569,6 +569,16 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { return $modules; } + /** + * @inheritDoc + */ + public function getUser($contactID) { + $user_details = parent::getUser($contactID); + $user_details['name'] = $user_details['name']->value; + $user_details['email'] = $user_details['email']->value; + return $user_details; + } + /** * @inheritDoc */ diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index 5def803e23..6c575ef5ab 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -638,6 +638,16 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { return $this->getUniqueIdentifierFromUserObject($user); } + /** + * @inheritDoc + */ + public function getUser($contactID) { + $user_details = parent::getUser($contactID); + $user = JFactory::getUser($user_details['id']); + $user_details['name'] = $user->name; + return $user_details; + } + /** * @inheritDoc */ -- 2.25.1