Last active
December 28, 2015 01:29
-
-
Save cravecode/7420720 to your computer and use it in GitHub Desktop.
Corrects the issue that causes non-billing primary address from showing in the my account drupal profile fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php | |
index e721f2c..25c50c3 100644 | |
--- a/CRM/Core/BAO/UFGroup.php | |
+++ b/CRM/Core/BAO/UFGroup.php | |
@@ -2128,6 +2128,16 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) | |
$defaults[$fldName] = $details[$name]; | |
} | |
} | |
+ else if($locTypeId == 1 && is_string($value)) { | |
+ $trimmed_field_name = str_replace('-Primary', '', $fldName); | |
+ // Select elements need special naming fixes to append "_id". | |
+ if(array_key_exists($fldName, $fields) && (stripos($fldName, 'country') !== false || stripos($fldName, 'state') !== false)) { | |
+ $trimmed_field_name .= '_id'; | |
+ } | |
+ if(array_key_exists($contactId, $contactDetails) && array_key_exists($trimmed_field_name, $contactDetails[$contactId][1])) { | |
+ $defaults[$fldName] = $contactDetails[$contactId][1][$trimmed_field_name]; | |
+ } | |
+ } | |
else { | |
list($fieldName, $locTypeId, $phoneTypeId) = CRM_Utils_System::explode('-', $name, 3); | |
if (!in_array($fieldName, $multipleFields)) { | |
@@ -2136,7 +2146,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) | |
// when we fixed CRM-5319 - get primary loc | |
// type as per loc field and removed below code. | |
if ($locTypeId == 'Primary') { | |
- $locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactId); | |
+ $locTypeId = 1;//CRM_Contact_BAO_Contact::getPrimaryLocationType($contactId); | |
} | |
// fixed for CRM-665 | |
@@ -2192,6 +2202,11 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) | |
$defaults[$fldName] = $value[substr($fieldName, 8)]; | |
} | |
} | |
+ else if($locTypeId == 1 && is_string($value)) { | |
+ if(array_key_exists($value, $contactDetails) && array_key_exists($fieldName, $contactDetails[$value][1])) { | |
+ $defaults[$fldName] = $contactDetails[$value][1][$fieldName]; | |
+ } | |
+ } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment