X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FEntityTag.php;h=482203e230e0872fa4233c0958be18bb91ca2d72;hb=effbca4ff9428542add5a429ab3f492b07d52d92;hp=2064277944b02cb02d945deb69ffcea4674997c7;hpb=b71cb96619f284fb007d4365c33f59f088573d8f;p=civicrm-core.git diff --git a/CRM/Core/BAO/EntityTag.php b/CRM/Core/BAO/EntityTag.php index 2064277944..482203e230 100644 --- a/CRM/Core/BAO/EntityTag.php +++ b/CRM/Core/BAO/EntityTag.php @@ -403,14 +403,21 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { public static function buildOptions($fieldName, $context = NULL, $props = array()) { $params = array(); - $options = CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context); + if ($fieldName == 'tag' || $fieldName == 'tag_id') { + if (!empty($props['entity_table'])) { + $entity = CRM_Utils_Type::escape($props['entity_table'], 'String'); + $params[] = "used_for LIKE '%$entity%'"; + } - // Output tag list as nested hierarchy - // TODO: This will only work when api.entity is "entity_tag". What about others? - if (($fieldName == 'tag' || $fieldName == 'tag_id') && ($context == 'search' || $context == 'create')) { - $options = CRM_Core_BAO_Tag::getTags('civicrm_contact', CRM_Core_DAO::$_nullArray, CRM_Utils_Array::value('parent_id', $params), '- '); + // Output tag list as nested hierarchy + // TODO: This will only work when api.entity is "entity_tag". What about others? + if ($context == 'search' || $context == 'create') { + return CRM_Core_BAO_Tag::getTags(CRM_Utils_Array::value('entity_table', $props, 'civicrm_contact'), CRM_Core_DAO::$_nullArray, CRM_Utils_Array::value('parent_id', $params), '- '); + } } + $options = CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context); + return $options; }