Example #1
0
/**
 * Returns all entities assigned to a specific Tag. Optionally filtered by entity_type.
 *
 * @param  $tag         object  Valid Tag object.
 * @param  $entity_type enum    Optional filter for type of entity being queried. Valid values: 'Individual', 'Organization', 'Household', 'Group', 'Contact_action'.
 *
 * @return $entities    Array   An array of entity objects (Individuals and/or Organizations and/or etc.).
 * @access public
 */
function crm_get_entities_by_tag(&$tag, $entity_type = null)
{
    require_once 'CRM/Core/BAO/EntityTag.php';
    if (!isset($tag->id)) {
        return _crm_error('Invalid tag object passed in');
    }
    $contactIDs =& CRM_Core_BAO_EntityTag::getEntitiesByTag($tag);
    $entities = array();
    foreach ($contactIDs as $Id) {
        $params = array('contact_id' => $Id);
        if ($entity_type != null) {
            $temp = clone crm_get_contact($params);
            if ($entity_type == $temp->contact_type) {
                $entities[] = $temp;
            }
        } else {
            $entities[] = clone crm_get_contact($params);
        }
    }
    return $entities;
}
/**
 * Returns all entities assigned to a specific Tag.
 *
 * @param  $params      Array   an array valid Tag id
 *
 * @return $entities    Array   An array of entity ids.
 * @access public
 */
function civicrm_tag_entities_get(&$params)
{
    require_once 'CRM/Core/BAO/Tag.php';
    require_once 'CRM/Core/BAO/EntityTag.php';
    $tag = new CRM_Core_BAO_Tag();
    $tag->id = CRM_Utils_Array::value('tag_id', $params) ? $params['tag_id'] : NULL;
    $entities = CRM_Core_BAO_EntityTag::getEntitiesByTag($tag);
    return $entities;
}
Example #3
0
/**
 * Returns all entities assigned to a specific Tag.
 * @param  $params      Array   an array valid Tag id                               
 * @return $entities    Array   An array of entity ids.
 * @access public
 */
function civicrm_tag_entities_get(&$params)
{
    require_once 'CRM/Core/BAO/Tag.php';
    require_once 'CRM/Core/BAO/EntityTag.php';
    $tag = new CRM_Core_BAO_Tag();
    $tag->id = $params['tag_id'] ? $params['tag_id'] : null;
    $entities =& CRM_Core_BAO_EntityTag::getEntitiesByTag($tag);
    return $entities;
}