Merge pull request #5473 from aydun/CRM-16160
[civicrm-core.git] / api / v3 / Profile.php
index 3532e5dbd00dfdef5439b55af6c4c06ee4f3f88f..23682854ed30d0f6eed2892390413fc1d33f0768 100644 (file)
@@ -3,7 +3,7 @@
   +--------------------------------------------------------------------+
   | CiviCRM version 4.6                                                |
   +--------------------------------------------------------------------+
-  | Copyright CiviCRM LLC (c) 2004-2014                                |
+  | Copyright CiviCRM LLC (c) 2004-2015                                |
   +--------------------------------------------------------------------+
   | This file is a part of CiviCRM.                                    |
   |                                                                    |
  */
 
 /**
- * This api exposes CiviCRM activity profile.
+ * This api exposes CiviCRM profiles.
+ *
+ * Profiles are collections of fields used as forms, listings, search columns, etc.
  *
  * @package CiviCRM_APIv3
- * @subpackage API_ActivityProfile
  */
 
 /**
@@ -173,7 +174,7 @@ function civicrm_api3_profile_submit($params) {
 
   $contactParams = $activityParams = $missingParams = array();
 
-  $profileFields = civicrm_api3('profile', 'getfields', array('action' => 'submit', 'profile_id' => $profileID));
+  $profileFields = civicrm_api3('Profile', 'getfields', array('action' => 'submit', 'profile_id' => $profileID));
   $profileFields = $profileFields['values'];
   if ($isContactActivityProfile) {
     civicrm_api3_verify_mandatory($params, NULL, array('activity_id'));
@@ -244,47 +245,7 @@ function civicrm_api3_profile_submit($params) {
     $profileParams['api.activity.create'] = $activityParams;
   }
 
-  $groups = $tags = array();
-  if (isset($profileParams['group'])) {
-    $groups = $profileParams['group'];
-    unset($profileParams['group']);
-  }
-
-  if (isset($profileParams['tag'])) {
-    $tags = $profileParams['tag'];
-    unset($profileParams['tag']);
-  }
-
   return civicrm_api3('contact', 'create', $profileParams);
-
-  $ufGroupDetails = array();
-  $ufGroupParams = array('id' => $profileID);
-  CRM_Core_BAO_UFGroup::retrieve($ufGroupParams, $ufGroupDetails);
-
-  if (isset($profileFields['group'])) {
-    CRM_Contact_BAO_GroupContact::create($groups,
-      $params['contact_id'],
-      FALSE,
-      'Admin'
-    );
-  }
-
-  if (isset($profileFields['tag'])) {
-    CRM_Core_BAO_EntityTag::create($tags,
-      'civicrm_contact',
-      $params['contact_id']
-    );
-  }
-
-  if (!empty($ufGroupDetails['add_to_group_id'])) {
-    $contactIds = array($params['contact_id']);
-    CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds,
-      $ufGroupDetails['add_to_group_id']
-    );
-  }
-
-  return $result;
-
 }
 
 /**
@@ -333,15 +294,14 @@ function _civicrm_api3_profile_submit_spec(&$params, $apirequest) {
 }
 
 /**
- * Set profile - deprecated.
+ * Update Profile field values.
  *
  * @deprecated - calling this function directly is deprecated as 'set' is not a clear action
  * use submit
- * Update Profile field values.
  *
  * @param array $params
  *   Array of property name/value.
- *                             pairs to update profile field values
+ *   pairs to update profile field values
  *
  * @return array
  *   Updated Contact/ Activity object|CRM_Error
@@ -351,14 +311,14 @@ function civicrm_api3_profile_set($params) {
 }
 
 /**
- * Apply profile - deprecated.
+ * Apply profile.
  *
  * @deprecated - appears to be an internal function - should not be accessible via api
  * Provide formatted values for profile fields.
  *
  * @param array $params
  *   Array of property name/value.
- *                             pairs to profile field values
+ *   pairs to profile field values
  *
  * @throws API_Exception
  * @return array
@@ -367,7 +327,6 @@ function civicrm_api3_profile_set($params) {
  * @todo add test cases
  */
 function civicrm_api3_profile_apply($params) {
-
   $profileFields = CRM_Core_BAO_UFGroup::getFields($params['profile_id'],
     FALSE,
     NULL,