dev/core/#/233 Use merged data api to display navigation help on contact deleted...
authoreileen <emcnaughton@wikimedia.org>
Tue, 17 Jul 2018 05:18:42 +0000 (17:18 +1200)
committereileen <emcnaughton@wikimedia.org>
Tue, 17 Jul 2018 07:33:39 +0000 (19:33 +1200)
CRM/Contact/Page/View.php

index aded97985116dd3ad3661141257d4dd9b9c47be2..4da77a244a8551831ac29fc50254fd366d7686ba 100644 (file)
@@ -306,7 +306,7 @@ class CRM_Contact_Page_View extends CRM_Core_Page {
    */
   public static function setTitle($contactId, $isDeleted = FALSE) {
     static $contactDetails;
-    $displayName = $contactImage = NULL;
+    $contactImage = NULL;
     if (!isset($contactDetails[$contactId])) {
       list($displayName, $contactImage) = self::getContactDetails($contactId);
       $contactDetails[$contactId] = array(
@@ -327,6 +327,15 @@ class CRM_Contact_Page_View extends CRM_Core_Page {
     }
     if ($isDeleted) {
       $title = "<del>{$title}</del>";
+      $mergedTo = civicrm_api3('Contact', 'getmergedto', ['contact_id' => $contactId, 'api.Contact.get' => ['return' => 'display_name']]);
+      if ($mergedTo['count']) {
+        $mergedToContactID = $mergedTo['id'];
+        $mergedToDisplayName = $mergedTo['values'][$mergedToContactID]['api.Contact.get']['values'][0]['display_name'];
+        $title .= ' ' . ts('(This contact has been merged to <a href="%1">%2</a>)', [
+            1 => CRM_Utils_System::url('civicrm/contact/view', ['reset' => 1, 'cid' => $mergedToContactID]),
+            2 => $mergedToDisplayName,
+          ]);
+      }
     }
 
     // Inline-edit places its own title on the page