Introduce new `communication_style` field for Contacts
[civicrm-core.git] / CRM / Contact / Page / Inline / CommunicationPreferences.php
index 445b6a60b8b29d8b7a7b7e3a92363c5b75629f73..30e95eb1cd94d17834682f5aa72182fcc2030150 100644 (file)
@@ -58,6 +58,17 @@ class CRM_Contact_Page_Inline_CommunicationPreferences extends CRM_Core_Page {
     CRM_Contact_BAO_Contact::getValues( $params, $defaults );
     $defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
 
+    $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id');
+    if (!empty($communicationStyle)) {
+      if (CRM_Utils_Array::value('communication_style_id', $defaults)) {
+        $defaults['communication_style_display'] = $communicationStyle[CRM_Utils_Array::value('communication_style_id', $defaults)];
+      }
+      else {
+        // Make sure the field is displayed as long as it is active, even if it is unset for this contact.
+        $defaults['communication_style_display'] = '';
+      }
+    }
+
     $this->assign('contactId', $contactId);
     $this->assign($defaults);