CRM_Utils_Array::lookupValue($defaults, 'prefix', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'), $reverse);
CRM_Utils_Array::lookupValue($defaults, 'suffix', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'), $reverse);
CRM_Utils_Array::lookupValue($defaults, 'gender', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), $reverse);
+ CRM_Utils_Array::lookupValue($defaults, 'communication_style', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id'), $reverse);
//lookup value of email/postal greeting, addressee, CRM-4575
foreach (self::$_greetingTypes as $greeting) {
if ($fieldName == 'gender_id') {
$this->_pseudoConstantsSelect['gender'] = array('pseudoField' => 'gender_id', 'idCol' => "gender_id", 'bao' => 'CRM_Contact_BAO_Contact');
}
+ if ($name == 'communication_style_id') {
+ $this->_pseudoConstantsSelect['communication_style'] = array('pseudoField' => 'communication_style_id', 'idCol' => "communication_style_id", 'bao' => 'CRM_Contact_BAO_Contact');
+ }
$this->_select[$name] = "contact_a.{$fieldName} as `$name`";
}
}
'prefix_id' => 1,
'suffix_id' => 1,
'formal_title' => 1,
+ 'communication_style_id' => 1,
'birth_date' => 1,
'gender_id' => 1,
'street_address' => 1,
'prefix_id' => 1,
'suffix_id' => 1,
'formal_title' => 1,
+ 'communication_style_id' => 1,
'email_greeting' => 1,
'postal_greeting' => 1,
'addressee' => 1,
$qill = $value;
}
- $pseudoFields = array('email_greeting', 'postal_greeting', 'addressee', 'gender_id', 'prefix_id', 'suffix_id');
+ $pseudoFields = array('email_greeting', 'postal_greeting', 'addressee', 'gender_id', 'prefix_id', 'suffix_id', 'communication_style_id');
if (is_numeric($value)) {
$qill = $selectValues[(int ) $value];
}
if (in_array($name, $pseudoFields)) {
- if (!in_array($name, array('gender_id', 'prefix_id', 'suffix_id'))) {
+ if (!in_array($name, array('gender_id', 'prefix_id', 'suffix_id', 'communication_style_id'))) {
$wc = "contact_a.{$name}_id";
}
$dataType = 'Positive';
$form->add('select', 'preferred_mail_format', ts('Email Format'), CRM_Core_SelectValues::pmf());
$form->add('checkbox', 'is_opt_out', ts('NO BULK EMAILS (User Opt Out)'));
+ $communicationStyleOptions = array();
+ $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id', array('localize' => TRUE));
+ foreach ($communicationStyle as $key => $var) {
+ $communicationStyleOptions[$key] = $form->createElement('radio', NULL,
+ ts('Communication Style'), $var, $key,
+ array('id' => "civicrm_communication_style_{$var}_{$key}")
+ );
+ }
+ if (!empty($communicationStyleOptions)) {
+ $form->addGroup($communicationStyleOptions, 'communication_style_id', ts('Communication Style'));
+ }
+
//check contact type and build filter clause accordingly for greeting types, CRM-4575
$greetings = self::getGreetingFields($form->_contactType);
$defaults['preferred_language'] = $config->lcMessages;
}
+ if (empty($defaults['communication_style_id'])) {
+ $defaults['communication_style_id'] = array_pop(CRM_Core_OptionGroup::values('communication_style', TRUE, NULL, NULL, 'AND is_default = 1'));
+ }
+
//set default from greeting types CRM-4575, CRM-9739
if ($form->_action & CRM_Core_Action::ADD) {
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
$defaults['preferred_language'] = $config->lcMessages;
}
+ if (empty($defaults['communication_style_id'])) {
+ $defaults['communication_style_id'] = array_pop(CRM_Core_OptionGroup::values('communication_style', TRUE, NULL, NULL, 'AND is_default = 1'));
+ }
+
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
$name = "{$greeting}_display";
$this->assign($name, CRM_Utils_Array::value($name, $defaults));
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);
$defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)];
}
+ $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'] = '';
+ }
+ }
+
// to make contact type label available in the template -
$contactType = array_key_exists('contact_sub_type', $defaults) ? $defaults['contact_sub_type'] : $defaults['contact_type'];
$defaults['contact_type_label'] = CRM_Contact_BAO_ContactType::contactTypePairs(TRUE, $contactType, ', ');
'gender' => 'gender_id',
'individual_prefix' => 'prefix_id',
'individual_suffix' => 'suffix_id',
+ 'communication_style' => 'communication_style_id', // Not only Individuals -- but the code seems to be generic for all contact types, despite the naming...
);
$contributions = array('payment_instrument' => 'payment_instrument_id');
$activities = array('activity_type' => 'activity_type_id');
$names['gender'] = array('newName' => 'gender_id', 'groupName' => 'gender');
$names['individual_prefix'] = array('newName' => 'prefix_id', 'groupName' => 'individual_prefix');
$names['individual_suffix'] = array('newName' => 'suffix_id', 'groupName' => 'individual_suffix');
+ $names['communication_style'] = array('newName' => 'communication_style_id', 'groupName' => 'communication_style');
$names['addressee'] = array('newName' => 'addressee_id', 'groupName' => 'addressee');
$names['email_greeting'] = array('newName' => 'email_greeting_id', 'groupName' => 'email_greeting');
$names['postal_greeting'] = array('newName' => 'postal_greeting_id', 'groupName' => 'postal_greeting');
$values[$index] = '';
}
}
- elseif (in_array(substr($name, 0, -3), array('gender', 'prefix', 'suffix'))) {
+ elseif (in_array(substr($name, 0, -3), array('gender', 'prefix', 'suffix', 'communication_style'))) {
$values[$index] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', $name, $params[$name]);
}
elseif (in_array($name, array(
elseif ($field == 'pledge_next_pay_amount') {
$row[$field] = $dao->pledge_next_pay_amount + $dao->pledge_outstanding_amount;
}
- elseif (in_array(substr($field, 0, -3), array('gender', 'prefix', 'suffix'))) {
+ elseif (in_array(substr($field, 0, -3), array('gender', 'prefix', 'suffix', 'communication_style'))) {
$row[$field] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', $field, $dao->$field);
}
elseif (is_array($value) && $field == 'location') {
case 'gender':
case 'preferred_communication_method':
case 'preferred_mail_format':
+ case 'communication_style':
$row[$field] = $i18n->crm_translate($fieldValue);
break;
ALTER TABLE `civicrm_contact`
ADD COLUMN `formal_title` varchar(64) COMMENT 'Formal (academic or similar) title in front of name. (Prof., Dr. etc.)' AFTER `suffix_id`;
+
+ALTER TABLE `civicrm_contact`
+ ADD COLUMN `communication_style_id` int(10) unsigned COMMENT 'Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.' AFTER `formal_title`,
+ ADD INDEX `index_communication_style_id` (`communication_style_id`);
+
+INSERT INTO
+ `civicrm_option_group` (`name`, {localize field='title'}`title`{/localize}, `is_reserved`, `is_active`)
+VALUES
+ ('communication_style', {localize}'{ts escape="sql"}Communication Style{/ts}'{/localize}, 1, 1);
+
+SELECT @option_group_id_communication_style := max(id) from civicrm_option_group where name = 'communication_style';
+
+INSERT INTO
+ `civicrm_option_value` (`option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
+VALUES
+ (@option_group_id_communication_style, {localize}'{ts escape="sql"}Formal{/ts}'{/localize} , 1, 'formal' , NULL, 0, 1, 1, NULL, 0, 0, 1, NULL, NULL),
+ (@option_group_id_communication_style, {localize}'{ts escape="sql"}Familiar{/ts}'{/localize}, 2, 'familiar', NULL, 0, 0, 2, NULL, 0, 0, 1, NULL, NULL);
'contact.organization_name' => CRM_Utils_Array::value('display_name', $fields),
'contact.legal_name' => CRM_Utils_Array::value('legal_name', $fields),
'contact.preferred_communication_method' => CRM_Utils_Array::value('preferred_communication_method', $fields),
+ 'contact.communication_style' => CRM_Utils_Array::value('communication_style', $fields),
'contact.addressee' => CRM_Utils_Array::value('addressee_display', $fields),
'contact.email_greeting' => CRM_Utils_Array::value('email_greeting_display', $fields),
'contact.postal_greeting' => CRM_Utils_Array::value('postal_greeting_display', $fields),
'status_id' => 'activity_status_id',
'priority_id' => 'activity_priority_id',
'medium_id' => 'encounter_medium',
+ 'communication_style_id' => 'communication_style',
'email_greeting' => 'email_greeting',
'postal_greeting' => 'postal_greeting',
'addressee_id' => 'addressee',
'individual_prefix' => 'prefix_id',
'individual_suffix' => 'suffix_id',
'gender' => 'gender_id',
+ 'communication_style' => 'communication_style_id',
);
}
<p>{ts}You can use an address belonging to an existing contact or create a new contact by selecting the desired contact type from the select field. If you link an individual's address to an organization, an employee-employer relationship will be automatically created. If you link an individual's address to a household, a household member relationship is created.{/ts}</p>
{/htxt}
+{htxt id="id-communication_style-title"}
+ {ts}Communication Style{/ts}
+{/htxt}
+{htxt id="id-communication_style"}
+<p>{ts}Choose how you communicate with this contact, e.g. on formal or familiar terms.{/ts}</p>
+<p>{ts}Depending on the CiviCRM setup, email and postal greetings (see below) may be automatically adapted accordingly; or the information can be used in other ways.{/ts}</p>
+{/htxt}
+
{htxt id="id-greeting-title"}
{ts}Greeting{/ts}
{/htxt}
</div><!-- /.crm-accordion-header -->
<div id="commPrefs" class="crm-accordion-body">
<table class="form-layout-compressed" >
+ {if !empty($form.communication_style_id)}
+ <tr><td colspan='4'>
+ <span class="label">{$form.communication_style_id.label} {help id="id-communication_style" file="CRM/Contact/Form/Contact.hlp"}</span>
+ <span class="value">{$form.communication_style_id.html}</span>
+ </td><tr>
+ {/if}
<tr>
{if !empty($form.email_greeting_id)}
<td>{$form.email_greeting_id.label}</td>
</div>
{/if}
+ {if !empty($form.communication_style_id)}
+ <div class="crm-summary-row">
+ <div class="crm-label">
+ {$form.communication_style_id.label} {help id="id-communication_style" file="CRM/Contact/Form/Contact.hlp"}
+ </div>
+ <div class="crm-content">
+ {$form.communication_style_id.html}
+ </div>
+ </div>
+ {/if}
+
{if !empty($form.email_greeting_id)}
<div class="crm-summary-row">
<div class="crm-label">{$form.email_greeting_id.label}</div>
{$preferred_mail_format}
</div>
</div>
+ {if isset($communication_style_display)}
+ <div class="crm-summary-row">
+ <div class="crm-label">{ts}Communication Style{/ts}</div>
+ <div class="crm-content crm-contact-communication_style_display">
+ {$communication_style_display}
+ </div>
+ </div>
+ {/if}
<div class="crm-summary-row">
<div class="crm-label">{ts}Email Greeting{/ts}</div>
<div class="crm-content crm-contact-email_greeting_display">
<comment>Formal (academic or similar) title in front of name. (Prof., Dr. etc.)</comment>
<add>4.5</add>
</field>
+ <field>
+ <name>communication_style_id</name>
+ <title>Communication Style</title>
+ <type>int unsigned</type>
+ <pseudoconstant>
+ <optionGroupName>communication_style</optionGroupName>
+ </pseudoconstant>
+ <export>true</export>
+ <comment>Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.</comment>
+ <add>4.4</add>
+ </field>
+ <index>
+ <name>index_communication_style_id</name>
+ <fieldName>communication_style_id</fieldName>
+ <add>4.4</add>
+ </index>
<field>
<name>greeting_type</name>
<type>varchar</type>
('financial_account_type' , '{ts escape="sql"}Financial Account Type{/ts}' , 1, 1),
('financial_item_status' , '{ts escape="sql"}Financial Item Status{/ts}' , 1, 1),
('label_type' , '{ts escape="sql"}Label Type{/ts}' , 1, 1),
- ('name_badge' , '{ts escape="sql"}Name Badge Format{/ts}' , 1, 1);
+ ('name_badge' , '{ts escape="sql"}Name Badge Format{/ts}' , 1, 1),
+ ('communication_style' , '{ts escape="sql"}Communication Style{/ts}' , 1, 1);
SELECT @option_group_id_pcm := max(id) from civicrm_option_group where name = 'preferred_communication_method';
SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
SELECT @option_group_id_financial_item_status := max(id) from civicrm_option_group where name = 'financial_item_status';
SELECT @option_group_id_label_type := max(id) from civicrm_option_group where name = 'label_type';
SELECT @option_group_id_name_badge := max(id) from civicrm_option_group where name = 'name_badge';
+SELECT @option_group_id_communication_style := max(id) from civicrm_option_group where name = 'communication_style';
SELECT @contributeCompId := max(id) FROM civicrm_component where name = 'CiviContribute';
(@option_group_id_label, '{ts escape="sql"}Avery L7160{/ts}', '{literal}{"paper-size":"a4","orientation":"portrait","font-name":"helvetica","font-size":9,"font-style":"","metric":"in","lMargin":0.28,"tMargin":0.6,"NX":3,"NY":7,"SpaceX":0.1,"SpaceY":0,"width":2.5,"height":1.5,"lPadding":0.20,"tPadding":0.20}{/literal}', 'L7160', 'Avery', NULL, 0, 8, NULL, 0, 1, 1, NULL, NULL),
(@option_group_id_label, '{ts escape="sql"}Avery L7161{/ts}', '{literal}{"paper-size":"a4","orientation":"portrait","font-name":"helvetica","font-size":9,"font-style":"","metric":"in","lMargin":0.28,"tMargin":0.35,"NX":3,"NY":6,"SpaceX":0.1,"SpaceY":0,"width":2.5,"height":1.83,"lPadding":0.20,"tPadding":0.20}{/literal}', 'L7161', 'Avery', NULL, 0, 9, NULL, 0, 1, 1, NULL, NULL),
(@option_group_id_label, '{ts escape="sql"}Avery L7162{/ts}', '{literal}{"paper-size":"a4","orientation":"portrait","font-name":"helvetica","font-size":9,"font-style":"","metric":"in","lMargin":0.18,"tMargin":0.51,"NX":2,"NY":8,"SpaceX":0.1,"SpaceY":0,"width":3.9,"height":1.33,"lPadding":0.20,"tPadding":0.20}{/literal}', 'L7162', 'Avery', NULL, 0, 10, NULL, 0, 1, 1, NULL, NULL),
- (@option_group_id_label, '{ts escape="sql"}Avery L7163{/ts}', '{literal}{"paper-size":"a4","orientation":"portrait","font-name":"helvetica","font-size":9,"font-style":"","metric":"in","lMargin":0.18,"tMargin":0.6,"NX":2,"NY":7,"SpaceX":0.1,"SpaceY":0,"width":3.9,"height":1.5,"lPadding":0.20,"tPadding":0.20}{/literal}', 'L7163', 'Avery', NULL, 0, 11, NULL, 0, 1, 1, NULL, NULL);
+ (@option_group_id_label, '{ts escape="sql"}Avery L7163{/ts}', '{literal}{"paper-size":"a4","orientation":"portrait","font-name":"helvetica","font-size":9,"font-style":"","metric":"in","lMargin":0.18,"tMargin":0.6,"NX":2,"NY":7,"SpaceX":0.1,"SpaceY":0,"width":3.9,"height":1.5,"lPadding":0.20,"tPadding":0.20}{/literal}', 'L7163', 'Avery', NULL, 0, 11, NULL, 0, 1, 1, NULL, NULL),
+
+-- Communication Styles
+ (@option_group_id_communication_style, '{ts escape="sql"}Formal{/ts}' , 1, 'formal' , NULL, 0, 1, 1, NULL, 0, 0, 1, NULL, NULL),
+ (@option_group_id_communication_style, '{ts escape="sql"}Familiar{/ts}', 2, 'familiar', NULL, 0, 0, 2, NULL, 0, 0, 1, NULL, NULL);
-- financial accounts
SELECT @opval := value FROM civicrm_option_value WHERE name = 'Revenue' and option_group_id = @option_group_id_fat;