<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
'grant_type',
);
+ /**
+ * @param CRM_Core_DAO $dao
+ * @param bool $flip
+ * @param bool $grouping
+ * @param bool $localize
+ * @param string $valueColumnName
+ *
+ * @return array
+ */
static function &valuesCommon(
$dao, $flip = FALSE, $grouping = FALSE,
$localize = FALSE, $valueColumnName = 'label'
* (radio, select, checkbox etc). OptionGroups for most cases have the
* 'label' in the label colum and the 'id' or 'name' in the value column
*
- * @param $name string name of the option group
- * @param $flip boolean results are return in id => label format if false
+ * @param $name
+ * String name of the option group.
+ * @param $flip
+ * Boolean results are return in id => label format if false.
* if true, the results are reversed
- * @param $grouping boolean if true, return the value in 'grouping' column
- * @param $localize boolean if true, localize the results before returning
- * @param $condition string add another condition to the sql query
- * @param $labelColumnName string the column to use for 'label'
- * @param $onlyActive boolean return only the action option values
- * @param $fresh boolean ignore cache entries and go back to DB
- * @param $keyColumnName string the column to use for 'key'
+ * @param $grouping
+ * Boolean if true, return the value in 'grouping' column.
+ * @param $localize
+ * Boolean if true, localize the results before returning.
+ * @param $condition
+ * String add another condition to the sql query.
+ * @param $labelColumnName
+ * String the column to use for 'label'.
+ * @param $onlyActive
+ * Boolean return only the action option values.
+ * @param $fresh
+ * Boolean ignore cache entries and go back to DB.
+ * @param $keyColumnName
+ * String the column to use for 'key'.
*
* @return array the values as specified by the above params
* @static
/**
* Counterpart to values() which removes the item from the cache
*
- * @param $name
+ * @param string $name
* @param $flip
* @param $grouping
* @param $localize
* @param $condition
- * @param $labelColumnName
+ * @param string $labelColumnName
* @param $onlyActive
* @param string $keyColumnName
*/
unset(self::$_cache[$cacheKey]);
}
+ /**
+ * @return string
+ */
protected static function createCacheKey() {
$cacheKey = "CRM_OG_" . serialize(func_get_args());
return $cacheKey;
* (radio, select, checkbox etc). OptionGroups for most cases have the
* 'label' in the label colum and the 'id' or 'name' in the value column
*
- * @param $id integer id of the option group
- * @param $flip boolean results are return in id => label format if false
+ * @param $id
+ * Integer id of the option group.
+ * @param $flip
+ * Boolean results are return in id => label format if false.
* if true, the results are reversed
- * @param $grouping boolean if true, return the value in 'grouping' column
- * @param $localize boolean if true, localize the results before returning
- * @param $labelColumnName string the column to use for 'label'
+ * @param $grouping
+ * Boolean if true, return the value in 'grouping' column.
+ * @param $localize
+ * Boolean if true, localize the results before returning.
+ * @param $labelColumnName
+ * String the column to use for 'label'.
*
* @param bool $onlyActive
* @param bool $fresh
* @static
* @void
*/
- static function &valuesByID($id, $flip = FALSE, $grouping = FALSE, $localize = FALSE, $labelColumnName = 'label', $onlyActive = TRUE, $fresh = FALSE) {
+ public static function &valuesByID($id, $flip = FALSE, $grouping = FALSE, $localize = FALSE, $labelColumnName = 'label', $onlyActive = TRUE, $fresh = FALSE) {
$cacheKey = self::createCacheKey($id, $flip, $grouping, $localize, $labelColumnName, $onlyActive);
$cache = CRM_Utils_Cache::singleton();
}
/**
- * Function to lookup titles OR ids for a set of option_value populated fields. The retrieved value
+ * Lookup titles OR ids for a set of option_value populated fields. The retrieved value
* is assigned a new fieldname by id or id's by title
* (each within a specificied option_group)
*
- * @param array $params Reference array of values submitted by the form. Based on
+ * @param array $params
+ * Reference array of values submitted by the form. Based on.
* $flip, creates new elements in $params for each field in
* the $names array.
* If $flip = false, adds root field name => title
* If $flip = true, adds actual field name => id
*
- * @param array $names Reference array of fieldnames we want transformed.
+ * @param array $names
+ * Reference array of fieldnames we want transformed.
* Array key = 'postName' (field name submitted by form in $params).
* Array value = array(
- 'newName' => $newName, 'groupName' => $groupName).
+ 'newName' => $newName, 'groupName' => $groupName).
*
*
- * @param boolean $flip
+ * @param bool $flip
*
* @return void
*
- * @access public
* @static
*/
- static function lookupValues(&$params, &$names, $flip = FALSE) {
+ public static function lookupValues(&$params, &$names, $flip = FALSE) {
foreach ($names as $postName => $value) {
// See if $params field is in $names array (i.e. is a value that we need to lookup)
if ($postalName = CRM_Utils_Array::value($postName, $params)) {
}
}
- static function getLabel($groupName, $value, $onlyActiveValue = TRUE) {
+ /**
+ * @param string $groupName
+ * @param $value
+ * @param bool $onlyActiveValue
+ *
+ * @return null
+ */
+ public static function getLabel($groupName, $value, $onlyActiveValue = TRUE) {
if (empty($groupName) ||
empty($value)
) {
if ($onlyActiveValue) {
$query .= " AND v.is_active = 1 ";
}
- $p = array(1 => array($groupName, 'String'),
+ $p = array(
+ 1 => array($groupName, 'String'),
2 => array($value, 'Integer'),
);
$dao = CRM_Core_DAO::executeQuery($query, $p);
return NULL;
}
- static function getValue($groupName,
+ /**
+ * @param string $groupName
+ * @param $label
+ * @param string $labelField
+ * @param string $labelType
+ * @param string $valueField
+ *
+ * @return null
+ */
+ static function getValue(
+ $groupName,
$label,
$labelField = 'label',
- $labelType = 'String',
+ $labelType = 'String',
$valueField = 'value'
) {
if (empty($label)) {
AND v.$labelField = %2
";
- $p = array(1 => array($groupName, 'String'),
+ $p = array(
+ 1 => array($groupName, 'String'),
2 => array($label, $labelType),
);
$dao = CRM_Core_DAO::executeQuery($query, $p);
/**
* Get option_value.value from default option_value row for an option group
*
- * @param string $groupName the name of the option group
+ * @param string $groupName
+ * The name of the option group.
*
- * @access public
* @static
*
* @return string the value from the row where is_default = true
*/
- static function getDefaultValue($groupName) {
+ public static function getDefaultValue($groupName) {
if (empty($groupName)) {
return NULL;
}
* @TODO: Should update the group if it already exists intelligently, so multi-lingual is
* not messed up. Currently deletes the old group
*
- * @param string $groupName the name of the option group - make sure there is no conflict
- * @param array $values the associative array that has information on the option values
+ * @param string $groupName
+ * The name of the option group - make sure there is no conflict.
+ * @param array $values
+ * The associative array that has information on the option values.
* the keys of this array are:
* string 'title' (required)
* string 'value' (required)
* int 'weight' (optional) - the order in which the value are displayed
* bool 'is_default' (optional) - is this the default one to display when rendered in form
* bool 'is_active' (optional) - should this element be rendered
- * @param int $defaultID (reference) - the option value ID of the default element (if set) is returned else 'null'
+ * @param int $defaultID
+ * (reference) - the option value ID of the default element (if set) is returned else 'null'.
* @param null $groupTitle
+ * The optional label of the option group else set to group name.
*
- * @internal param string $groupLabel - the optional label of the option group else set to group name
- *
- * @access public
* @static
*
* @return int the option group ID
*/
- static function createAssoc($groupName, &$values, &$defaultID, $groupTitle = NULL) {
+ public static function createAssoc($groupName, &$values, &$defaultID, $groupTitle = NULL) {
self::deleteAssoc($groupName);
if (!empty($values)) {
$group = new CRM_Core_DAO_OptionGroup();
return $group->id;
}
- static function getAssoc($groupName, &$values, $flip = FALSE, $field = 'name') {
+ /**
+ * @param string $groupName
+ * @param $values
+ * @param bool $flip
+ * @param string $field
+ */
+ public static function getAssoc($groupName, &$values, $flip = FALSE, $field = 'name') {
$query = "
SELECT v.id as amount_id, v.value, v.label, v.name, v.description, v.weight
FROM civicrm_option_group g,
}
}
- static function deleteAssoc($groupName, $operator = "=") {
+ /**
+ * @param string $groupName
+ * @param string $operator
+ */
+ public static function deleteAssoc($groupName, $operator = "=") {
$query = "
DELETE g, v
FROM civicrm_option_group g,
$dao = CRM_Core_DAO::executeQuery($query, $params);
}
- static function optionLabel($groupName, $value) {
+ /**
+ * @param string $groupName
+ * @param $value
+ *
+ * @return null|string
+ */
+ public static function optionLabel($groupName, $value) {
$query = "
SELECT v.label
FROM civicrm_option_group g,
WHERE g.id = v.option_group_id
AND g.name = %1
AND v.value = %2";
- $params = array(1 => array($groupName, 'String'),
+ $params = array(
+ 1 => array($groupName, 'String'),
2 => array($value, 'String'),
);
return CRM_Core_DAO::singleValueQuery($query, $params);
}
- static function getRowValues($groupName, $fieldValue, $field = 'name',
+ /**
+ * @param string $groupName
+ * @param $fieldValue
+ * @param string $field
+ * @param string $fieldType
+ * @param bool $active
+ *
+ * @return array
+ */
+ static function getRowValues(
+ $groupName, $fieldValue, $field = 'name',
$fieldType = 'String', $active = TRUE
) {
$query = "
$query .= " AND v.is_active = 1";
}
- $p = array(1 => array($groupName, 'String'),
+ $p = array(
+ 1 => array($groupName, 'String'),
2 => array($fieldValue, $fieldType),
);
$dao = CRM_Core_DAO::executeQuery($query, $p);
* which is part of the cache key
* will do a couple of variations & aspire to someone cleaning it up later
*/
- static function flush($name, $params = array()){
+ /**
+ * @param $name
+ * @param array $params
+ */
+ public static function flush($name, $params = array()) {
$defaults = array(
'flip' => FALSE,
'grouping' => FALSE,
);
}
- static function flushAll() {
+ public static function flushAll() {
self::$_values = array();
self::$_cache = array();
CRM_Utils_Cache::singleton()->flush();
}
}
-