CRM-14446 contact.get api tests + fix on date filters
[civicrm-core.git] / api / v3 / Tag.php
index 490862866bfda8a9f43533cd3fe5d81c4c216e68..daa5f2dd6d4d0de8246fdba42e21961fb9fa3510 100644 (file)
@@ -1,9 +1,7 @@
 <?php
-// $Id$
-
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
  * @version $Id: Tag.php 30486 2010-11-02 16:12:09Z shot $
  */
 
-/**
- * Include utility functions
- */
-require_once 'CRM/Core/BAO/Tag.php';
-
 /**
  *  Add a Tag. Tags are used to classify CRM entities (including Contacts, Groups and Actions).
  *
@@ -54,28 +47,17 @@ require_once 'CRM/Core/BAO/Tag.php';
  * @access public
  */
 function civicrm_api3_tag_create($params) {
-
-  $ids = array('tag' => CRM_Utils_Array::value('tag', $params));
-  if (CRM_Utils_Array::value('tag', $params)) {
-    $ids['tag'] = $params['tag'];
-  }
-  if (CRM_Utils_Array::value('id', $params)) {
-    $ids['tag'] = $params['id'];
-  }
-  $tagBAO = CRM_Core_BAO_Tag::add($params, $ids);
-
-    $values = array();
-    _civicrm_api3_object_to_array($tagBAO, $values[$tagBAO->id]);
-    return civicrm_api3_create_success($values, $params, 'tag', 'create', $tagBAO);
-  }
+  return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
 
 /**
- * Specify Meta data for create. Note that this data is retrievable via the getfields function 
+ * Specify Meta data for create. Note that this data is retrievable via the getfields function
  * and is used for pre-filling defaults and ensuring mandatory requirements are met.
  */
 function _civicrm_api3_tag_create_spec(&$params) {
   $params['used_for']['api.default'] = 'civicrm_contact';
   $params['name']['api.required'] = 1;
+  $params['id']['api.aliases'] = array('tag');
 }
 
 /**