Merge pull request #4423 from PalanteJon/aclReportFix-4.5
[civicrm-core.git] / CRM / Contact / Form / Edit / CommunicationPreferences.php
index aa2bc1952d4b82b62d6f0c3c76c2649044a54c8a..1c0fa4b09174aa902849d19e289c43a878711073 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -79,12 +79,7 @@ class CRM_Contact_Form_Edit_CommunicationPreferences {
     }
     $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Method(s)'));
 
-    $form->add('select', 'preferred_language',
-      ts('Preferred Language'),
-      array(
-        '' => ts('- select -')) +
-      CRM_Contact_BAO_Contact::buildOptions('preferred_language')
-    );
+    $form->addSelect('preferred_language');
 
     if (!empty($privacyOptions)) {
       $commPreference['privacy'] = $privacyOptions;
@@ -138,9 +133,11 @@ class CRM_Contact_Form_Edit_CommunicationPreferences {
   /**
    * global form rule
    *
-   * @param array $fields  the input form values
-   * @param array $files   the uploaded files if any
-   * @param array $options additional user data
+   * @param array $fields the input form values
+   * @param array $files the uploaded files if any
+   * @param $self
+   *
+   * @internal param array $options additional user data
    *
    * @return true if no errors, else array of errors
    * @access public
@@ -152,9 +149,7 @@ class CRM_Contact_Form_Edit_CommunicationPreferences {
     $greetings = self::getGreetingFields($self->_contactType);
     foreach ($greetings as $greeting => $details) {
       $customizedValue = CRM_Core_OptionGroup::getValue($greeting, 'Customized', 'name');
-      if (CRM_Utils_Array::value($details['field'], $fields) == $customizedValue
-        && !CRM_Utils_Array::value($details['customField'], $fields)
-      ) {
+      if (CRM_Utils_Array::value($details['field'], $fields) == $customizedValue && empty($fields[$details['customField']])) {
         $errors[$details['customField']] = ts('Custom  %1 is a required field if %1 is of type Customized.',
           array(1 => $details['label'])
         );
@@ -169,6 +164,9 @@ class CRM_Contact_Form_Edit_CommunicationPreferences {
    *
    * @access public
    *
+   * @param $form
+   * @param $defaults
+   *
    * @return void
    */
   static function setDefaultValues(&$form, &$defaults) {
@@ -211,6 +209,8 @@ class CRM_Contact_Form_Edit_CommunicationPreferences {
   /**
    *  set array of greeting fields
    *
+   * @param $contactType
+   *
    * @return void
    * @access public
    */