Merge pull request #23537 from eileenmcnaughton/greet_cust
[civicrm-core.git] / CRM / Contact / BAO / Contact.php
index 0d586e08ad19fe3dd5383799663569254f5b40a8..1c5919312e9f952a44f94b5fcf7512e6d84367cc 100644 (file)
@@ -138,15 +138,18 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact implements Civi\Co
     }
     $params = array_merge($defaults, $params);
 
+    if (!empty($params['deceased_date']) && $params['deceased_date'] !== 'null') {
+      $params['is_deceased'] = TRUE;
+    }
     $allNull = $contact->copyValues($params);
 
     $contact->id = $contactID;
 
     if ($contact->contact_type === 'Individual') {
       $allNull = FALSE;
-      // @todo allow the lines below to be overridden by input or hooks & add tests,
-      // as has been done for households and organizations.
-      // Format individual fields.
+      // @todo get rid of this - most of this formatting should
+      // be done by time we get here - maybe start with some
+      // deprecation notices.
       CRM_Contact_BAO_Individual::format($params, $contact);
     }
 
@@ -503,6 +506,9 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact implements Civi\Co
     $missingGreetingParams = [];
 
     foreach ($allGreetingParams as $greetingIndex => $greetingParam) {
+      if (!empty($params[$greetingIndex . '_custom']) && empty($params[$greetingParam])) {
+        $params[$greetingParam] = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greetingParam, 'Customized');
+      }
       // An empty string means NULL
       if (($params[$greetingParam] ?? NULL) === '') {
         $params[$greetingParam] = 'null';