Exemplo n.º 1
0
/**
 * 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
 *
 * @throws API_Exception
 * @return array
 *
 * @todo add example
 * @todo add test cases
 */
function civicrm_api3_profile_apply($params)
{
    $profileFields = CRM_Core_BAO_UFGroup::getFields($params['profile_id'], FALSE, NULL, NULL, NULL, FALSE, NULL, TRUE, NULL, CRM_Core_Permission::EDIT);
    list($data, $contactDetails) = CRM_Contact_BAO_Contact::formatProfileContactParams($params, $profileFields, CRM_Utils_Array::value('contact_id', $params), $params['profile_id'], CRM_Utils_Array::value('contact_type', $params), CRM_Utils_Array::value('skip_custom', $params, FALSE));
    if (empty($data)) {
        throw new API_Exception('Unable to format profile parameters.');
    }
    return civicrm_api3_create_success($data);
}
/**
 * Provide formatted values for profile fields.
 *
 * @param array  $params       Associative array of property name/value
 *                             pairs to profile field values
 *
 * @return formatted profile field values|CRM_Error
 *
 * @todo add example
 * @todo add test cases
 *
 */
function civicrm_api3_profile_apply($params)
{
    civicrm_api3_verify_mandatory($params, NULL, array('profile_id'));
    require_once 'CRM/Contact/BAO/Contact.php';
    if (!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $params['profile_id'], 'is_active')) {
        return civicrm_api3_create_error('Invalid value for profile_id');
    }
    $profileFields = CRM_Core_BAO_UFGroup::getFields($params['profile_id'], FALSE, NULL, NULL, NULL, FALSE, NULL, TRUE, NULL, CRM_Core_Permission::EDIT);
    list($data, $contactDetails) = CRM_Contact_BAO_Contact::formatProfileContactParams($params, $profileFields, CRM_Utils_Array::value('contact_id', $params), $params['profile_id'], CRM_Utils_Array::value('contact_type', $params), CRM_Utils_Array::value('skip_custom', $params, FALSE));
    if (empty($data)) {
        return civicrm_api3_create_error('Enable to format profile parameters.');
    }
    return civicrm_api3_create_success($data);
}