$ufGroup = array('-1' => ts('- select -'),
'0' => ts('All Profiles'),
- ) + CRM_Core_PseudoConstant::ufGroup();
+ ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFGroup', 'uf_group_id');
$event = array('-1' => ts('- select -'),
'0' => ts('All Events'),
) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
$ufGroup = array('-1' => ts('- select -'),
'0' => ts('All Profiles'),
- ) + CRM_Core_PseudoConstant::ufGroup();
+ ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFGroup', 'uf_group_id');
$event = array('-1' => ts('- select -'),
'0' => ts('All Events'),
// Supporting search for currency type -- CRM-4711
case 'contribution_currency_type':
- $currencySymbol = CRM_Core_PseudoConstant::currencySymbols('name');
+ $currencySymbol = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', array('labelColumn' => 'name'));
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution.currency",
$op, $currencySymbol[$value], "String"
);
ts('Currency Type'),
array(
'' => ts('- any -')) +
- CRM_Core_PseudoConstant::currencySymbols('name')
+ CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', array('labelColumn' => 'name'))
);
$form->add('select', 'financial_type_id',
$fields = $subset;
}
else {
- $ufGroups = CRM_Core_PseudoConstant::ufGroup();
+ $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFGroup', 'uf_group_id');
$fields = array();
foreach ($ufGroups as $id => $title) {
*/
static function getProfiles($types, $onlyPure = FALSE) {
$profiles = array();
- $ufGroups = CRM_Core_PseudoConstant::ufgroup();
+ $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFGroup', 'uf_group_id');
CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $ufGroups);
}
$profiles = array();
- $ufGroups = CRM_Core_PseudoConstant::ufgroup();
+ $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFGroup', 'uf_group_id');
CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $ufGroups);
static $cachedSymbol = NULL;
if (!$cachedSymbol || $defaultCurrency) {
if ($this->defaultCurrency || $defaultCurrency) {
- $currencySymbolName = CRM_Core_PseudoConstant::currencySymbols('name');
- $currencySymbol = CRM_Core_PseudoConstant::currencySymbols();
+ $currencySymbolName = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', array('labelColumn' => 'name'));
+ $currencySymbol = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency');
$this->currencySymbols = array_combine($currencySymbolName, $currencySymbol);
$currency = $defaultCurrency ? $defaultCurrency : $this->defaultCurrency;
}
public static function ufGroup($type = CRM_Core_Permission::VIEW) {
- $ufGroups = CRM_Core_PseudoConstant::ufGroup();
+ $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFGroup', 'uf_group_id');
$allGroups = array_keys($ufGroups);
*/
private static $staticGroup;
- /**
- * user framework groups
- * @var array
- * @static
- */
- private static $ufGroup;
-
/**
* currency codes
* @var array
*/
private static $currencyCode;
- /**
- * currency Symbols
- * @var array
- * @static
- */
- private static $currencySymbols;
-
/**
* payment processor
* @var array
public static function get($daoName, $fieldName, $params = array()) {
$dao = new $daoName;
$fields = $dao->fields();
+ $fieldKeys = $dao->fieldKeys();
+ $fieldKey = $fieldKeys[$fieldName];
$dao->free();
- if (empty($fields[$fieldName])) {
+ if (empty($fields[$fieldKey])) {
return FALSE;
}
- $fieldSpec = $fields[$fieldName];
+ $fieldSpec = $fields[$fieldKey];
$flip = !empty($params['flip']);
// If the field is an enum, explode the enum definition and return the array.
// Get list of fields for the option table
$daoName = CRM_Core_AllCoreTables::getClassForTable($pseudoconstant['table']);
$dao = new $daoName;
- $availableFields = $dao->fields();
+ $availableFields = array_keys($dao->fieldKeys());
+ if (in_array('is_active', $availableFields)) {
+ $wheres[] = 'is_active = 1';
+ }
$dao->free();
$select = "SELECT %1 AS id, %2 AS label";
return self::$staticGroup;
}
- /**
- * Get all the user framework groups
- *
- * @access public
- *
- * @return array - array reference of all groups.
- * @static
- */
- public static function &ufGroup() {
- if (!self::$ufGroup) {
- self::populate(self::$ufGroup, 'CRM_Core_DAO_UFGroup', FALSE, 'title', 'is_active', NULL, 'title');
- }
- return self::$ufGroup;
- }
-
/**
* Get all Relationship Types from database.
*
return self::$relationshipType[$valueColumnName];
}
- /**
- * Get all the Currency Symbols from Database
- *
- * @access public
- *
- * @return array - array reference of all Currency Symbols
- * @static
- *
- * FIXME: this is not stored as an optionValue, and it's not tied to a single DB column;
- * FIXME: It's used for a setting stored in option group 'currencies_enabled'. What to do?
- */
- public static function ¤cySymbols($name = 'symbol', $key = 'id') {
- $cacheKey = "{$name}_{$key}";
- if (!isset(self::$currencySymbols[$cacheKey])) {
- self::populate(self::$currencySymbols[$cacheKey], 'CRM_Financial_DAO_Currency', TRUE, $name, NULL, NULL, 'name', $key);
- }
- return self::$currencySymbols[$cacheKey];
- }
-
/**
* get all the ISO 4217 currency codes
*
CRM_Core_Permission::EDIT,
NULL,
'civicrm_uf_group',
- CRM_Core_PseudoConstant::ufGroup()
+ CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFGroup', 'uf_group_id')
)
)
) {
return;
}
- $currencies = CRM_Core_PseudoConstant::currencySymbols('symbol', 'name');
+ $currencies = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'currency');
$currency = $currencies[$values['civicrm_grant_currency']];
if (!$customData) {
return;
}
- $ufGroups = CRM_Core_PseudoConstant::ufGroup();
+ $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFGroup', 'uf_group_id');
CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $allUFGroups);
foreach ($allUFGroups as $id => $value) {
}
if (!self::$_currencySymbols) {
- $currencySymbolName = CRM_Core_PseudoConstant::currencySymbols('name');
- $currencySymbol = CRM_Core_PseudoConstant::currencySymbols();
+ $currencySymbolName = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', array('labelColumn' => 'name'));
+ $currencySymbol = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency');
self::$_currencySymbols = array_combine($currencySymbolName, $currencySymbol);
}
* DAO fields having a <pseudoconstant> tag in the XML schema.
*/
function testOptionValues() {
- $custom_group_name = 'Test custom group';
+
+ $custom_group_name = md5(microtime());
$api_params = array(
- 'version' => 3,
- 'title' => $custom_group_name,
- 'extends' => 'Individual',
+ 'version' => 3,
+ 'title' => $custom_group_name,
+ 'extends' => 'Individual',
+ 'is_active' => TRUE,
);
- civicrm_api('customGroup', 'create', $api_params);
+ $result = civicrm_api('customGroup', 'create', $api_params);
/**
* daoName/field combinations to test
* - max: integer (default = 10) maximum number of option values expected.
*/
$fields = array(
+ 'CRM_Event_DAO_Participant' => array(
+ array(
+ 'fieldName' => 'fee_currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_Core_DAO_UFField' => array(
+ array(
+ 'fieldName' => 'uf_group_id',
+ 'sample' => 'Name and Address',
+ 'max' => 15,
+ ),
+ ),
+ 'CRM_Core_DAO_UFJoin' => array(
+ array(
+ 'fieldName' => 'uf_group_id',
+ 'sample' => 'Name and Address',
+ 'max' => 15,
+ ),
+ ),
+ 'CRM_Contribute_DAO_ContributionSoft' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_Contribute_DAO_Contribution' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_Contribute_DAO_Product' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_Contribute_DAO_ContributionPage' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_Contribute_DAO_ContributionRecur' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_Event_DAO_Event' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_Financial_DAO_FinancialItem' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_Financial_DAO_OfficialReceipt' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_Financial_DAO_FinancialTrxn' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_Grant_DAO_Grant' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_Pledge_DAO_PledgePayment' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_Pledge_DAO_Pledge' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
+ 'CRM_PCP_DAO_PCP' => array(
+ array(
+ 'fieldName' => 'currency',
+ 'sample' => '$',
+ 'max' => 200,
+ ),
+ ),
'CRM_Core_DAO_CustomField' => array(
array(
'fieldName' => 'custom_group_id',
<headerPattern>/cur(rency)?/i</headerPattern>
<dataPattern>/^[A-Z]{3}$/i</dataPattern>
<comment>3 character string, value from config setting or input via user.</comment>
- <add>1.3</add>
+ <add>1.3</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>cancel_date</name>
<headerPattern>/cur(rency)?/i</headerPattern>
<dataPattern>/^[A-Z]{3}$/i</dataPattern>
<comment>3 character string, value from config setting or input via user.</comment>
- <add>3.3</add>
+ <add>3.3</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>campaign_id</name>
<default>NULL</default>
<comment>3 character string, value from config setting or input via user.</comment>
<add>3.2</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>frequency_unit</name>
<default>NULL</default>
<comment>3 character string, value from config setting or input via user.</comment>
<add>3.2</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>pcp_id</name>
<default>NULL</default>
<comment>3 character string, value from config setting or input via user.</comment>
<add>3.2</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>financial_type_id</name>
<required>true</required>
<comment>Which form does this field belong to.</comment>
<add>1.1</add>
+ <pseudoconstant>
+ <table>civicrm_uf_group</table>
+ <keyColumn>id</keyColumn>
+ <labelColumn>title</labelColumn>
+ </pseudoconstant>
</field>
<foreignKey>
<name>uf_group_id</name>
<type>int unsigned</type>
<required>true</required>
<comment>Which form does this field belong to.</comment>
- <add>1.3</add>
+ <add>1.3</add>
+ <pseudoconstant>
+ <table>civicrm_uf_group</table>
+ <keyColumn>id</keyColumn>
+ <labelColumn>title</labelColumn>
+ </pseudoconstant>
</field>
<foreignKey>
<name>uf_group_id</name>
<dataPattern>/^[A-Z]{3}$/i</dataPattern>
<comment>3 character string, value from config setting or input via user.</comment>
<add>3.3</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>campaign_id</name>
<dataPattern>/^[A-Z]{3}$/i</dataPattern>
<comment>3 character string, value derived from config setting.</comment>
<add>3.0</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>campaign_id</name>
<length>3</length>
<comment>Currency for the amount</comment>
<add>4.3</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>financial_account_id</name>
<dataPattern>/^[A-Z]{3}$/</dataPattern>
<comment>3 character string, value from config setting or input via user.</comment>
<add>1.3</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>payment_processor</name>
<dataPattern>/^[A-Z]{3}$/</dataPattern>
<comment>3 character string, value from config setting or input via user.</comment>
<add>4.1</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>msg_template_id</name>
<required>true</required>
<comment>3 character string, value from config setting or input via user.</comment>
<add>3.2</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>currency</name>
<default>NULL</default>
<comment>3 character string, value from config setting or input via user.</comment>
<add>3.2</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>referer</name>
<default>NULL</default>
<comment>3 character string, value from config setting or input via user.</comment>
<add>3.2</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>frequency_unit</name>
<default>NULL</default>
<comment>3 character string, value from config setting or input via user.</comment>
<add>3.2</add>
+ <pseudoconstant>
+ <table>civicrm_currency</table>
+ <keyColumn>name</keyColumn>
+ <labelColumn>symbol</labelColumn>
+ </pseudoconstant>
</field>
<field>
<name>scheduled_date</name>