Merge pull request #5145 from agh1/case-insensitive-headers
[civicrm-core.git] / CRM / Core / BAO / CustomOption.php
index 2dd00e5ae0e626822f53dd880d93c8e7a53b9db7..7b01478cdb7a7447e42469251b5ee9d11cd1b7e4 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
 class CRM_Core_BAO_CustomOption {
 
   /**
-   * 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.
    * @param array $defaults
    *   (reference ) an assoc array to hold the flattened values.
    *
-   * @return CRM_Core_BAO_CustomOption object
-   * @static
+   * @return CRM_Core_BAO_CustomOption
    */
   public static function retrieve(&$params, &$defaults) {
     $customOption = new CRM_Core_DAO_OptionValue();
@@ -61,17 +60,17 @@ class CRM_Core_BAO_CustomOption {
   }
 
   /**
-   * Returns all active options ordered by weight for a given field
+   * Returns all active options ordered by weight for a given field.
    *
    * @param int $fieldID
    *   Field whose options are needed.
-   * @param boolean $inactiveNeeded
+   * @param bool $inactiveNeeded Do we need inactive options ?.
    *   Do we need inactive options ?.
    *
-   * @return array $customOption all active options for fieldId
-   * @static
+   * @return array
+   *   all active options for fieldId
    */
-  static function getCustomOption(
+  public static function getCustomOption(
     $fieldID,
     $inactiveNeeded = FALSE
   ) {
@@ -110,17 +109,17 @@ class CRM_Core_BAO_CustomOption {
    * Returns the option label for a custom field with a specific value. Handles all
    * custom field data and html types
    *
-   * @param $fieldId
-   *   Int the custom field ID.
+   * @param int $fieldId
+   *   the custom field ID.
    * @pram  $value    string the value (typically from the DB) of this custom field
    * @param $value
-   * @param $htmlType
-   *   String the html type of the field (optional).
-   * @param $dataType
-   *   String the data type of the field (optional).
+   * @param string $htmlType
+   *   the html type of the field (optional).
+   * @param string $dataType
+   *   the data type of the field (optional).
    *
-   * @return string          the label to display for this custom field
-   * @static
+   * @return string
+   *   the label to display for this custom field
    */
   public static function getOptionLabel($fieldId, $value, $htmlType = NULL, $dataType = NULL) {
     if (!$fieldId) {
@@ -153,7 +152,10 @@ WHERE  id = %1
       case 'Radio':
       case 'Autocomplete-Select':
         if (!in_array($dataType, array(
-          'Boolean', 'ContactReference'))) {
+          'Boolean',
+          'ContactReference',
+        ))
+        ) {
           $options = self::valuesByID($fieldId);
         }
     }
@@ -166,11 +168,11 @@ WHERE  id = %1
   }
 
   /**
-   * Delete Option
+   * Delete Option.
    *
-   * param $optionId integer option id
+   * @param $optionId integer
+   *   option id
    *
-   * @static
    */
   public static function del($optionId) {
     // get the customFieldID
@@ -186,8 +188,8 @@ AND    g.id    = v.option_group_id";
     $dao = CRM_Core_DAO::executeQuery($query, $params);
     if ($dao->fetch()) {
       if (in_array($dao->dataType,
-          array('Int', 'Float', 'Money', 'Boolean')
-        )) {
+        array('Int', 'Float', 'Money', 'Boolean')
+      )) {
         $value = 0;
       }
       else {
@@ -253,7 +255,8 @@ WHERE  id = %2";
             $dataType = $dao->dataType;
           }
           $queryParams = array(
-            1 => array($params['value'],
+            1 => array(
+              $params['value'],
               $dataType,
             ),
             2 => array(
@@ -268,10 +271,11 @@ WHERE  id = %2";
         case 'CheckBox':
           $oldString = CRM_Core_DAO::VALUE_SEPARATOR . $oldValue . CRM_Core_DAO::VALUE_SEPARATOR;
           $newString = CRM_Core_DAO::VALUE_SEPARATOR . $params['value'] . CRM_Core_DAO::VALUE_SEPARATOR;
-          $query     = "
+          $query = "
 UPDATE {$dao->tableName}
 SET    {$dao->columnName} = REPLACE( {$dao->columnName}, %1, %2 )";
-          $queryParams = array(1 => array($oldString, 'String'),
+          $queryParams = array(
+            1 => array($oldString, 'String'),
             2 => array($newString, 'String'),
           );
           break;
@@ -303,4 +307,5 @@ SET    {$dao->columnName} = REPLACE( {$dao->columnName}, %1, %2 )";
 
     return $options;
   }
+
 }