<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* This provides greater consistency/predictability after flushing.
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
/**
* Low-level option getter, rarely accessed directly.
* NOTE: Rather than calling this function directly use CRM_*_BAO_*::buildOptions()
+ * @see http://wiki.civicrm.org/confluence/display/CRMDOC/Pseudoconstant+%28option+list%29+Reference
*
* @param String $daoName
* @param String $fieldName
if (!empty($customField->option_group_id)) {
$options = CRM_Core_OptionGroup::valuesByID($customField->option_group_id,
- $flip,
+ FALSE,
$params['grouping'],
$params['localize'],
// Note: for custom fields the 'name' column is NULL
elseif ($customField->data_type === 'Boolean') {
$options = $context == 'validate' ? array(0, 1) : array(1 => ts('Yes'), 0 => ts('No'));
}
- $options = $options && $flip ? array_flip($options) : $options;
}
- if ($options !== FALSE) {
- CRM_Utils_Hook::customFieldOptions($customField->id, $options, FALSE);
+ CRM_Utils_Hook::customFieldOptions($customField->id, $options, FALSE);
+ if ($options && $flip) {
+ $options = array_flip($options);
}
$customField->free();
return $options;
return FALSE;
}
- // If the field is an enum, explode the enum definition and return the array.
- if (isset($fieldSpec['enumValues'])) {
- // use of a space after the comma is inconsistent in xml
- $enumStr = str_replace(', ', ',', $fieldSpec['enumValues']);
- $output = explode(',', $enumStr);
- return array_combine($output, $output);
- }
-
elseif (!empty($fieldSpec['pseudoconstant'])) {
$pseudoconstant = $fieldSpec['pseudoconstant'];
+
+ // if callback is specified..
+ if(!empty($pseudoconstant['callback'])) {
+ list($className, $fnName) = explode('::', $pseudoconstant['callback']);
+ if (method_exists($className, $fnName)) {
+ return call_user_func(array($className, $fnName));
+ }
+ }
+
// Merge params with schema defaults
$params += array(
'condition' => CRM_Utils_Array::value('condition', $pseudoconstant, array()),
return NULL;
}
// We don't have good mapping so have to do a bit of guesswork from the menu
- list(, , , $ent) = explode('_', $daoName);
+ list(, $parent, , $child) = explode('_', $daoName);
$sql = "SELECT path FROM civicrm_menu
- WHERE page_callback LIKE '%CRM_Admin_Page_$ent%'
+ WHERE page_callback LIKE '%CRM_Admin_Page_$child%' OR page_callback LIKE '%CRM_{$parent}_Page_$child%'
+ ORDER BY page_callback
LIMIT 1";
return CRM_Core_Dao::singleValueQuery($sql);
}
*
* Note: any database errors will be trapped by the DAO.
*
- * @param array $var the associative array we will fill
- * @param string $name the name of the DAO
- * @param boolean $all get all objects. default is to get only active ones.
- * @param string $retrieve the field that we are interested in (normally name, differs in some objects)
- * @param string $filter the field that we want to filter the result set with
- * @param string $condition the condition that gets passed to the final query as the WHERE clause
+ * @param array $var the associative array we will fill
+ * @param string $name the name of the DAO
+ * @param boolean $all get all objects. default is to get only active ones.
+ * @param string $retrieve the field that we are interested in (normally name, differs in some objects)
+ * @param string $filter the field that we want to filter the result set with
+ * @param string $condition the condition that gets passed to the final query as the WHERE clause
+ *
+ * @param null $orderby
+ * @param string $key
+ * @param null $force
*
* @return void
* @access public
* @access public
* @static
*
- * @param boolean $name pseudoconstant to be flushed
- *
+ * @param bool|string $name pseudoconstant to be flushed
*/
public static function flush($name = 'cache') {
if (isset(self::$$name)) {
*
* The static array activityType is returned
*
- * @param boolean $all - get All Activity types - default is to get only active ones.
+ * @internal param bool $all - get All Activity types - default is to get only active ones.
*
* @access public
* @static
* @access public
* @static
*
- * @param int $id - Optional id to return
+ * @param bool|int $id - Optional id to return
*
- * @return array - array reference of all State/Provinces.
+ * @param bool $limit
*
+ * @return array - array reference of all State/Provinces.
*/
public static function &stateProvince($id = FALSE, $limit = TRUE) {
if (($id && !CRM_Utils_Array::value($id, self::$stateProvince)) || !self::$stateProvince || !$id) {
* @access public
* @static
*
- * @param int $id - Optional id to return
+ * @param bool|int $id - Optional id to return
+ *
+ * @param bool $limit
*
* @return array - array reference of all State/Province abbreviations.
*/
* @access public
* @static
*
- * @param int $id - Optional id to return
+ * @param bool|int $id - Optional id to return
*
- * @return array - array reference of all countries.
+ * @param bool $applyLimit
*
+ * @return array - array reference of all countries.
*/
public static function country($id = FALSE, $applyLimit = TRUE) {
if (($id && !CRM_Utils_Array::value($id, self::$country)) || !self::$country || !$id) {
* @access public
* @static
*
- * @return array - array reference of all country ISO codes.
+ * @param bool $id
*
+ * @return array - array reference of all country ISO codes.
*/
public static function &countryIsoCode($id = FALSE) {
if (!self::$countryIsoCode) {
*
* Note: any database errors will be trapped by the DAO.
*
- * @param string $groupType type of group(Access/Mailing)
- * @param boolen $excludeHidden exclude hidden groups.
+ * @param string $groupType type of group(Access/Mailing)
+ * @param bool|\boolen $excludeHidden exclude hidden groups.
*
* @access public
* @static
*
* @return array - array reference of all groups.
- *
*/
public static function &allGroup($groupType = NULL, $excludeHidden = TRUE) {
$condition = CRM_Contact_BAO_Group::groupTypeCondition($groupType, $excludeHidden);
* @access public
* @static
*
- * @return mixed - instance of CRM_Contact_BAO_GroupNesting
+ * @param bool $styledLabels
*
+ * @return mixed - instance of CRM_Contact_BAO_GroupNesting
*/
public static function &groupIterator($styledLabels = FALSE) {
if (!self::$groupIterator) {
*
* Note: any database errors will be trapped by the DAO.
*
- * @param string $groupType type of group(Access/Mailing)
- * @param boolen $excludeHidden exclude hidden groups.
-
+ * @param string $groupType type of group(Access/Mailing)
+ * @param bool|\boolen $excludeHidden exclude hidden groups.
+ *
* @access public
* @static
*
* @return array - array reference of all groups.
- *
*/
public static function group($groupType = NULL, $excludeHidden = TRUE) {
return CRM_Core_Permission::group($groupType, $excludeHidden);
* @access public
* @static
*
- * @return array - array reference of all groups.
+ * @param bool $onlyPublic
+ * @param null $groupType
+ * @param bool $excludeHidden
*
+ * @return array - array reference of all groups.
*/
public static function &staticGroup($onlyPublic = FALSE, $groupType = NULL, $excludeHidden = TRUE) {
if (!self::$staticGroup) {
* @access public
* @static
*
- * @param int $id - Optional id to return
+ * @param bool|int $id - Optional id to return
*
* @return array - array reference of all Counties
- *
*/
public static function &county($id = FALSE) {
if (!self::$county) {
* @access public
* @static
*
- * @param boolean $all - get payment processors - default is to get only active ones.
+ * @param boolean $all - get payment processors - default is to get only active ones.
* @param boolean $test - get test payment processors
*
- * @return array - array of all payment processors
+ * @param null $additionalCond
*
+ * @return array - array of all payment processors
*/
public static function &paymentProcessor($all = FALSE, $test = FALSE, $additionalCond = NULL) {
$condition = "is_test = ";
* @access public
* @static
*
- * @param boolean $all - get payment processors - default is to get only active ones.
+ * @param boolean $all - get payment processors - default is to get only active ones.
*
- * @return array - array of all payment processor types
+ * @param null $id
+ * @param string $return
*
+ * @return array - array of all payment processor types
*/
public static function &paymentProcessorType($all = FALSE, $id = NULL, $return = 'title') {
$cacheKey = $id . '_' .$return;
*
* @access public
*
+ * @param bool $id
+ *
* @return array - array reference of all World Regions
* @static
*/
* @access public
* @static
*
+ * @param string $column
+ *
* @return array - array reference of all activity statuses
*/
public static function &activityStatus($column = 'label') {
* @access public
* @static
*
- * @return array - array reference of all Visibility levels.
+ * @param string $column
*
+ * @return array - array reference of all Visibility levels.
*/
public static function &visibility($column = 'label') {
if (!isset(self::$visibility)) {
return self::$visibility[$column];
}
+ /**
+ * @param $countryID
+ * @param string $field
+ *
+ * @return array
+ */
public static function &stateProvinceForCountry($countryID, $field = 'name') {
static $_cache = NULL;
return $result;
}
+ /**
+ * @param $stateID
+ *
+ * @return array
+ */
public static function &countyForState($stateID) {
if (is_array($stateID)) {
$states = implode(", ", $stateID);
*
* @param $filter - get All Email Greetings - default is to get only active ones.
*
- * @return array - array reference of all greetings.
+ * @param string $columnName
*
+ * @return array - array reference of all greetings.
*/
public static function greeting($filter, $columnName = 'label') {
$index = $filter['greeting_type'] . '_' . $columnName;
*
* @param boolean $optionGroupName - get All Option Group values- default is to get only active ones.
*
- * @return array - array reference of all Option Group Name
+ * @param null $id
+ * @param null $condition
*
+ * @return array - array reference of all Option Group Name
*/
public static function accountOptionValues($optionGroupName, $id = null, $condition = null) {
$cacheKey = $optionGroupName . '_' . $condition;