<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
'grant_type',
);
+ /**
+ * @param $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'
* @param $condition
* @param $labelColumnName
* @param $onlyActive
+ * @param string $keyColumnName
*/
protected static function flushValues($name, $flip, $grouping, $localize, $condition, $labelColumnName, $onlyActive, $keyColumnName = 'value') {
$cacheKey = self::createCacheKey($name, $flip, $grouping, $localize, $condition, $labelColumnName, $onlyActive, $keyColumnName);
unset(self::$_cache[$cacheKey]);
}
+ /**
+ * @return string
+ */
protected static function createCacheKey() {
$cacheKey = "CRM_OG_" . serialize(func_get_args());
return $cacheKey;
* @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
+ *
* @return array the values as specified by the above params
* @static
* @void
}
}
+ /**
+ * @param $groupName
+ * @param $value
+ * @param bool $onlyActiveValue
+ *
+ * @return null
+ */
static function getLabel($groupName, $value, $onlyActiveValue = TRUE) {
if (empty($groupName) ||
empty($value)
return NULL;
}
+ /**
+ * @param $groupName
+ * @param $label
+ * @param string $labelField
+ * @param string $labelType
+ * @param string $valueField
+ *
+ * @return null
+ */
static function getValue($groupName,
$label,
$labelField = 'label',
* @static
*
* @return string the value from the row where is_default = true
- */
+ */
static function getDefaultValue($groupName) {
if (empty($groupName)) {
return NULL;
$p = array(1 => array($groupName, 'String'));
return CRM_Core_DAO::singleValueQuery($query, $p);
}
-
+
/**
* Creates a new option group with the passed in values
* @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 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 string $groupLabel - the optional label of the option group else set to group name
+ * @param int $defaultID (reference) - the option value ID of the default element (if set) is returned else 'null'
+ * @param null $groupTitle
+ *
+ * @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) {
self::deleteAssoc($groupName);
return $group->id;
}
+ /**
+ * @param $groupName
+ * @param $values
+ * @param bool $flip
+ * @param string $field
+ */
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
}
}
+ /**
+ * @param $groupName
+ * @param string $operator
+ */
static function deleteAssoc($groupName, $operator = "=") {
$query = "
DELETE g, v
$dao = CRM_Core_DAO::executeQuery($query, $params);
}
+ /**
+ * @param $groupName
+ * @param $value
+ *
+ * @return null|string
+ */
static function optionLabel($groupName, $value) {
$query = "
SELECT v.label
return CRM_Core_DAO::singleValueQuery($query, $params);
}
+ /**
+ * @param $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
) {
* which is part of the cache key
* will do a couple of variations & aspire to someone cleaning it up later
*/
+ /**
+ * @param $name
+ * @param array $params
+ */
static function flush($name, $params = array()){
$defaults = array(
'flip' => FALSE,
static function flushAll() {
self::$_values = array();
self::$_cache = array();
+ CRM_Utils_Cache::singleton()->flush();
}
}