Fix the contact merge form on Drupal 8
authorDavid Snopek <dsnopek@gmail.com>
Wed, 18 Apr 2018 03:12:51 +0000 (22:12 -0500)
committerDavid Snopek <dsnopek@gmail.com>
Wed, 18 Apr 2018 03:12:51 +0000 (22:12 -0500)
CRM/Contact/Form/Merge.php
CRM/Utils/System/Drupal8.php
CRM/Utils/System/Joomla.php

index ba9cfce432262c099f83075baf0f8e4bb354f569..3066e68bf3658aad3db4eb61fc0c7b1fd4a5896d 100644 (file)
@@ -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;
index 9eaf10a912aa8ab492960157bd6a236fdb3650d2..a042a227fd26e31f4ed17b94928fe4a32b8ac40a 100644 (file)
@@ -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
    */
index 5def803e23f5d88216977beea2608294ba24c8ca..6c575ef5ab3698db6dce4596ebff41ce7bb552de 100644 (file)
@@ -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
    */