Merge pull request #4789 from totten/master-test-tx
[civicrm-core.git] / api / v3 / ContactType.php
index ed8ff1c222ffd99f35b4f9d6a754fb95329bf996..fede1f2ceb4a146eec1400dc6b9eacd2709424ec 100644 (file)
@@ -2,7 +2,7 @@
 
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -41,7 +41,7 @@
  * In case of updating existing contact_type, id of that particular contact_type must
  * be in $params array.
  *
- * @param array $params  (referance) Associative array of property
+ * @param array $params  (reference) Associative array of property
  *                       name/value pairs to insert in new 'contact_type'
  *
  * @return array   contact_type array
  */
 function civicrm_api3_contact_type_create($params) {
   civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__), array('name', 'parent_id'));
-  if (!array_key_exists('label', $params)) {
-    $params['label'] = $params['name'];
-  }
-  if (!array_key_exists('is_active', $params)) {
-    $params['is_active'] = TRUE;
+
+  if (empty($params['id'])) {
+    if (!array_key_exists('label', $params)) {
+      $params['label'] = $params['name'];
+    }
+    if (!array_key_exists('is_active', $params)) {
+      $params['is_active'] = TRUE;
+    }
+    $params['name'] = CRM_Utils_String::munge($params['name']);
   }
 
-  $params['name'] = CRM_Utils_String::munge($params['name']);
   return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
 
 /**
  * Returns array of contact_types  matching a set of one or more group properties
  *
- * @param array $params  (referance) Array of one or more valid
+ * @param array $params one or more valid
  *                       property_name=>value pairs. If $params is set
  *                       as null, all contact_types will be returned
  *
- * @return array  (referance) Array of matching contact_types
+ * @return array Array of matching contact_types
  * @access public
  */
 function civicrm_api3_contact_type_get($params) {
@@ -82,11 +85,10 @@ function civicrm_api3_contact_type_get($params) {
  * This method is used to delete any existing contact_type. id of the group
  * to be deleted is required field in $params array
  *
- * @param array $params  (reference) array containing id of the group
+ * @param array $params array containing id of the group
  *                       to be deleted
  *
- * @return array  (referance) returns flag true if successfull, error
- *                message otherwise
+ * @return array  API Result Array
  *
  * @access public
  */