<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Core_BAO_CustomOption {
/**
- * Takes a bunch of params that are needed to match certain criteria and
- * retrieves the relevant objects. Typically the valid params are only
- * contact_id. We'll tweak this function to be more full featured over a period
- * of time. This is the inverse function of create. It also stores all the retrieved
- * values in the default array
+ * 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
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
+ * @param array $defaults
+ * (reference ) an assoc array to hold the flattened values.
*
- * @return object CRM_Core_BAO_CustomOption object
- * @access public
+ * @return CRM_Core_BAO_CustomOption object
* @static
*/
- static function retrieve(&$params, &$defaults) {
+ public static function retrieve(&$params, &$defaults) {
$customOption = new CRM_Core_DAO_OptionValue();
$customOption->copyValues($params);
if ($customOption->find(TRUE)) {
/**
* Returns all active options ordered by weight for a given field
*
- * @param $fieldID
- * @param boolean $inactiveNeeded do we need inactive options ?
+ * @param int $fieldID
+ * Field whose options are needed.
+ * @param bool $inactiveNeededDo we need inactive options ?.
+ * Do we need inactive options ?.
*
- * @internal param int $fieldId field whose options are needed
* @return array $customOption all active options for fieldId
* @static
*/
* 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 $fieldId
+ * Int 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 $htmlType
+ * String the html type of the field (optional).
+ * @param $dataType
+ * String the data type of the field (optional).
*
* @return string the label to display for this custom field
* @static
- * @access public
*/
- static function getOptionLabel($fieldId, $value, $htmlType = NULL, $dataType = NULL) {
+ public static function getOptionLabel($fieldId, $value, $htmlType = NULL, $dataType = NULL) {
if (!$fieldId) {
return NULL;
}
}
/**
- * Function to delete Option
+ * Delete Option
*
* param $optionId integer option id
*
* @static
- * @access public
*/
- static function del($optionId) {
+ public static function del($optionId) {
// get the customFieldID
$query = "
SELECT f.id as id, f.data_type as dataType
}
}
- static function updateCustomValues($params) {
+ /**
+ * @param array $params
+ *
+ * @throws Exception
+ */
+ public static function updateCustomValues($params) {
$optionDAO = new CRM_Core_DAO_OptionValue();
$optionDAO->id = $params['optionId'];
$optionDAO->find(TRUE);
$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;
}
}
- static function valuesByID($customFieldID, $optionGroupID = NULL) {
+ /**
+ * @param int $customFieldID
+ * @param int $optionGroupID
+ *
+ * @return array
+ */
+ public static function valuesByID($customFieldID, $optionGroupID = NULL) {
if (!$optionGroupID) {
$optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField',
$customFieldID,
return $options;
}
}
-