/** * Get a Tag. * * This api is used for finding an existing tag. * Either id or name of tag are required parameters for this api. * * @param array $params an associative array of name/value pairs. * * @return array details of found tag else error * @access public */ function civicrm_tag_get($params) { _civicrm_initialize(); require_once 'CRM/Core/BAO/Tag.php'; $tagBAO = new CRM_Core_BAO_Tag(); if (!is_array($params)) { return civicrm_create_error('Params is not an array.'); } if (!isset($params['id']) && !isset($params['name'])) { return civicrm_create_error('Required parameters missing.'); } $properties = array('id', 'name', 'description', 'parent_id', 'is_selectable', 'is_hidden', 'is_reserved', 'used_for'); foreach ($properties as $name) { if (array_key_exists($name, $params)) { $tagBAO->{$name} = $params[$name]; } } if (!$tagBAO->find(TRUE)) { return civicrm_create_error('Exact match not found.'); } _civicrm_object_to_array($tagBAO, $tag); $tag['is_error'] = 0; return $tag; }