CRM-14312 include prefix/suffix when passing to contact create so display/sort name...
authorBrian Shaughnessy <brian@lcdservices.biz>
Tue, 4 Mar 2014 20:16:42 +0000 (15:16 -0500)
committerBrian Shaughnessy <brian@lcdservices.biz>
Tue, 4 Mar 2014 20:16:42 +0000 (15:16 -0500)
CRM/Dedupe/Merger.php

index 132c47987c55ddc6656096fc3464070f7f38c91d..36de5b7569d040efb3c25b5d3a5bf83a6fc8e78b 100644 (file)
@@ -879,12 +879,14 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
           if ($label === '1') {
             $label = ts('[x]');
           }
-        } elseif ($field == 'individual_prefix' || $field == 'prefix_id') {
-          $label = CRM_Utils_Array::value('prefix', $contact);
+        }
+        elseif ($field == 'individual_prefix' || $field == 'prefix_id') {
+          $label = CRM_Utils_Array::value('individual_prefix', $contact);
           $value = CRM_Utils_Array::value('prefix_id', $contact);
           $field = 'prefix_id';
-        } elseif ($field == 'individual_suffix' || $field == 'suffix_id') {
-          $label = CRM_Utils_Array::value('suffix', $contact);
+        }
+        elseif ($field == 'individual_suffix' || $field == 'suffix_id') {
+          $label = CRM_Utils_Array::value('individual_suffix', $contact);
           $value = CRM_Utils_Array::value('suffix_id', $contact);
           $field = 'suffix_id';
         }
@@ -1519,6 +1521,14 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         unset($submitted['current_employer_id']);
       }
 
+      //CRM-14312 include prefix/suffix from mainId if not overridden for proper construction of display/sort name
+      if ( !isset($submitted['prefix_id']) && !empty($migrationInfo['main_details']['prefix_id']) ) {
+        $submitted['prefix_id'] = $migrationInfo['main_details']['prefix_id'];
+      }
+      if ( !isset($submitted['suffix_id']) && !empty($migrationInfo['main_details']['suffix_id']) ) {
+        $submitted['suffix_id'] = $migrationInfo['main_details']['suffix_id'];
+      }
+
       CRM_Contact_BAO_Contact::createProfileContact($submitted, CRM_Core_DAO::$_nullArray, $mainId);
       unset($submitted);
     }