X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FEntityTag.php;h=482203e230e0872fa4233c0958be18bb91ca2d72;hb=7fce4915eecc80f9f693a490548d579c1ca6aec6;hp=88561556d57b76927df8c51c5893fc39d179276c;hpb=872e6b74c3a65599d0ce40e2a4e88b52e4c9cf12;p=civicrm-core.git diff --git a/CRM/Core/BAO/EntityTag.php b/CRM/Core/BAO/EntityTag.php index 88561556d5..482203e230 100644 --- a/CRM/Core/BAO/EntityTag.php +++ b/CRM/Core/BAO/EntityTag.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * This class contains functions for managing Tag(tag) for a contact @@ -64,7 +64,7 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { } /** - * Takes an associative array and creates a entityTag object + * Takes an associative array and creates a entityTag object. * * the function extract all the params it needs to initialize the create a * group object. the params array could contain additional unused name/value @@ -98,7 +98,7 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { } /** - * Check if there is data to create the object + * Check if there is data to create the object. * * @param array $params * An assoc array of name/value pairs. @@ -110,7 +110,7 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { } /** - * Delete the tag for a contact + * Delete the tag for a contact. * * @param array $params * (reference ) an assoc array of name/value pairs. @@ -216,7 +216,7 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { } /** - * Takes an associative array and creates tag entity record for all tag entities + * Takes an associative array and creates tag entity record for all tag entities. * * @param array $params * (reference) an assoc array of name/value pairs. @@ -260,7 +260,7 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { } /** - * This function returns all entities assigned to a specific tag + * This function returns all entities assigned to a specific tag. * * @param object $tag * An object of a tag. @@ -280,7 +280,7 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { } /** - * Get contact tags + * Get contact tags. */ public static function getContactTags($contactID, $count = FALSE) { $contactTags = array(); @@ -313,7 +313,7 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { } /** - * Get child contact tags given parentId + * Get child contact tags given parentId. */ public static function getChildEntityTags($parentId, $entityId, $entityTable = 'civicrm_contact') { $entityTags = array(); @@ -403,14 +403,22 @@ 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; } + }