Mwalker has submitted this change and it was merged.

Change subject: (FR #1378) preferred_language defaults to null
......................................................................


(FR #1378) preferred_language defaults to null

See http://issues.civicrm.org/jira/browse/CRM-14232

Change-Id: I7e904d30734070ad213bd9942048dc07c0de7fb9
---
M CRM/Admin/Form/Setting/Localization.php
M CRM/Contact/BAO/Contact.php
M CRM/Contact/Form/Edit/CommunicationPreferences.php
M CRM/Contact/Form/Inline/CommunicationPreferences.php
M CRM/Core/BAO/UFGroup.php
M CRM/Core/Config/Variables.php
M templates/CRM/Admin/Form/Setting/Localization.tpl
7 files changed, 33 insertions(+), 10 deletions(-)

Approvals:
  Mwalker: Looks good to me, approved



diff --git a/CRM/Admin/Form/Setting/Localization.php 
b/CRM/Admin/Form/Setting/Localization.php
index 784b18c..f689266 100644
--- a/CRM/Admin/Form/Setting/Localization.php
+++ b/CRM/Admin/Form/Setting/Localization.php
@@ -97,6 +97,8 @@
       }
     }
 
+    $this->addElement('checkbox', 'contactLanguageHasDefault', ts('New 
contacts have default language'));
+
     $this->addElement('checkbox', 'inheritLocale', ts('Inherit CMS Language'));
     $this->addElement('text', 'monetaryThousandSeparator', ts('Thousands 
Separator'), array('size' => 2));
     $this->addElement('text', 'monetaryDecimalPoint', ts('Decimal Delimiter'), 
array('size' => 2));
@@ -227,6 +229,10 @@
       $values['inheritLocale'] = 0;
     }
 
+    if (!isset($values['contactLanguageHasDefault'])) {
+      $values['contactLanguageHasDefault'] = 0;
+    }
+
     //cache contact fields retaining localized titles
     //though we changed localization, so reseting cache.
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php
index c204b66..406b2a9 100644
--- a/CRM/Contact/BAO/Contact.php
+++ b/CRM/Contact/BAO/Contact.php
@@ -267,8 +267,10 @@
     $config = CRM_Core_Config::singleton();
 
     // CRM-6942: set preferred language to the current language if it’s unset 
(and we’re creating a contact)
-    if (empty($params['contact_id']) && empty($params['preferred_language'])) {
-      $params['preferred_language'] = $config->lcMessages;
+    if ($config->contactLanguageHasDefault) {
+        if (empty($params['contact_id']) && 
empty($params['preferred_language'])) {
+          $params['preferred_language'] = $config->lcMessages;
+        }
     }
 
     // CRM-9739: set greeting & addressee if unset and we’re creating a contact
diff --git a/CRM/Contact/Form/Edit/CommunicationPreferences.php 
b/CRM/Contact/Form/Edit/CommunicationPreferences.php
index 6aa554a..8a22c1d 100644
--- a/CRM/Contact/Form/Edit/CommunicationPreferences.php
+++ b/CRM/Contact/Form/Edit/CommunicationPreferences.php
@@ -83,7 +83,7 @@
     $form->add('select', 'preferred_language',
       ts('Preferred Language'),
       array(
-        '' => ts('- select -')) +
+        '' => ts('- unknown -')) +
       CRM_Core_PseudoConstant::languages()
     );
 
@@ -169,9 +169,11 @@
     }
 
     // CRM-7119: set preferred_language to default if unset
-    if (empty($defaults['preferred_language'])) {
-      $config = CRM_Core_Config::singleton();
-      $defaults['preferred_language'] = $config->lcMessages;
+    if ($config->contactLanguageHasDefault) {
+      if (empty($defaults['preferred_language'])) {
+        $config = CRM_Core_Config::singleton();
+        $defaults['preferred_language'] = $config->lcMessages;
+      }
     }
 
     //set default from greeting types CRM-4575, CRM-9739
diff --git a/CRM/Contact/Form/Inline/CommunicationPreferences.php 
b/CRM/Contact/Form/Inline/CommunicationPreferences.php
index 553bd02..10a6e2f 100644
--- a/CRM/Contact/Form/Inline/CommunicationPreferences.php
+++ b/CRM/Contact/Form/Inline/CommunicationPreferences.php
@@ -119,9 +119,11 @@
     }
 
     // CRM-7119: set preferred_language to default if unset
-    if (empty($defaults['preferred_language'])) {
-      $config = CRM_Core_Config::singleton();
-      $defaults['preferred_language'] = $config->lcMessages;
+    if ($config->contactLanguageHasDefault) {
+      if (empty($defaults['preferred_language'])) {
+        $config = CRM_Core_Config::singleton();
+        $defaults['preferred_language'] = $config->lcMessages;
+      }
     }
 
     foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php
index 439d533..ec5d816 100644
--- a/CRM/Core/BAO/UFGroup.php
+++ b/CRM/Core/BAO/UFGroup.php
@@ -1738,7 +1738,7 @@
       $form->add('select', $name, $title, CRM_Core_SelectValues::pmf());
     }
     elseif ($fieldName === 'preferred_language') {
-      $form->add('select', $name, $title, array('' => ts('- select -')) + 
CRM_Core_PseudoConstant::languages());
+      $form->add('select', $name, $title, array('' => ts('- unknown -')) + 
CRM_Core_PseudoConstant::languages());
     }
     elseif ($fieldName == 'external_identifier') {
       $form->add('text', $name, $title, $attributes, $required);
diff --git a/CRM/Core/Config/Variables.php b/CRM/Core/Config/Variables.php
index a3aa027..73d2091 100644
--- a/CRM/Core/Config/Variables.php
+++ b/CRM/Core/Config/Variables.php
@@ -129,6 +129,12 @@
   public $lcMessages = 'en_US';
 
   /**
+   * Whether new contacts default to $lcMessages (if config is true), or null.
+   * @var boolean
+   */
+  public $contactLanguageHasDefault = true;
+
+  /**
    * String format for date+time
    * @var string
    */
diff --git a/templates/CRM/Admin/Form/Setting/Localization.tpl 
b/templates/CRM/Admin/Form/Setting/Localization.tpl
index 032a69f..759ec3a 100644
--- a/templates/CRM/Admin/Form/Setting/Localization.tpl
+++ b/templates/CRM/Admin/Form/Setting/Localization.tpl
@@ -32,6 +32,11 @@
                 <td>{$form.lcMessages.html}<br />
                 <span class="description">{ts}Default language used for this 
installation.{/ts}</span></td>
             </tr>
+            <tr class="crm-localization-form-block-contactLanguageHasDefault">
+                <td class="label">{$form.contactLanguageHasDefault.label}</td>
+                <td>{$form.contactLanguageHasDefault.html}<br />
+                <span class="description">{ts}New contacts without an explicit 
preferred_language will default to the site default language when this box is 
checked.  Otherwise, the contact language will default to empty, meaning it is 
unknown.{/ts}</span></td>
+            </tr>
            {if $form.languageLimit}
              <tr class="crm-localization-form-block-languageLimit"> 
                  <td class="label">{$form.languageLimit.label}</td>

-- 
To view, visit https://gerrit.wikimedia.org/r/114388
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7e904d30734070ad213bd9942048dc07c0de7fb9
Gerrit-PatchSet: 2
Gerrit-Project: wikimedia/fundraising/crm/civicrm
Gerrit-Branch: master
Gerrit-Owner: Adamw <awi...@wikimedia.org>
Gerrit-Reviewer: Katie Horn <kh...@wikimedia.org>
Gerrit-Reviewer: Mwalker <mwal...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to