$customGroup = array('-1' => ts('- select -'),
'0' => ts('All Custom Groups'),
- ) + CRM_Core_PseudoConstant::customGroup();
+ ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
$ufGroup = array('-1' => ts('- select -'),
'0' => ts('All Profiles'),
) + CRM_Core_PseudoConstant::group();
$customGroup = array('-1' => ts('- select -'),
'0' => ts('All Custom Groups'),
- ) + CRM_Core_PseudoConstant::customGroup();
+ ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
$ufGroup = array('-1' => ts('- select -'),
'0' => ts('All Profiles'),
) + CRM_Core_PseudoConstant::ufGroup();
case 'activity_tags':
$value = array_keys($value);
- $activityTags = CRM_Core_PseudoConstant::tag();
+ $activityTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$names = array();
$val = array();
}
}
case 'case_tags':
- $tags = CRM_Core_PseudoConstant::tag();
+ $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
if (is_array($value)) {
foreach ($value as $k => $v) {
$tags = CRM_Core_BAO_EntityTag::getTag($activityID, 'civicrm_activity');
if (!empty($tags)) {
- $allTag = CRM_Core_PseudoConstant::tag();
+ $allTag = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
foreach ($tags as $tid) {
$tags[$tid] = $allTag[$tid];
}
function tag(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
- $tagNames = CRM_Core_PseudoConstant::tag();
+ $tagNames = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
if (is_array($value)) {
if (count($value) > 1) {
$this->_useDistinct = TRUE;
$form->addElement('select', 'group', ts('in'), $group);
// add select for categories
- $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::tag();
+ $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$form->addElement('select', 'tag', ts('Tagged'), $tag);
// text for sort_name
$groups = CRM_Core_PseudoConstant::group();
- $tags = CRM_Core_PseudoConstant::tag();
+ $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
if (count($groups) == 0 || count($tags) == 0) {
CRM_Core_Session::setStatus(ts("At least one Group and Tag must be present for Custom Group / Tag search."), ts('Missing Group/Tag'));
$url = CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1');
$form->addElement('select', 'group', ts('in'), $group);
// add select for tags
- $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::tag();
+ $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$form->addElement('select', 'tag', ts('Tagged'), $tag);
if (empty($this->_groupTree)) {
$group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group();
$form->addElement('select', 'group', ts('Group'), $group);
- $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::tag();
+ $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$form->addElement('select', 'tag', ts('Tag'), $tag);
$form->addDate('start_date', ts('Contribution Date From'), FALSE, array('formatType' => 'custom'));
$form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
- $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::tag();
+ $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$form->addElement('select', 'tag', ts('Tagged'), $tag);
/**
$groups = CRM_Core_PseudoConstant::group();
$this->set('groups', $groups);
- $tag = CRM_Core_PseudoConstant::tag();
+ $tag = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
if ($tag) {
$this->set('tag', $tag);
}
}
//fix tag names
- $tags = CRM_Core_PseudoConstant::tag();
+ $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
foreach($results as &$values) {
if (!empty($values['tag'])) {
}
elseif ($name == 'tag') {
$entityTags = CRM_Core_BAO_EntityTag::getTag($cid);
- $allTags = CRM_Core_PseudoConstant::tag();
+ $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$title = array();
foreach ($entityTags as $tagId) {
$title[] = $allTags[$tagId];
if (!empty($form->_submitValues['activity_taglist']) &&
CRM_Utils_Array::value($parentId, $form->_submitValues['activity_taglist'])
) {
- $allTags = CRM_Core_PseudoConstant::tag();
+ $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$tagIds = explode(',', $form->_submitValues['activity_taglist'][$parentId]);
foreach ($tagIds as $tagId) {
if (is_numeric($tagId)) {
if (!empty($form->_submitValues['case_taglist']) &&
CRM_Utils_Array::value($parentId, $form->_submitValues['case_taglist'])
) {
- $allTags = CRM_Core_PseudoConstant::tag();
+ $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$tagIds = explode(',', $form->_submitValues['case_taglist'][$parentId]);
foreach ($tagIds as $tagId) {
if (is_numeric($tagId)) {
if (!empty($form->_submitValues["attachment_taglist_$i"]) &&
CRM_Utils_Array::value($parentId, $form->_submitValues["attachment_taglist_$i"])
) {
- $allTags = CRM_Core_PseudoConstant::tag();
+ $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$tagIds = explode(',', $form->_submitValues["attachment_taglist_$i"][$parentId]);
foreach ($tagIds as $tagId) {
if (is_numeric($tagId)) {
}
public static function customGroup($type = CRM_Core_Permission::VIEW, $reset = FALSE) {
- $customGroups = CRM_Core_PseudoConstant::customGroup($reset);
+ $customGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id', array('fresh' => $reset));
$defaultGroups = array();
// check if user has all powerful permission
*/
private static $countryIsoCode;
- /**
- * tag
- * @var array
- * @static
- */
- private static $tag;
-
/**
* group
* @var array
*/
private static $ufGroup;
- /**
- * custom groups
- * @var array
- * @static
- */
- private static $customGroup;
-
/**
* currency codes
* @var array
return self::$countryIsoCode;
}
- /**
- * Get all the categories from database.
- *
- * The static array tag is returned, and if it's
- * called the first time, the <b>Tag DAO</b> is used
- * to get all the categories.
- *
- * Note: any database errors will be trapped by the DAO.
- *
- * @access public
- * @static
- *
- * @return array - array reference of all categories.
- *
- */
- public static function &tag() {
- if (!self::$tag) {
- self::populate(self::$tag, 'CRM_Core_DAO_Tag', TRUE);
- }
- return self::$tag;
- }
-
/**
* Get all groups from database
*
return self::$staticGroup;
}
- /**
- * Get all the custom groups
- *
- * @access public
- *
- * @return array - array reference of all groups.
- * @static
- */
- public static function &customGroup($reset = FALSE) {
- if (!self::$customGroup || $reset) {
- self::populate(self::$customGroup, 'CRM_Core_DAO_CustomGroup', FALSE, 'title', 'is_active', NULL, 'title');
- }
- return self::$customGroup;
- }
-
/**
* Get all the user framework groups
*
*/
public function buildQuickForm() {
- $customGroup = CRM_Core_PseudoConstant::customGroup();
+ $customGroup = CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
unset($customGroup[$this->_srcGID]);
if (empty($customGroup)) {
CRM_Core_Error::statusBounce(ts('You need more than one custom group to move fields'));
}
elseif ($name == 'tag') {
$entityTags = $params[$name];
- $allTags = CRM_Core_PseudoConstant::tag();
+ $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$title = array();
if (is_array($entityTags)) {
foreach ($entityTags as $tagId => $dontCare) {
}
// Get all custom groups
- $allGroups = CRM_Core_PseudoConstant::customGroup();
+ $allGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
// Get the custom groupIds for which the user have VIEW permission
require_once 'CRM/ACL/API.php';
$values = CRM_Core_BAO_EntityTag::getTag($entityID, $entityTable);
$result = array();
- $tags = CRM_Core_PseudoConstant::tag();
+ $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
foreach ($values as $v) {
$result[] = $tags[$v];
}
parent::setUp();
}
+ /**
+ * Assure CRM_Core_PseudoConstant::get() is working properly for a range of
+ * DAO fields having a <pseudoconstant> tag in the XML schema.
+ */
function testOptionValues() {
- /*
+ $custom_group_name = 'Test custom group';
+ $api_params = array(
+ 'version' => 3,
+ 'title' => $custom_group_name,
+ 'extends' => 'Individual',
+ );
+ civicrm_api('customGroup', 'create', $api_params);
+
+ /**
* daoName/field combinations to test
- * array[DAO Name] = properties, where properties can be:
+ * Format: array[DAO Name] = $properties, where properties is an array whose
+ * named members can be:
* - fieldName: the SQL column name within the DAO table.
* - sample: Any one value which is expected in the list of option values.
* - exclude: Any one value which should not be in the list.
* - max: integer (default = 10) maximum number of option values expected.
*/
$fields = array(
+ 'CRM_Core_DAO_CustomField' => array(
+ array(
+ 'fieldName' => 'custom_group_id',
+ 'sample' => $custom_group_name,
+ ),
+ ),
+ 'CRM_Core_DAO_EntityTag' => array(
+ array(
+ 'fieldName' => 'tag_id',
+ 'sample' => 'Government Entity',
+ ),
+ ),
'CRM_Core_DAO_OptionValue' => array(
array(
'fieldName' => 'component_id',
die("you need to profide a csv file (1st column parent name, 2nd tag name");
}
$this->file = $this->args[0];
- $this->tags = array_flip(CRM_Core_PseudoConstant::tag());
+ $this->tags = array_flip(CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)));
}
//format expected: parent name, tag
$form->addElement('select', 'group', ts('in'), $group);
// add select for categories
- $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::tag();
+ $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$form->addElement('select', 'tag', ts('Tagged'), $tag);
// text for sort_name
<type>int unsigned</type>
<required>true</required>
<comment>FK to civicrm_custom_group.</comment>
- <add>1.1</add>
+ <add>1.1</add>
+ <pseudoconstant>
+ <table>civicrm_custom_group</table>
+ <keyColumn>id</keyColumn>
+ <labelColumn>title</labelColumn>
+ </pseudoconstant>
</field>
<foreignKey>
<name>custom_group_id</name>
<title>Tag ID</title>
<required>true</required>
<comment>FK to civicrm_tag</comment>
- <add>1.1</add>
+ <add>1.1</add>
+ <pseudoconstant>
+ <table>civicrm_tag</table>
+ <keyColumn>id</keyColumn>
+ <labelColumn>name</labelColumn>
+ </pseudoconstant>
</field>
<foreignKey>
<name>tag_id</name>