Test fixes for All kind of Custom Values
[civicrm-core.git] / CRM / Core / BAO / UFField.php
index 0781e9e5549e98d4704f3e6c52f2f3330caad144..83d56486b79d1c523fedc64661f5b903a5b799bd 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
 class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField {
 
   /**
-   * Batch entry fields
+   * Batch entry fields.
    */
   private static $_contriBatchEntryFields = NULL;
   private static $_memberBatchEntryFields = NULL;
 
 
   /**
-   * Fetch object based on array of properties
+   * Fetch object based on array of properties.
    *
    * @param array $params
    *   (reference ) an assoc array of name/value pairs.
@@ -75,7 +75,7 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField {
   }
 
   /**
-   * Update the is_active flag in the db
+   * Update the is_active flag in the db.
    *
    * @param int $id
    *   Id of the database record.
@@ -106,7 +106,7 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField {
    * @param int $id
    *   Field Id.
    *
-   * @return boolean
+   * @return bool
    *
    */
   public static function del($id) {
@@ -118,7 +118,7 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField {
   }
 
   /**
-   * Check duplicate for duplicate field in a group
+   * Check duplicate for duplicate field in a group.
    *
    * @param array $params
    *   An associative array with field and values.
@@ -191,7 +191,7 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1";
   }
 
   /**
-   * Add the UF Field
+   * Add the UF Field.
    *
    * @param array $params
    *   (reference) array containing the values submitted by the form.
@@ -247,7 +247,7 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1";
   }
 
   /**
-   * Automatically determine one weight and modify others
+   * Automatically determine one weight and modify others.
    *
    * @param array $params
    *   UFField record, e.g. with 'weight', 'uf_group_id', and 'field_id'.
@@ -310,7 +310,7 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1";
   }
 
   /**
-   * Delete profile field given a custom field
+   * Delete profile field given a custom field.
    *
    * @param int $customFieldId
    *   ID of the custom field to be deleted.
@@ -356,11 +356,11 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1";
   }
 
   /**
-   * Check the status of custom field used in uf fields
+   * Check the status of custom field used in uf fields.
    *
    * @param int $UFFieldId
    *
-   * @return boolean
+   * @return bool
    *   false if custom field are disabled else true
    */
   public static function checkUFStatus($UFFieldId) {
@@ -450,11 +450,11 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1";
    * @param array $optional
    *   Array of types those are optional.
    *
-   * @return boolean
+   * @return bool
    */
   public static function checkValidProfileType($ufGroupId, $required, $optional = NULL) {
     if (!is_array($required) || empty($required)) {
-      return;
+      return FALSE;
     }
 
     $ufGroup = new CRM_Core_DAO_UFGroup();
@@ -569,7 +569,6 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1";
    * @return string
    *   profile group_type
    *
-   * TODO Why is this function in this class? It seems to be about the UFGroup.
    */
   public static function getProfileType($ufGroupId, $returnMixType = TRUE, $onlyPure = FALSE, $skipComponentType = FALSE) {
     $ufGroup = new CRM_Core_DAO_UFGroup();
@@ -590,10 +589,8 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1";
    *   True if only pure profiles are required.
    * @param bool $skipComponentType
    *
-   * @return string
-   *   profile group_type
+   * @return string  profile group_type
    *
-   * TODO Why is this function in this class? It seems to be about the UFGroup.
    */
   public static function calculateProfileType($ufGroupType, $returnMixType = TRUE, $onlyPure = FALSE, $skipComponentType = FALSE) {
     // profile types
@@ -728,7 +725,7 @@ SELECT ufg.id as id
    *
    * @param int $profileID
    *
-   * @return boolean
+   * @return bool
    */
   public static function checkSearchableORInSelector($profileID) {
     $result = FALSE;
@@ -802,7 +799,7 @@ SELECT  id
         'return' => 'field_name, is_required',
         'options' => array(
           'limit' => 0,
-        )
+        ),
       )
     ));
     //check for valid fields ( fields that are present in billing block )
@@ -831,7 +828,7 @@ SELECT  id
     }
 
     if (!in_array($prefixName, $validProfileFields)) {
-      return;
+      return FALSE;
     }
 
     if (!empty($index) && (
@@ -856,7 +853,7 @@ SELECT  id
   }
 
   /**
-   * Get a list of fields which can be added to profiles
+   * Get a list of fields which can be added to profiles.
    *
    * @param int $gid : UF group ID
    * @param array $defaults : Form defaults
@@ -1029,7 +1026,7 @@ SELECT  id
     ));
     //unset selected fields
     foreach ($groupFieldList as $key => $value) {
-      if (is_integer($key)) {
+      if (is_int($key)) {
         unset($fields['Individual'][$value], $fields['Household'][$value], $fields['Organization'][$value]);
         continue;
       }
@@ -1046,7 +1043,7 @@ SELECT  id
   }
 
   /**
-   * Get a list of fields which can be added to profiles
+   * Get a list of fields which can be added to profiles.
    *
    * @param bool $force
    *
@@ -1071,7 +1068,7 @@ SELECT  id
   }
 
   /**
-   * Determine whether the given field_name is valid
+   * Determine whether the given field_name is valid.
    *
    * @param string $fieldName
    * @return bool
@@ -1154,4 +1151,5 @@ SELECT  id
     }
     return self::$_memberBatchEntryFields;
   }
+
 }