Merge pull request #6595 from eileenmcnaughton/CRM-16996
[civicrm-core.git] / api / v3 / UFField.php
index 2d5c55ed86952004044fa3fa8963c456cc646823..9f028687fc5f9a0953730475281bd30e8ec2bd5c 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -29,8 +29,6 @@
  * This api exposes CiviCRM profile field.
  *
  * @package CiviCRM_APIv3
- * @subpackage API_UF
- *
  */
 
 /**
@@ -53,10 +51,10 @@ function civicrm_api3_uf_field_create($params) {
 
   $field_type       = CRM_Utils_Array::value('field_type', $params);
   $field_name       = CRM_Utils_Array::value('field_name', $params);
-  $location_type_id = CRM_Utils_Array::value('location_type_id', $params);
+  $location_type_id = CRM_Utils_Array::value('location_type_id', $params, CRM_Utils_Array::value('website_type_id', $params));
   $phone_type       = CRM_Utils_Array::value('phone_type_id', $params, CRM_Utils_Array::value('phone_type', $params));
 
-  if (!CRM_Core_BAO_UFField::isValidFieldName($field_name)) {
+  if (strpos($field_name, 'formatting') !== 0 && !CRM_Core_BAO_UFField::isValidFieldName($field_name)) {
     throw new API_Exception('The field_name is not valid');
   }
   $params['field_name'] = array($field_type, $field_name, $location_type_id, $phone_type);
@@ -109,12 +107,11 @@ function civicrm_api3_uf_field_create($params) {
  */
 function _civicrm_api3_uf_field_create_spec(&$params) {
   $params['option.autoweight'] = array(
-    'title' => "Automatically adjust weights in UFGroup to align with UFField",
+    'title' => "Auto Weight",
+    'description' => "Automatically adjust weights in UFGroup to align with UFField",
     'type' => CRM_Utils_Type::T_BOOLEAN,
     'api.default' => TRUE,
   );
-  $params['created_id']['api.default'] = 'user_contact_id';
-  $params['created_id']['title']  = 'Created By';
   $params['is_active']['api.default'] = TRUE;
 }