static $skipWhere = NULL;
static $likeNames = NULL;
$result = NULL;
+ // Change camelCase EntityName to lowercase with underscores
+ $apiEntity = _civicrm_api_get_entity_name_from_camel($apiEntity);
if (CRM_Utils_System::isNull($values)) {
return $result;
* @param array $params
* (reference ) an assoc array of name/value pairs.
* @param array $ids
- * The array that holds all the db ids.
+ * Unused variable.
*
* @return CRM_Core_DAO_ActionSchedule
*/
$actionSchedule->mapping_id = $mappingID;
$actionSchedule->is_active = 1;
if (!empty($params)) {
- _civicrm_api3_dao_set_filter($actionSchedule, $params, FALSE, 'ActionSchedule');
+ _civicrm_api3_dao_set_filter($actionSchedule, $params, FALSE);
}
$actionSchedule->find();
*/
/**
- * This api exposes CiviCRM acl.
+ * This api exposes CiviCRM Acl records.
*
* @package CiviCRM_APIv3
*/
/**
- * Save an acl.
+ * Save an Acl.
*
* @param array $params
*
* @return array
- * Array of newly created acl property values.
*/
function civicrm_api3_acl_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
- * Get an acl.
+ * Get an Acl.
*
* @param array $params
*
* @return array
- * Array of retrieved acl property values.
+ * Array of retrieved Acl property values.
*/
function civicrm_api3_acl_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
- * Delete an acl.
+ * Delete an Acl.
*
* @param array $params
*
*/
/**
- * This api exposes CiviCRM acl_role.
+ * This api exposes CiviCRM AclRole.
*
* @package CiviCRM_APIv3
*/
/**
- * Save an acl_role.
+ * Save an AclRole.
*
* Allowed @params array keys are:
*
* @param array $params
*
* @return array
- * Array of newly created acl_role property values.
*/
function civicrm_api3_acl_role_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
- * Get an acl_role.
+ * Get an AclRole.
*
* @param array $params
*
* @return array
- * Array of retrieved acl_role property values.
+ * Array of retrieved AclRole property values.
*/
function civicrm_api3_acl_role_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
- * Delete an acl_role.
+ * Delete an AclRole.
*
* @param array $params
*
*/
/**
- * Get CiviCRM Action Schedule details.
+ * Get CiviCRM ActionSchedule details.
*
* @param array $params
*
* @return array
*/
function civicrm_api3_action_schedule_get($params) {
- return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'action_schedule');
+ return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'ActionSchedule');
}
/**
- * Create a new Action Schedule.
+ * Create a new ActionSchedule.
*
* @param array $params
*
if (!array_key_exists('name', $params) && !array_key_exists('id', $params)) {
$params['name'] = CRM_Utils_String::munge($params['title']);
}
- return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'action_schedule');
+ return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'ActionSchedule');
}
/**
}
/**
- * Delete an existing action_schedule.
+ * Delete an existing ActionSchedule.
*
* @param array $params
* Array containing id of the action_schedule to be deleted.
*/
/**
- * This api exposes CiviCRM activity.
+ * This api exposes CiviCRM Activity records.
*
* @package CiviCRM_APIv3
*/
}
_civicrm_api3_object_to_array($activityBAO, $activityArray[$activityBAO->id]);
- return civicrm_api3_create_success($activityArray, $params, 'activity', 'get', $activityBAO);
+ return civicrm_api3_create_success($activityArray, $params, 'Activity', 'get', $activityBAO);
}
}
else {
$activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE);
}
- $options = _civicrm_api3_get_options_from_params($params, FALSE, 'activity', 'get');
+ $options = _civicrm_api3_get_options_from_params($params, FALSE, 'Activity', 'get');
if ($options['is_count']) {
- return civicrm_api3_create_success($activities, $params, 'activity', 'get');
+ return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
$activities = _civicrm_api3_activity_get_formatResult($params, $activities);
//legacy custom data get - so previous formatted response is still returned too
- return civicrm_api3_create_success($activities, $params, 'activity', 'get');
+ return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
/**
function civicrm_api3_activity_delete($params) {
if (CRM_Activity_BAO_Activity::deleteActivity($params)) {
- return civicrm_api3_create_success(1, $params, 'activity', 'delete');
+ return civicrm_api3_create_success(1, $params, 'Activity', 'delete');
}
else {
- throw new API_Exception('Could not delete activity');
+ throw new API_Exception('Could not delete Activity');
}
}
*/
/**
- * This api exposes CiviCRM activity contact.
+ * This api exposes the CiviCRM ActivityContact join table.
*
* @package CiviCRM_APIv3
*/
*/
/**
- * The activity_type api is deprecated. Please use the option_value api instead.
+ * The ActivityType api is deprecated. Please use the OptionValue api instead.
*
* @deprecated
*
* to indicate this entire api entity is deprecated
*/
function _civicrm_api3_activity_type_deprecation() {
- return 'The activity_type api is deprecated. Please use the option_value api instead.';
+ return 'The ActivityType api is deprecated. Please use the OptionValue api instead.';
}
/**
*
* @return array
* activity types keyed by id
- * @deprecated - use getoptions
+ * @deprecated - use the getoptions action instead
*/
function civicrm_api3_activity_type_get($params) {
* @return array
* created / updated activity type
*
- * @deprecated use option_value api
+ * @deprecated use the OptionValue api instead
*/
function civicrm_api3_activity_type_create($params) {
}
/**
- * Delete activity type.
+ * Delete ActivityType.
*
* @param array $params
* Array including id of activity_type to delete.
* @return array
* API result array
*
- * @deprecated use option_value api
+ * @deprecated use OptionValue api
*/
function civicrm_api3_activity_type_delete($params) {
return civicrm_api3_create_success(CRM_Core_BAO_OptionValue::del($params['id']), $params);
*/
/**
- * This api exposes CiviCRM address records.
+ * This api exposes CiviCRM Address records.
*
* @package CiviCRM_APIv3
*/
* Array per getfields metadata.
*
* @return array
- * Array of newly created tag property values.
*/
function civicrm_api3_address_create(&$params) {
/**
}
else {
$values = _civicrm_api3_dao_to_array($addressBAO, $params);
- return civicrm_api3_create_success($values, $params, 'address', $addressBAO);
+ return civicrm_api3_create_success($values, $params, 'Address', $addressBAO);
}
}
}
/**
- * Create an attachment.
+ * Create an Attachment.
*
* @param array $params
*
* @return array
- * Array of newly created file property values.
* @throws API_Exception validation errors
* @see Civi\API\Subscriber\DynamicFKAuthorization
*/
}
/**
- * Get attachment.
+ * Get Attachment.
*
* @param array $params
*
}
/**
- * Adjust metadata for attachment delete action.
+ * Adjust metadata for Attachment delete action.
*
* @param $spec
*/
}
/**
- * Delete attachment.
+ * Delete Attachment.
*
* @param array $params
*
*/
/**
- * This api exposes CiviCRM batch.
+ * This api exposes CiviCRM Batch records.
*
* @package CiviCRM_APIv3
*/
* @param array $params
*
* @return array
- * Array of newly created batch property values.
*/
function civicrm_api3_batch_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
*/
/**
- * This api exposes CiviCRM campaign records.
+ * This api exposes CiviCRM Campaign records.
*
* @note Campaign component must be enabled.
*
*/
/**
- * Create/update campaign.
+ * Create/update Campaign.
*
* This API is used to create new campaign or update any of the existing
* In case of updating existing campaign, id of that particular campaign must
}
/**
- * Returns array of campaigns matching a set of one or more group properties.
+ * Returns array of campaigns matching a set of one or more properties.
*
* @param array $params
* Array per getfields
/**
* Delete an existing campaign.
*
- * This method is used to delete any existing campaign. id of the group
- * to be deleted is required field in $params array
+ * This method is used to delete any existing campaign.
+ * Id of the campaign to be deleted is required field in $params array
*
* @param array $params
* array containing id of the group to be deleted
/**
- * Open a new case, add client and manager roles, and add standard timeline.
+ * Open a new case, add client and manager roles, and standard timeline.
*
* @param array $params
* @code
$values = array();
_civicrm_api3_object_to_array($caseBAO, $values[$caseBAO->id]);
- return civicrm_api3_create_success($values, $params, 'case', 'create', $caseBAO);
+ return civicrm_api3_create_success($values, $params, 'Case', 'create', $caseBAO);
}
/**
$cases[$id] = $case;
}
}
- return civicrm_api3_create_success($cases, $params, 'case', 'get');
+ return civicrm_api3_create_success($cases, $params, 'Case', 'get');
}
//search by activity
}
$caseId = CRM_Case_BAO_Case::getCaseIdByActivityId($params['activity_id']);
if (!$caseId) {
- return civicrm_api3_create_success(array(), $params, 'case', 'get');
+ return civicrm_api3_create_success(array(), $params, 'Case', 'get');
}
$case = array($caseId => _civicrm_api3_case_read($caseId, $options));
- return civicrm_api3_create_success($case, $params, 'case', 'get');
+ return civicrm_api3_create_success($case, $params, 'Case', 'get');
}
//search by contacts
while ($dao->fetch()) {
$cases[$dao->case_id] = _civicrm_api3_case_read($dao->case_id, $options);
}
- return civicrm_api3_create_success($cases, $params, 'case', 'get');
+ return civicrm_api3_create_success($cases, $params, 'Case', 'get');
}
// For historic reasons we always return these when an id is provided
}
}
- return civicrm_api3_create_success($cases, $params, 'case', 'get');
+ return civicrm_api3_create_success($cases, $params, 'Case', 'get');
}
/**
_civicrm_api3_object_to_array($dao, $case);
$values[$dao->id] = $case;
- return civicrm_api3_create_success($values, $params, 'case', 'update', $dao);
+ return civicrm_api3_create_success($values, $params, 'Case', 'update', $dao);
}
/**
* Delete a specified case.
*
* @param array $params
+ * @code
* //REQUIRED:
* 'id' => int
*
* //OPTIONAL
* 'move_to_trash' => bool (defaults to false)
+ * @endcode
*
* @throws API_Exception
* @return bool
civicrm_api3_verify_mandatory($params, NULL, array('id'));
if (CRM_Case_BAO_Case::deleteCase($params['id'], CRM_Utils_Array::value('move_to_trash', $params, FALSE))) {
- return civicrm_api3_create_success($params, $params, 'case', 'delete');
+ return civicrm_api3_create_success($params, $params, 'Case', 'delete');
}
else {
throw new API_Exception('Could not delete case.');
* Function to delete case type.
*
* @param array $params
- * Array including id of case_type to delete.
+ * Array including id of CaseType to delete.
*
* @return array
* API result array
* CiviCRM APIv3 pseudoconstants
*
* @deprecated
- * The constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.
+ * The Constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.
* @package CiviCRM_APIv3
*/
* to indicate this entire api entity is deprecated
*/
function _civicrm_api3_constant_deprecation() {
- return 'The constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.';
+ return 'The Constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.';
}
/**
* @param array $params
* Name of a public static method of
* CRM_Core_PseudoConstant: one of
- * <ul>
- * <li>activityStatus</li>
- * <li>activityType</li>
- * <li>addressee</li>
- * <li>allGroup</li>
- * <li>country</li>
- * <li>countryIsoCode</li>
- * <li>county</li>
- * <li>currencyCode</li>
- * <li>currencySymbols</li>
- * <li>customGroup</li>
- * <li>emailGreeting</li>
- * <li>fromEmailAddress</li>
- * <li>gender</li>
- * <li>group</li>
- * <li>groupIterator</li>
- * <li>honor</li>
- * <li>IMProvider</li>
- * <li>individualPrefix</li>
- * <li>individualSuffix</li>
- * <li>locationType</li>
- * <li>locationVcardName</li>
- * <li>mailProtocol</li>
- * <li>mappingTypes</li>
- * <li>paymentProcessor</li>
- * <li>paymentProcessorType</li>
- * <li>pcm</li>
- * <li>phoneType</li>
- * <li>postalGreeting</li>
- * <li>priority</li>
- * <li>relationshipType</li>
- * <li>stateProvince</li>
- * <li>stateProvinceAbbreviation</li>
- * <li>stateProvinceForCountry</li>
- * <li>staticGroup</li>
- * <li>tag</li>
- * <li>tasks</li>
- * <li>ufGroup</li>
- * <li>visibility</li>
- * <li>worldRegion</li>
- * <li>wysiwygEditor</li>
- * </ul>
+ * activityStatus
+ * activityType
+ * addressee
+ * allGroup
+ * country
+ * countryIsoCode
+ * county
+ * currencyCode
+ * currencySymbols
+ * customGroup
+ * emailGreeting
+ * fromEmailAddress
+ * gender
+ * group
+ * groupIterator
+ * honor
+ * IMProvider
+ * individualPrefix
+ * individualSuffix
+ * locationType
+ * locationVcardName
+ * mailProtocol
+ * mappingTypes
+ * paymentProcessor
+ * paymentProcessorType
+ * pcm
+ * phoneType
+ * postalGreeting
+ * priority
+ * relationshipType
+ * stateProvince
+ * stateProvinceAbbreviation
+ * stateProvinceForCountry
+ * staticGroup
+ * tag
+ * tasks
+ * ufGroup
+ * visibility
+ * worldRegion
+ * wysiwygEditor
*
* @return array
*/
//@TODO XAV take out the param the COOKIE, Entity, Action and so there are only the "real param" in it
//$values = call_user_func_array( array( $className, $name ), $params );
}
- return civicrm_api3_create_success($values, $params, 'constant');
+ return civicrm_api3_create_success($values, $params, 'Constant');
}
else {
$values = call_user_func(array('CRM_Utils_PseudoConstant', 'getConstant'), $name);
if (!empty($values)) {
- return civicrm_api3_create_success($values, $params, 'constant');
+ return civicrm_api3_create_success($values, $params, 'Constant');
}
}
return civicrm_api3_create_error('Unknown civicrm constant or method not callable');
/**
* This api exposes CiviCRM contacts.
+ *
* Contacts are the main entity in CiviCRM and this api is more robust than most.
* - Get action allows all params supported by advanced search.
* - Create action allows creating several related entities at once (e.g. email).
*/
/**
- * Create or update a contact.
+ * Create or update a Contact.
*
* @param array $params
* Input parameters.
function civicrm_api3_contact_get($params) {
$options = array();
_civicrm_api3_contact_get_supportanomalies($params, $options);
- $contacts = _civicrm_api3_get_using_query_object('contact', $params, $options);
- return civicrm_api3_create_success($contacts, $params, 'contact');
+ $contacts = _civicrm_api3_get_using_query_object('Contact', $params, $options);
+ return civicrm_api3_create_success($contacts, $params, 'Contact');
}
/**
- * Get count of contact.
+ * Get number of contacts matching the supplied criteria.
*
* @param array $params
*
function civicrm_api3_contact_getcount($params) {
$options = array();
_civicrm_api3_contact_get_supportanomalies($params, $options);
- $count = _civicrm_api3_get_using_query_object('contact', $params, $options, 1);
+ $count = _civicrm_api3_get_using_query_object('Contact', $params, $options, 1);
return (int) $count;
}
/**
* Support for historical oddities.
*
- * We are supporting 'showAll' = 'all', 'trash' or 'active' for contact get
+ * We are supporting 'showAll' = 'all', 'trash' or 'active' for Contact get
* and for getcount
* - hopefully some day we'll come up with a std syntax for the 3-way-boolean of
* 0, 1 or not set
}
/**
- * Delete a contact with given contact id.
+ * Delete a Contact with given contact_id.
*
* @param array $params
* input parameters per getfields
$params['employer_id'] = $dupeIds[0];
}
else {
- $result = civicrm_api3('contact', 'create', array(
+ $result = civicrm_api3('Contact', 'create', array(
'organization_name' => $params['current_employer'],
'contact_type' => 'Organization',
));
}
/**
- * Helper function for contact create.
+ * Helper function for Contact create.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
}
/**
- * Old contact quick search api.
+ * Old Contact quick search api.
*
* @deprecated
*
$where .= " AND cc.contact_type LIKE '{$contactType}'";
}
- //set default for current_employer or return contact with particular id
+ // Set default for current_employer or return contact with particular id
if (!empty($params['id'])) {
$where .= " AND cc.id = " . (int) $params['id'];
}
$where .= " AND cc.id <> " . (int) $params['cid'];
}
- //contact's based of relationhip type
+ // Contact's based of relationhip type
$relType = NULL;
if (!empty($params['rel'])) {
$relation = explode('_', CRM_Utils_Array::value('rel', $params));
}
}
- return civicrm_api3_create_success($contactList, $params, 'contact', 'getquick');
+ return civicrm_api3_create_success($contactList, $params, 'Contact', 'getquick');
}
/**
$contacts[] = $dao->toArray();
}
- return civicrm_api3_create_success($contacts, $params, 'contact', 'get_by_location', $dao);
+ return civicrm_api3_create_success($contacts, $params, 'Contact', 'get_by_location', $dao);
}
*/
/**
- * Create/update contact_type.
+ * Create/update ContactType.
*
- * This API is used to create new contact_type or update any of the existing
- * In case of updating existing contact_type, id of that particular contact_type must
+ * This API is used to create new ContactType or update any of the existing
+ * In case of updating existing ContactType, id of that particular ContactType must
* be in $params array.
*
* @param array $params
* Array per getfields metadata.
*
* @return array
- * contact_type array
+ * ContactType array
*/
function civicrm_api3_contact_type_create($params) {
civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__), array('name', 'parent_id'));
}
/**
- * Delete an existing contact_type.
+ * Delete an existing ContactType.
*
- * This method is used to delete any existing contact_type. id of the group
- * to be deleted is required field in $params array
+ * This method is used to delete any existing ContactType given its id.
*
* @param array $params
* [id]
*/
/**
- * Add or update a contribution.
+ * Add or update a Contribution.
*
* @param array $params
* Input parameters.
}
/**
- * Delete a contribution.
+ * Delete a Contribution.
*
* @param array $params
* Input parameters.
function civicrm_api3_contribution_get($params) {
$mode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE;
- $entity = 'contribution';
- list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, $entity);
+ list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, 'Contribution');
$contribution = array();
while ($dao->fetch()) {
// format soft credit for backward compatibility
_civicrm_api3_format_soft_credit($contribution[$dao->contribution_id]);
}
- return civicrm_api3_create_success($contribution, $params, 'contribution', 'get', $dao);
+ return civicrm_api3_create_success($contribution, $params, 'Contribution', 'get', $dao);
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_contribution_transact_spec(&$params) {
- $fields = civicrm_api3('contribution', 'getfields', array('action' => 'create'));
+ $fields = civicrm_api3('Contribution', 'getfields', array('action' => 'create'));
$params = array_merge($params, $fields['values']);
$params['receive_date']['api.default'] = 'now';
}
$transaction = $payment->doPayment($params);
$params['payment_instrument_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType', $paymentProcessor['payment_processor_type_id'], 'payment_type') == 1 ? 'Credit Card' : 'Debit Card';
- return civicrm_api('contribution', 'create', $params);
+ return civicrm_api('Contribution', 'create', $params);
}
/**
*/
/**
- * Create or update a contribution_page.
+ * Create or update a ContributionPage.
*
* @param array $params
* Array per getfields metadata.
}
/**
- * Returns array of contribution_pages matching a set of one or more group properties.
+ * Returns array of ContributionPage(s) matching a set of one or more group properties.
*
* @param array $params
* Array per getfields metadata.
}
/**
- * Delete an existing contribution_page.
+ * Delete an existing ContributionPage.
*
- * This method is used to delete any existing contribution_page. id of the group
- * to be deleted is required field in $params array
+ * This method is used to delete any existing ContributionPage given its id.
*
* @param array $params
* Array per getfields metadata.
}
/**
- * Submit a contribution_page.
+ * Submit a ContributionPage.
*
* @param array $params
* Array per getfields metadata.
*/
function civicrm_api3_contribution_page_submit($params) {
$result = CRM_Contribute_Form_Contribution_Confirm::submit($params);
- return civicrm_api3_create_success($result, $params, 'contribution_page', 'submit');
+ return civicrm_api3_create_success($result, $params, 'ContributionPage', 'submit');
}
*/
/**
- * Create or update a contribution_recur.
+ * Create or update a ContributionRecur.
*
* @param array $params
* Array per getfields metadata.
}
/**
- * Cancel a recurring contribution of existing contribution_recur.id.
+ * Cancel a recurring contribution of existing ContributionRecur given its id.
*
* @param array $params
* Array containing id of the recurring contribution.
}
/**
- * Delete an existing contribution_recur.
+ * Delete an existing ContributionRecur.
*
- * This method is used to delete any existing contribution_recur. id of the group
- * to be deleted is required field in $params array
+ * This method is used to delete an existing ContributionRecur given its id.
*
* @param array $params
* [id]
*/
/**
- * This api exposes CiviCRM soft credit.
+ * This api exposes CiviCRM soft credits.
*
* @package CiviCRM_APIv3
*/
$customField = CRM_Core_BAO_CustomField::create($params);
_civicrm_api3_object_to_array_unique_fields($customField, $values[$customField->id]);
_civicrm_api3_custom_field_flush_static_caches();
- return civicrm_api3_create_success($values, $params, 'custom_field', $customField);
+ return civicrm_api3_create_success($values, $params, 'CustomField', $customField);
}
/**
* Flush static caches in functions that might have stored available custom fields.
*/
function _civicrm_api3_custom_field_flush_static_caches() {
- civicrm_api('custom_field', 'getfields', array('version' => 3, 'cache_clear' => 1));
+ civicrm_api('CustomField', 'getfields', array('version' => 3, 'cache_clear' => 1));
CRM_Core_BAO_UFField::getAvailableFieldsFlat(TRUE);
}
$field->id = $params['id'];
$field->find(TRUE);
$customFieldDelete = CRM_Core_BAO_CustomField::deleteField($field);
- civicrm_api('custom_field', 'getfields', array('version' => 3, 'cache_clear' => 1));
+ civicrm_api('CustomField', 'getfields', array('version' => 3, 'cache_clear' => 1));
return $customFieldDelete ? civicrm_api3_create_error('Error while deleting custom field') : civicrm_api3_create_success();
}
* @param array $params
*
* @return array
- * Array of newly created option_value property values.
*/
function civicrm_api3_custom_search_create($params) {
require_once 'api/v3/OptionValue.php';
if ($result['is_error']) {
throw new Exception($result['error_message']);
}
- return civicrm_api3_create_success(TRUE, $params);
+ return civicrm_api3_create_success(TRUE, $params, 'CustomValue');
}
/**
if ($result['is_error']) {
if ($result['error_message'] == "No values found for the specified entity ID and custom field(s).") {
$values = array();
- return civicrm_api3_create_success($values, $params);
+ return civicrm_api3_create_success($values, $params, 'CustomValue');
}
else {
throw new API_Exception($result['error_message']);
$values[$id]['id'] = $id;
$values[$id][$n] = $value;
}
- return civicrm_api3_create_success($values, $params);
+ return civicrm_api3_create_success($values, $params, 'CustomValue');
}
}
*/
function civicrm_api3_dashboard_get($params) {
$bao = new CRM_Core_BAO_Dashboard();
- _civicrm_api3_dao_set_filter($bao, $params, TRUE, 'Dashboard');
+ _civicrm_api3_dao_set_filter($bao, $params, TRUE);
$dashlets = _civicrm_api3_dao_to_array($bao, $params, TRUE, 'Dashboard');
- return civicrm_api3_create_success($dashlets, $params, 'dashboard', 'get', $bao);
+ return civicrm_api3_create_success($dashlets, $params, 'Dashboard', 'get', $bao);
}
/**
*/
function civicrm_api3_dashboard_delete($params) {
if (CRM_Core_BAO_Dashboard::deleteDashlet($params['id'])) {
- return civicrm_api3_create_success(1, $params, 'dashboard', 'delete');
+ return civicrm_api3_create_success(1, $params, 'Dashboard', 'delete');
}
else {
return civicrm_api3_create_error('Could not delete dashlet');
*/
/**
- * This api exposes CiviCRM domain.
+ * This api exposes CiviCRM Domain configuration settings.
*
* @package CiviCRM_APIv3
*/
/**
- * Get CiviCRM domain details.
+ * Get CiviCRM Domain details.
*
* @param array $params
*
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
- _civicrm_api3_dao_set_filter($bao, $params, TRUE, 'domain');
- $domains = _civicrm_api3_dao_to_array($bao, $params, TRUE, 'domain');
+ _civicrm_api3_dao_set_filter($bao, $params, TRUE);
+ $domains = _civicrm_api3_dao_to_array($bao, $params, TRUE, 'Domain');
foreach ($domains as $domain) {
if (!empty($domain['contact_id'])) {
}
}
- return civicrm_api3_create_success($domains, $params, 'domain', 'get', $bao);
+ return civicrm_api3_create_success($domains, $params, 'Domain', 'get', $bao);
}
/**
}
/**
- * Create a new domain.
+ * Create a new Domain.
*
* @param array $params
*
*/
/**
- * This api exposes CiviCRM email.
+ * This api exposes CiviCRM email records.
*
* @package CiviCRM_APIv3
*/
* api result array
*/
function civicrm_api3_email_get($params) {
-
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
* Get list of deprecated entities.
*
+ * This is called by the api wrapper when returning the result of api.Entity.get.
+ *
* @param array $entities
*
* @return array
*/
/**
- * This api exposes CiviCRM entity tag.
+ * This api exposes CiviCRM EntityTag records.
+ *
+ * Use this api to add/remove tags from a contact/activity/etc.
+ * To create/update/delete the tags themselves, use the Tag api.
*
* @package CiviCRM_APIv3
*/
-/**
- * Include utility functions
- */
-
/**
* Get entity tags.
*
foreach ($values as $v) {
$result[$v] = array('tag_id' => $v);
}
- return civicrm_api3_create_success($result, $params);
+ return civicrm_api3_create_success($result, $params, 'EntityTag');
}
}
/**
*
- * This api exposes CiviCRM event.
+ * This api exposes CiviCRM Event.
*
* @package CiviCRM_APIv3
*/
}
$eventDAO = new CRM_Event_BAO_Event();
- _civicrm_api3_dao_set_filter($eventDAO, $params, TRUE, 'Event');
+ _civicrm_api3_dao_set_filter($eventDAO, $params, TRUE);
if (!empty($params['isCurrent'])) {
$eventDAO->whereAdd('(start_date >= CURDATE() || end_date >= CURDATE())');
}
}
- return civicrm_api3_create_success($event, $params, 'event', 'get', $eventDAO);
+ return civicrm_api3_create_success($event, $params, 'Event', 'get', $eventDAO);
}
/**
}
/**
- * Delete an existing event.
+ * Delete an existing Event.
*
- * This API is used for deleting a event.
+ * This API is used for deleting a event given its id.
*
* @param array $params
*
/**
- * This api exposes CiviCRM extension.
+ * This provides an api interface for CiviCRM extension management.
*
* @package CiviCRM_APIv3
*/
*
* @param array $params
* Input parameters.
- * - key: string, eg "com.example.myextension"
- * - keys: mixed; array of string, eg array("com.example.myextension1", "com.example.myextension2") or string with comma-delimited list
- * using 'keys' should be more performant than making multiple API calls with 'key'
+ * - key: string, eg "com.example.myextension"
+ * - keys: mixed; array of string, eg array("com.example.myextension1", "com.example.myextension2") or string with comma-delimited list
+ * using 'keys' should be more performant than making multiple API calls with 'key'
*
* @return array
* API result
*
* @param array $params
* Input parameters.
- * - key: string, eg "com.example.myextension"
- * - url: string eg "http://repo.com/myextension-1.0.zip"
+ * - key: string, eg "com.example.myextension"
+ * - url: string eg "http://repo.com/myextension-1.0.zip"
*
* @throws API_Exception
* @return array
*
* @param array $params
* Input parameters.
- * - local: bool, whether to rescan local filesystem (default: TRUE)
- * - remote: bool, whether to rescan remote repository (default: TRUE)
+ * - local: bool, whether to rescan local filesystem (default: TRUE)
+ * - remote: bool, whether to rescan remote repository (default: TRUE)
*
* @return array
* API result
* Array per getfields metadata.
*
* @return array
- * Array of newly created file property values.
*/
function civicrm_api3_file_create($params) {
$file = array();
_civicrm_api3_object_to_array($fileDAO, $file);
- return civicrm_api3_create_success($file, $params, 'file', 'create', $fileDAO);
+ return civicrm_api3_create_success($file, $params, 'File', 'create', $fileDAO);
}
/**
- * Get a file.
+ * Get a File.
*
* @param array $params
* Array per getfields metadata.
}
/**
- * Update an existing file.
+ * Update an existing File.
*
* @param array $params
* Array per getfields metadata.
}
/**
- * Delete an existing file.
+ * Delete an existing File.
*
* @param array $params
* Array per getfields metadata.
*/
/**
- * This api exposes CiviCRM financial_account.
+ * This api exposes CiviCRM FinancialAccount.
*
* @package CiviCRM_APIv3
*/
/**
- * Save a financial_account.
+ * Save a FinancialAccount.
*
* @param array $params
*
* @return array
- * Array of newly created financial_account property values.
*/
function civicrm_api3_financial_account_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
- * Get a financial_account.
+ * Get a FinancialAccount.
*
* @param array $params
*
* @return array
- * Array of retrieved financial_account property values.
+ * Array of retrieved FinancialAccount property values.
*/
function civicrm_api3_financial_account_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
- * Delete a financial_account.
+ * Delete a FinancialAccount.
*
* @param array $params
*
*/
/**
- * This api exposes CiviCRM financial_type.
+ * This api exposes CiviCRM FinancialType.
*
* @package CiviCRM_APIv3
*/
/**
- * Save a financial_type.
+ * Save a FinancialType.
*
* @param array $params
*
* @return array
- * Array of newly created financial_type property values.
*/
function civicrm_api3_financial_type_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
- * Get a financial_type.
+ * Get a FinancialType.
*
* @param array $params
*
* @return array
- * Array of retrieved financial_type property values.
+ * Array of retrieved FinancialType property values.
*/
function civicrm_api3_financial_type_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
- * Delete a financial_type.
+ * Delete a FinancialType.
*
* @param array $params
*
*/
/**
- * This api exposes CiviCRM grant records.
+ * This api exposes CiviCRM Grant records.
*
* @note Grant component must be enabled.
*
*/
/**
- * Create/update grant.
+ * Create/update Grant.
*
* @param array $params
* Array per getfields metadata.
*
* @return array
- * grant array
*/
function civicrm_api3_grant_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Grant');
}
/**
- * This method is used to delete an existing grant.
+ * This method is used to delete an existing Grant.
*
* @param array $params
- * Id of the grant to be deleted is required.
+ * Id of the Grant to be deleted is required.
*
* @return array
* API Result Array
*/
/**
- * This api exposes CiviCRM groups.
+ * This api exposes CiviCRM Groups.
*
* This api is for creating/deleting groups or fetching a list of existing groups.
- * To add/remove contacts to a group, use the groupContact api instead.
+ * To add/remove contacts to a group, use the GroupContact api instead.
*
* @package CiviCRM_APIv3
*/
* Create/update group.
*
* @param array $params
- * name/value pairs to insert in new 'group'
+ * name/value pairs to insert in new 'Group'
*
* @return array
* API result array
}
/**
- * Returns array of groups matching a set of one or more group properties.
+ * Returns array of groups matching a set of one or more Group properties.
*
* @param array $params
* Array of properties. If empty, all records will be returned.
* Array of matching groups
*/
function civicrm_api3_group_get($params) {
- $options = _civicrm_api3_get_options_from_params($params, TRUE, 'group', 'get');
+ $options = _civicrm_api3_get_options_from_params($params, TRUE, 'Group', 'get');
if (empty($options['return']) || !in_array('member_count', $options['return'])) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Group');
}
foreach ($groups as $id => $group) {
$groups[$id]['member_count'] = CRM_Contact_BAO_Group::memberCount($id);
}
- return civicrm_api3_create_success($groups, $params, 'group', 'get');
+ return civicrm_api3_create_success($groups, $params, 'Group', 'get');
}
/**
- * Delete an existing group.
+ * Delete an existing Group.
*
* @param array $params
* [id]
*/
/**
- * This api exposes CiviCRM group contacts.
+ * This api exposes CiviCRM GroupContact records.
*
* This api is for adding/removing contacts from a group,
* or fetching a list of groups for a contact.
*
* Important note: This api does not fetch smart groups for a contact.
- * To fetch all contacts in a smart group, use the contact api
+ * To fetch all contacts in a smart group, use the Contact api
* passing a contact_id and group_id.
*
* To create/delete groups, use the group api instead.
* @package CiviCRM_APIv3
*/
-
/**
- * This API will give list of the groups for particular contact.
+ * Fetch a list of groups for a contact, or contacts for a group.
*
- * Particular status can be sent in params array.
+ * @Note: this only applies to static groups, not smart groups.
+ * To fetch all contacts in a smart group, use the Contact api
+ * passing a contact_id and group_id.
*
* If no status mentioned in params, by default 'added' will be used
* to fetch the records
$groupId = CRM_Utils_Array::value('group_id', $params);
$values = &CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], $status, NULL, FALSE, TRUE, FALSE, TRUE, $groupId);
- return civicrm_api3_create_success($values, $params);
+ return civicrm_api3_create_success($values, $params, 'GroupContact');
}
/**
$extraReturnValues['not_removed'] += $nr;
}
}
- $dao = NULL;// can't pass this by reference
- return civicrm_api3_create_success(1, $params, 'group_contact', 'create', $dao, $extraReturnValues);
+ // can't pass this by reference
+ $dao = NULL;
+ return civicrm_api3_create_success(1, $params, 'GroupContact', 'create', $dao, $extraReturnValues);
}
/**
*/
/**
- * This api exposes CiviCRM group nesting.
+ * This api exposes CiviCRM GroupNesting.
*
* This defines parent/child relationships between nested groups.
*
* list of group nesting records
*/
function civicrm_api3_group_nesting_get($params) {
-
return _civicrm_api3_basic_get('CRM_Contact_DAO_GroupNesting', $params);
}
* @todo Work out the return value.
*/
function civicrm_api3_group_nesting_create($params) {
-
CRM_Contact_BAO_GroupNesting::add($params['parent_group_id'], $params['child_group_id']);
// FIXME: CRM_Contact_BAO_GroupNesting requires some work
$result = array('is_error' => 0);
- return civicrm_api3_create_success($result, $params);
+ return civicrm_api3_create_success($result, $params, 'GroupNesting');
}
/**
* @todo Work out the return value.
*/
function civicrm_api3_group_nesting_delete($params) {
-
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
}
_civicrm_api3_object_to_array($groupOrgBAO, $values);
- return civicrm_api3_create_success($values, $params, 'group_organization', 'get', $groupOrgBAO);
+ return civicrm_api3_create_success($values, $params, 'GroupOrganization', 'get', $groupOrgBAO);
}
/**
*/
/**
- * This api exposes CiviCRM IM.
+ * This api exposes CiviCRM IM records.
*
* @package CiviCRM_APIv3
*/
* @param array $params
*
* @return array
- * Array of newly created IM property values.
*/
function civicrm_api3_im_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
*/
/**
- * This api is used for triggering scheduled "cron" jobs.
+ * This api is used for working with scheduled "cron" jobs.
*
* @package CiviCRM_APIv3
*/
$facility->execute(FALSE);
// Always creates success - results are handled elsewhere.
- return civicrm_api3_create_success(1, $params);
+ return civicrm_api3_create_success(1, $params, 'Job');
}
/**
}
else {
$values = array();
- return civicrm_api3_create_success($values, $params, 'mailing', 'process');
+ return civicrm_api3_create_success($values, $params, 'Job', 'process_mailing');
}
}
}
else {
$values = array();
- return civicrm_api3_create_success($values, $params, 'mailing', 'process');
+ return civicrm_api3_create_success($values, $params, 'Job', 'process_sms');
}
}
// FIXME: processBounces doesn't return true/false on success/failure
$values = array();
- return civicrm_api3_create_success($values, $params, 'mailing', 'bounces');
+ return civicrm_api3_create_success($values, $params, 'Job', 'fetch_bounces');
}
/**
CRM_Utils_Mail_EmailProcessor::processActivities();
$values = array();
$lock->release();
- return civicrm_api3_create_success($values, $params, 'mailing', 'activities');
+ return civicrm_api3_create_success($values, $params, 'Job', 'fetch_activities');
}
catch (Exception $e) {
$lock->release();
$lock->release();
if ($result['is_error'] == 0) {
- return civicrm_api3_create_success($result['messages'], $params);
+ return civicrm_api3_create_success($result['messages'], $params, 'Job', 'process_membership');
}
else {
return civicrm_api3_create_error($result['messages']);
if (!$result) {
throw new API_Exception('Failed to disable all expired relationships.');
}
- return civicrm_api3_create_success(1, $params);
+ return civicrm_api3_create_success(1, $params, 'Job', 'disable_expired_relationships');
}
/**
/**
- * This api exposes CiviCRM line item.
+ * This api exposes CiviCRM LineItem records.
+ *
+ * Line items are sub-components of a complete financial transaction record.
*
* @package CiviCRM_APIv3
*/
}
/**
- * Delete an existing line_item.
+ * Delete an existing LineItem.
*
- * This method is used to delete any existing line_item. id of the group
- * to be deleted is required field in $params array
+ * This method is used to delete any existing LineItem given its id.
*
* @param array $params
* Array containing id of the group to be deleted.
/**
- * This api exposes CiviCRM loc_block.
+ * This api exposes CiviCRM LocBlock records.
*
* @package CiviCRM_APIv3
*/
/**
- * Create or update a loc_block.
+ * Create or update a LocBlock.
*
* @param array $params
- * name/value pairs to insert in new 'loc_block'
+ * name/value pairs to insert in new 'LocBlock'
*
* @return array
* API result array.
if (!empty($dao->id)) {
$values = array($dao->id => $entities);
_civicrm_api3_object_to_array($dao, $values[$dao->id]);
- return civicrm_api3_create_success($values, $params, 'loc_block', 'create', $dao);
+ return civicrm_api3_create_success($values, $params, 'LocBlock', 'create', $dao);
}
return civicrm_api3_create_error('Unable to create LocBlock. Please check your params.');
}
}
$values[$val['id']] = $val;
}
- return civicrm_api3_create_success($values, $params, 'loc_block', 'get');
+ return civicrm_api3_create_success($values, $params, 'LocBlock', 'get');
}
return _civicrm_api3_basic_get('CRM_Core_DAO_LocBlock', $params);
}
/**
- * Delete an existing loc_block.
+ * Delete an existing LocBlock.
*
* @param array $params
* Array containing id of the record to be deleted.
*/
/**
- * This api exposes CiviCRM location type.
+ * This api exposes CiviCRM LocationType records.
*
* @package CiviCRM_APIv3
*/
/**
- * Add a Location Type.
+ * Add a LocationType.
*
* @param array $params
*
}
/**
- * Deletes an existing Location Type.
+ * Deletes an existing LocationType.
*
* @param array $params
*
}
/**
- * Retrieve one or more Location Types.
+ * Retrieve one or more LocationTypes.
*
* @param array $params
* An associative array of name/value pairs.
*/
/**
- * Create or update a mail_settings.
+ * Create or update a MailSettings.
*
* @param array $params
- * name/value pairs to insert in new 'mail_settings'
+ * name/value pairs to insert in new 'MailSettings'
*
* @return array
* API result array.
* Array of parameters determined by getfields.
*/
function _civicrm_api3_mail_settings_create_spec(&$params) {
-
}
/**
- * Returns array of mail_settings matching a set of one or more group properties.
+ * Returns array of MailSettings matching a set of one or more properties.
*
* @param array $params
* Array of one or more property_name=>value pairs.
- * If $params is set as null, all mail_settings will be returned
+ * If $params is set as null, all MailSettings will be returned.
*
* @return array
* API result array.
}
/**
- * Delete an existing mail_settings.
+ * Delete an existing MailSettings.
*
* @param array $params
* [id]
return civicrm_api3_create_success($params);
}
else {
- throw new API_Exception(ts('Queue event could not be found'), 'no_queue_event
- ');
+ throw new API_Exception(ts('Queue event could not be found'), 'no_queue_event');
}
}
* @return array
*/
function civicrm_api3_mailing_event_confirm($params) {
- return civicrm_api('mailing_event_confirm', 'create', $params);
+ return civicrm_api('MailingEventConfirm', 'create', $params);
}
/**
*/
/**
- * This api exposes CiviCRM mailing_component.
+ * This api exposes CiviCRM MailingComponent.
*
* @package CiviCRM_APIv3
*/
/**
- * Save a mailing_component.
+ * Save a MailingComponent.
*
* @param array $params
*
}
/**
- * Get a mailing_component.
+ * Get a MailingComponent.
*
* @param array $params
*
}
/**
- * Delete a mailing_component.
+ * Delete a MailingComponent.
*
* @param array $params
*
function civicrm_api3_mailing_contact_get($params) {
return civicrm_api3_create_success(_civicrm_api3_mailing_contact_getresults($params, FALSE));
}
+
/**
* This is a wrapper for the functions that return the results from the 'quasi-entity' mailing contact.
*
*/
/**
- * Handle a confirm event.
+ * Handle a queue event.
*
* @param array $params
* Array of property.
* to indicate this entire api entity is deprecated
*/
function _civicrm_api3_mailing_group_deprecation() {
- return 'The mailing_group api is deprecated. Use the mailing_event apis instead.';
+ return 'The MailingGroup api is deprecated. Use the mailing_event apis instead.';
}
/**
unset($field['pseudoconstant']);
}
- return civicrm_api3_create_success($fields, $params, 'mailing_group', 'getfields');
+ return civicrm_api3_create_success($fields, $params, 'MailingGroup', 'getfields');
}
*/
/**
- * Handle creation of a Mailing Job for a Mailing.
+ * Handle creation of a MailingJob for a Mailing.
*
* @param array $params
*
*/
/**
- * APIv3 functions for registering/processing mailing recipients.
+ * API for retrieving mailing recipients.
*
* @package CiviCRM_APIv3
*/
/**
- * Returns array of Mailing Recipients.
+ * Returns array of MailingRecipients.
*
* @param array $params
* Array per getfields metadata.
/**
*
- * This api exposes CiviCRM membership contact.
+ * This api exposes CiviCRM membership contact records.
*
* @package CiviCRM_APIv3
*/
/**
- * Deletes an existing contact membership.
+ * Deletes an existing contact Membership.
*
* @param array $params
* Array array holding id - Id of the contact membership to be deleted.
$membership = array();
_civicrm_api3_object_to_array($membershipBAO, $membership[$membershipBAO->id]);
- return civicrm_api3_create_success($membership, $params, 'membership', 'create', $membershipBAO);
+ return civicrm_api3_create_success($membership, $params, 'Membership', 'create', $membershipBAO);
}
}
/**
- * Get contact membership record.
+ * Get contact Membership record.
*
* This api will return the membership records for the contacts
* having membership based on the relationship with the direct members.
$params['status_id'] = array('IN' => CRM_Member_BAO_MembershipStatus::getMembershipStatusCurrent());
}
- $options = _civicrm_api3_get_options_from_params($params, TRUE, 'membership', 'get');
+ $options = _civicrm_api3_get_options_from_params($params, TRUE, 'Membership', 'get');
if ($options['is_count']) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
&& !array_key_exists('relationship_name', $return)
)
) {
- return civicrm_api3_create_success($membershipValues, $params, 'membership', 'get');
+ return civicrm_api3_create_success($membershipValues, $params, 'Membership', 'get');
}
$members = _civicrm_api3_membership_relationsship_get_customv2behaviour($params, $membershipValues, $contactID);
- return civicrm_api3_create_success($members, $params, 'membership', 'get');
+ return civicrm_api3_create_success($members, $params, 'Membership', 'get');
}
/**
*/
/**
- * This api exposes CiviCRM membership block.
+ * This api exposes CiviCRM MembershipBlock records.
*
* @package CiviCRM_APIv3
*/
/**
- * API to Create or update a Membership Block.
+ * API to Create or update a MembershipBlock.
*
* @param array $params
- * An associative array of name/value property values of civicrm_membership_block.
+ * An associative array of name/value property values of MembershipBlock.
*
* @return array
* newly created or updated membership block property values.
* Array of name/value property values of civicrm_membership_status.
*
* @return array
- * Array of newly created membership status property values.
*/
function civicrm_api3_membership_status_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @return array
*/
function civicrm_api3_note_delete($params) {
-
$result = new CRM_Core_BAO_Note();
return $result->del($params['id']) ? civicrm_api3_create_success() : civicrm_api3_create_error('Error while deleting Note');
}
* if error an array with an error id and error message
*/
function civicrm_api3_note_get($params) {
-
return _civicrm_api3_basic_get('CRM_Core_BAO_Note', $params);
}
* Nested associative array beginning with direct children of given note.
*/
function &civicrm_api3_note_tree_get($params) {
-
civicrm_api3_verify_mandatory($params, NULL, array('id'));
if (!is_numeric($params['id'])) {
/**
* This api exposes CiviCRM option groups.
- * Each group contains option values.
+ *
+ * OptionGroups are containers for option values.
*
* @package CiviCRM_APIv3
*/
/**
* Delete an existing Option Group.
*
- * This method is used to delete any existing Option Group. id of the group
- * to be deleted is required field in $params array
+ * This method is used to delete any existing OptionGroup given its id.
*
* @param array $params
* [id]
/**
* This api exposes CiviCRM option values.
+ *
* Values are grouped by "OptionGroup"
*
* @package CiviCRM_APIv3
*
* @throws API_Exception
* @return array
- * Array of newly created option_value property values.
*/
function civicrm_api3_option_value_create($params) {
$result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
_civicrm_api3_object_to_array($participantBAO, $participant[$participantBAO->id]);
- return civicrm_api3_create_success($participant, $params, 'participant', 'create', $participantBAO);
+ return civicrm_api3_create_success($participant, $params, 'Participant', 'create', $participantBAO);
}
/**
*/
function civicrm_api3_participant_get($params) {
$mode = CRM_Contact_BAO_Query::MODE_EVENT;
- $entity = 'participant';
- list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, $entity);
+ list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, 'Participant');
$participant = array();
while ($dao->fetch()) {
_civicrm_api3_custom_data_get($participant[$dao->participant_id], 'Participant', $dao->participant_id, NULL);
}
- return civicrm_api3_create_success($participant, $params, 'participant', 'get', $dao);
+ return civicrm_api3_create_success($participant, $params, 'Participant', 'get', $dao);
}
/**
* An associative array of name/value property values of civicrm_participant_payment.
*
* @return array
- * Array of newly created payment property values.
*/
function civicrm_api3_participant_payment_create($params) {
/**
* Delete an existing participant_status.
*
- * This method is used to delete any existing participant_status. id of the group
- * to be deleted is required field in $params array
+ * This method is used to delete any existing participant_status given its id.
*
* @param array $params
* [id]
* @param array $params
*
* @return array
- * Array of newly created PaymentProcessor property values.
*/
function civicrm_api3_payment_processor_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
_civicrm_api3_object_to_array($paymentProcessorType, $relType[$paymentProcessorType->id]);
- return civicrm_api3_create_success($relType, $params, 'payment_processor_type', 'create', $paymentProcessorType);
+ return civicrm_api3_create_success($relType, $params, 'PaymentProcessorType', 'create', $paymentProcessorType);
}
/**
if (!$result) {
return civicrm_api3_create_error('Could not delete payment processor type');
}
- return civicrm_api3_create_success($result, $params, 'payment_processor_type', 'delete', $payProcTypeBAO);
+ return civicrm_api3_create_success($result, $params, 'PaymentProcessorType', 'delete', $payProcTypeBAO);
}
*/
/**
- * This api exposes CiviCRM phone.
+ * This api exposes CiviCRM phone records.
*
* @package CiviCRM_APIv3
*/
* Array per getfields metadata.
*
* @return array
- * Array of newly created phone property values.
*/
function civicrm_api3_phone_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Phone');
if (CRM_Pledge_BAO_Pledge::deletePledge($params['id'])) {
return civicrm_api3_create_success(array(
'id' => $params['id'],
- ), $params, 'pledge', 'delete');
+ ), $params, 'Pledge', 'delete');
}
else {
return civicrm_api3_create_error('Could not delete pledge');
*/
function civicrm_api3_pledge_get($params) {
$mode = CRM_Contact_BAO_Query::MODE_PLEDGE;
- $entity = 'pledge';
- list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, $entity);
+ list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, 'Pledge');
$pledge = array();
while ($dao->fetch()) {
$pledge[$dao->pledge_id] = $query->store($dao);
}
- return civicrm_api3_create_success($pledge, $params, 'pledge', 'get', $dao);
+ return civicrm_api3_create_success($pledge, $params, 'Pledge', 'get', $dao);
}
/**
//update pledge status
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($dao->pledge_id);
- return civicrm_api3_create_success($result, $params, 'pledge_payment', 'create', $dao);
+ return civicrm_api3_create_success($result, $params, 'PledgePayment', 'create', $dao);
}
/**
function civicrm_api3_pledge_payment_delete($params) {
if (CRM_Pledge_BAO_PledgePayment::del($params['id'])) {
- return civicrm_api3_create_success(array('id' => $params['id']), $params, 'pledge_payment', 'delete');
+ return civicrm_api3_create_success(array('id' => $params['id']), $params, 'PledgePayment', 'delete');
}
else {
return civicrm_api3_create_error('Could not delete payment');
*/
/**
- * This api exposes CiviCRM premium.
+ * This api exposes CiviCRM premiums.
+ *
+ * Premiums are used as incentive gifts on contribution pages.
+ * Premiums contain "Products" which has a separate api.
+ * Use chaining to create a premium and related products in one api call.
*
* @package CiviCRM_APIv3
*/
*
* @throws API_Exception
* @return array
- * Array of newly created premium property values.
*/
function civicrm_api3_premium_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
/**
* This api exposes CiviCRM price set fields.
*
+ * PriceSets contain PriceFields, which may contain PriceFieldValues.
+ * Each has its own api.
+ * Use chaining to create a PriceSet and associated PriceFields and values in one api call.
+ *
* @package CiviCRM_APIv3
*/
/**
* Delete an existing price_field.
*
- * This method is used to delete any existing price_field. id of the group
- * to be deleted is required field in $params array
+ * This method is used to delete any existing price_field given its id.
*
* @param array $params
* Array containing id of the group to be deleted.
/**
- * This api exposes CiviCRM price sets.
+ * This api exposes CiviCRM price field values.
+ *
+ * PriceFields may contain zero or more PriceFieldValues.
+ * Use chaining to create PriceFields and values in one api call.
*
* @package CiviCRM_APIv3
*/
/**
- * Create or update a price_field_value.
+ * Create or update a PriceFieldValue.
*
* @param array $params
- * name/value pairs to insert in new 'price_field_value'
+ * name/value pairs to insert in new 'PriceFieldValue'
*
* @return array
* API result array.
$values = array();
_civicrm_api3_object_to_array($bao, $values[$bao->id]);
- return civicrm_api3_create_success($values, $params, 'price_field_value', 'create', $bao);
+ return civicrm_api3_create_success($values, $params, 'PriceFieldValue', 'create', $bao);
}
}
/**
- * Returns array of price_field_values matching a set of one or more group properties.
+ * Returns array of PriceFieldValues matching a set of one or more group properties.
*
* @param array $params
* Array of one or more valid property_name=>value pairs. If $params is set.
}
/**
- * Delete an existing price_field_value.
+ * Delete an existing PriceFieldValue.
*
- * This method is used to delete any existing price_field_value. id of the group
- * to be deleted is required field in $params array
+ * This method is used to delete any existing PriceFieldValue given its id.
*
* @param array $params
* Array containing id of the group to be deleted.
/**
- * This api exposes CiviCRM price sets.
+ * This api exposes CiviCRM Price Sets.
+ *
+ * PriceSets contain PriceFields (which have their own api).
+ * Use chaining to create a PriceSet and associated PriceFields in one api call.
*
* @package CiviCRM_APIv3
*/
/**
- * Create or update a price_set.
+ * Create or update a PriceSet.
*
* @param array $params
- * name/value pairs to insert in new 'price_set'
+ * name/value pairs to insert in new 'PriceSet'
*
* @return array
* api result array
}
/**
- * Delete an existing price_set.
+ * Delete an existing PriceSet.
*
- * This method is used to delete any existing price_set. id of the group
- * to be deleted is required field in $params array
+ * This method is used to delete any existing PriceSet given its id.
*
* @param array $params
* Array containing id of the group to be deleted.
*/
/**
- * This api exposes CiviCRM print_label.
+ * This api exposes CiviCRM PrintLabel.
*
* @package CiviCRM_APIv3
*/
/**
- * Save a print_label.
+ * Save a PrintLabel.
*
* @param array $params
*
* @return array
- * Array of newly created print_label property values.
*/
function civicrm_api3_print_label_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
- * Get a print_label.
+ * Get a PrintLabel.
*
* @param array $params
*
* @return array
- * Array of retrieved print_label property values.
+ * Array of retrieved PrintLabel property values.
*/
function civicrm_api3_print_label_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
- * Delete a print_label.
+ * Delete a PrintLabel.
*
* @param array $params
*
*/
/**
- * This api exposes CiviCRM product.
+ * This api exposes CiviCRM premium products.
+ *
+ * Premiums are used as incentive gifts on contribution pages.
+ * Use chaining to create a premium and related products in one api call.
*
* @package CiviCRM_APIv3
*/
*
* @throws API_Exception
* @return array
- * Array of newly created product property values.
*/
function civicrm_api3_product_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
*/
/**
- * 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
*/
$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'));
}
/**
- * 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
}
/**
- * 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
* @todo add test cases
*/
function civicrm_api3_profile_apply($params) {
-
$profileFields = CRM_Core_BAO_UFGroup::getFields($params['profile_id'],
FALSE,
NULL,
_civicrm_api3_object_to_array($relationType, $relType[$relationType->id]);
- return civicrm_api3_create_success($relType, $params, 'relationship_type', 'create', $relationType);
+ return civicrm_api3_create_success($relType, $params, 'RelationshipType', 'create', $relationType);
}
/**
* @param array $params
*
* @return array
- * Array of newly created report instance property values.
*/
function civicrm_api3_report_instance_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
- * Array of newly created option_value property values.
*/
function civicrm_api3_report_template_create($params) {
require_once 'api/v3/OptionValue.php';
function civicrm_api3_report_template_getrows($params) {
civicrm_api3_verify_one_mandatory($params, NULL, array('report_id', 'instance_id'));
list($rows, $instance, $metadata) = _civicrm_api3_report_template_getrows($params);
- return civicrm_api3_create_success($rows, $params, 'report_template', 'getrows', CRM_Core_DAO::$_nullObject, $metadata);
+ return civicrm_api3_create_success($rows, $params, 'ReportTemplate', 'getrows', CRM_Core_DAO::$_nullObject, $metadata);
}
/**
$reportInstance->preProcess();
$reportInstance->setDefaultValues(FALSE);
$reportInstance->setParams(array_merge($reportInstance->getDefaultValues(), $params));
- $options = _civicrm_api3_get_options_from_params($params, TRUE, 'report_template', 'get');
+ $options = _civicrm_api3_get_options_from_params($params, TRUE, 'ReportTemplate', 'get');
$reportInstance->setLimitValue($options['limit']);
$reportInstance->setOffsetValue($options['offset']);
$reportInstance->beginPostProcessCommon();
function civicrm_api3_report_template_getstatistics($params) {
list($rows, $reportInstance, $metadata) = _civicrm_api3_report_template_getrows($params);
$stats = $reportInstance->statistics($rows);
- return civicrm_api3_create_success($stats, $params, 'report_template', 'getstatistics', CRM_Core_DAO::$_nullObject, $metadata);
+ return civicrm_api3_create_success($stats, $params, 'ReportTemplate', 'getstatistics', CRM_Core_DAO::$_nullObject, $metadata);
}
/**
* Adjust metadata for template getrows action.
'description' => 'Settings Group. This is required if the setting is not stored in config',
'type' => CRM_Utils_Type::T_STRING),
);
- return civicrm_api3_create_success($result, $params, 'setting', 'getfields');
+ return civicrm_api3_create_success($result, $params, 'Setting', 'getfields');
}
if (!empty($params['name'])) {
//am of two minds about special handling for 'name' as opposed to other filters - but is does make most common
$specFunction($result);
}
}
- return civicrm_api3_create_success($result, $params, 'setting', 'getfields');
+ return civicrm_api3_create_success($result, $params, 'Setting', 'getfields');
}
/**
* @throws \Exception
*/
function civicrm_api3_setting_getdefaults(&$params) {
- $settings = civicrm_api3('setting', 'getfields', $params);
+ $settings = civicrm_api3('Setting', 'getfields', $params);
$domains = _civicrm_api3_setting_getDomainArray($params);
$defaults = array();
foreach ($domains as $domainID) {
print_r($noDefaults);
}
}
- return civicrm_api3_create_success($defaults, $params, 'setting', 'getfields');
+ return civicrm_api3_create_success($defaults, $params, 'Setting', 'getfields');
}
/**
- * Metadata for setting create function.
+ * Metadata for Setting create function.
*
* @param array $params
* Parameters as passed to the API.
* @throws \Exception
*/
function civicrm_api3_setting_revert(&$params) {
- $defaults = civicrm_api('setting', 'getdefaults', $params);
- $fields = civicrm_api('setting', 'getfields', $params);
+ $defaults = civicrm_api('Setting', 'getdefaults', $params);
+ $fields = civicrm_api('Setting', 'getfields', $params);
$fields = $fields['values'];
$domains = _civicrm_api3_setting_getDomainArray($params);
$result = array();
$valuesToRevert['version'] = $params['version'];
$valuesToRevert['domain_id'] = $domainID;
// note that I haven't looked at how the result would appear with multiple domains in play
- $result = array_merge($result, civicrm_api('setting', 'create', $valuesToRevert));
+ $result = array_merge($result, civicrm_api('Setting', 'create', $valuesToRevert));
}
}
- return civicrm_api3_create_success($result, $params, 'setting', 'revert');
+ return civicrm_api3_create_success($result, $params, 'Setting', 'revert');
}
/**
* @throws \Exception
*/
function civicrm_api3_setting_fill(&$params) {
- $defaults = civicrm_api3('setting', 'getdefaults', $params);
+ $defaults = civicrm_api3('Setting', 'getdefaults', $params);
$domains = _civicrm_api3_setting_getDomainArray($params);
$result = array();
foreach ($domains as $domainID) {
'version' => $params['version'],
'domain_id' => $domainID,
);
- $existing = civicrm_api3('setting', 'get', $apiArray);
+ $existing = civicrm_api3('Setting', 'get', $apiArray);
$valuesToFill = array_diff_key($defaults['values'][$domainID], $existing['values'][$domainID]);
if (!empty($valuesToFill)) {
- $result = array_merge($result, civicrm_api('setting', 'create', $valuesToFill + $apiArray));
+ $result = array_merge($result, civicrm_api('Setting', 'create', $valuesToFill + $apiArray));
}
}
- return civicrm_api3_create_success($result, $params, 'setting', 'fill');
+ return civicrm_api3_create_success($result, $params, 'Setting', 'fill');
}
/**
function civicrm_api3_setting_create($params) {
$domains = _civicrm_api3_setting_getDomainArray($params);
$result = CRM_Core_BAO_Setting::setItems($params, $domains);
- return civicrm_api3_create_success($result, $params, 'setting', 'create');
+ return civicrm_api3_create_success($result, $params, 'Setting', 'create');
}
/**
function civicrm_api3_setting_get($params) {
$domains = _civicrm_api3_setting_getDomainArray($params);
$result = $result = CRM_Core_BAO_Setting::getItems($params, $domains, CRM_Utils_Array::value('return', $params, array()));
- return civicrm_api3_create_success($result, $params, 'setting', 'get');
+ return civicrm_api3_create_success($result, $params, 'Setting', 'get');
}
/**
* Metadata for setting create function.
* @param array $params
*
* @return array
- * Array of newly created sms_provider property values.
*/
function civicrm_api3_sms_provider_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
/**
* Delete an existing survey.
*
- * This method is used to delete any existing survey. id of the group
- * to be deleted is required field in $params array
+ * This method is used to delete any existing survey given its id.
*
* @param array $params
* [id]
*
* @deprecated api notice
* @return string
- * to indicate this entire api entity is deprecated
+ * String output indicates this entire api entity as deprecated
*/
function _civicrm_api3_survey_respondant_deprecation() {
- return 'The survey_respondant api is not currently supported.';
+ return 'The SurveyRespondant api is not currently supported.';
}
/**
$ufJoin = CRM_Core_BAO_UFJoin::create($params);
_civicrm_api3_object_to_array($ufJoin, $ufJoinArray[]);
- return civicrm_api3_create_success($ufJoinArray, $params, 'uf_join', 'create');
+ return civicrm_api3_create_success($ufJoinArray, $params, 'UFJoin', 'create');
}
/**
$websiteBAO = CRM_Core_BAO_Website::add($params);
$values = array();
_civicrm_api3_object_to_array($websiteBAO, $values[$websiteBAO->id]);
- return civicrm_api3_create_success($values, $params, 'website', 'get');
+ return civicrm_api3_create_success($values, $params, 'Website', 'get');
}
/**
if ($websiteDAO->find()) {
while ($websiteDAO->fetch()) {
$websiteDAO->delete();
- return civicrm_api3_create_success(1, $params, 'website', 'delete');
+ return civicrm_api3_create_success(1, $params, 'Website', 'delete');
}
}
else {
- throw new API_Exception('Could not delete website with id ' . $websiteID);
+ throw new API_Exception('Could not delete Website with id ' . $websiteID);
}
}
* details of found websites
*/
function civicrm_api3_website_get($params) {
- return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'website');
+ return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Website');
}
*/
/**
- * This api exposes CiviCRM word replacement.
+ * This api exposes CiviCRM WordReplacement records.
*
- * Word-replacements are used to globally alter strings in the CiviCRM UI.
+ * Word replacements are used to globally alter strings in the CiviCRM UI.
* Note that the original source string is always English, regardless of language settings.
*
* @package CiviCRM_APIv3
*/
function civicrm_api3_word_replacement_get($params) {
$bao = new CRM_Core_BAO_WordReplacement();
- _civicrm_api3_dao_set_filter($bao, $params, TRUE, 'WordReplacement');
+ _civicrm_api3_dao_set_filter($bao, $params, TRUE);
$wordReplacements = _civicrm_api3_dao_to_array($bao, $params, TRUE, 'WordReplacement');
- return civicrm_api3_create_success($wordReplacements, $params, 'word_replacement', 'get', $bao);
+ return civicrm_api3_create_success($wordReplacements, $params, 'WordReplacement', 'get', $bao);
}
}
/**
- * Delete an existing word_replacement.
+ * Delete an existing WordReplacement.
*
* @param array $params
- * Array containing id of the word_replacement to be deleted.
+ * Array containing id of the WordReplacement to be deleted.
*
* @return array
* API result array
* @return array
*/
function _civicrm_api3_get_using_query_object($entity, $params, $additional_options = array(), $getCount = NULL) {
-
+ $lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity);
// Convert id to e.g. contact_id
- if (empty($params[$entity . '_id']) && isset($params['id'])) {
- $params[$entity . '_id'] = $params['id'];
+ if (empty($params[$lowercase_entity . '_id']) && isset($params['id'])) {
+ $params[$lowercase_entity . '_id'] = $params['id'];
}
unset($params['id']);
// we will filter query object against getfields
$fields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => 'get'));
// we need to add this in as earlier in this function 'id' was unset in favour of $entity_id
- $fields['values'][$entity . '_id'] = array();
+ $fields['values'][$lowercase_entity . '_id'] = array();
$varsToFilter = array('returnProperties', 'inputParams');
foreach ($varsToFilter as $varToFilter) {
if (!is_array($$varToFilter)) {
}
if (substr($sort, 0, 2) == 'id') {
- $sort = $entity . "_" . $sort;
+ $sort = $lowercase_entity . "_" . $sort;
}
$newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams);
* @param CRM_Core_DAO $dao
* @param array $params
* @param bool $unique
- * @param string $entity
*
* @throws API_Exception
* @throws Exception
*/
-function _civicrm_api3_dao_set_filter(&$dao, $params, $unique = TRUE, $entity) {
- $entity = substr($dao->__table, 8);
- if (!empty($params[$entity . "_id"]) && empty($params['id'])) {
+function _civicrm_api3_dao_set_filter(&$dao, $params, $unique = TRUE) {
+ $entity = _civicrm_api_get_entity_name_from_dao($dao);
+ $lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity);
+ if (!empty($params[$lowercase_entity . "_id"]) && empty($params['id'])) {
//if entity_id is set then treat it as ID (will be overridden by id if set)
- $params['id'] = $params[$entity . "_id"];
+ $params['id'] = $params[$lowercase_entity . "_id"];
}
$allfields = _civicrm_api3_build_fields_array($dao, $unique);
$fields = array_intersect(array_keys($allfields), array_keys($params));
*
* @param array $params
* Associative array of property name/value.
- * pairs to insert in new history.
+ * pairs to insert in new history.
* @param string $daoName
* @param bool $return
*
*/
function _civicrm_api3_basic_get($bao_name, &$params, $returnAsSuccess = TRUE, $entity = "") {
$bao = new $bao_name();
- _civicrm_api3_dao_set_filter($bao, $params, TRUE, $entity);
+ _civicrm_api3_dao_set_filter($bao, $params, TRUE);
if ($returnAsSuccess) {
return civicrm_api3_create_success(_civicrm_api3_dao_to_array($bao, $params, FALSE, $entity), $params, $entity, 'get');
}
function _civicrm_api3_basic_create($bao_name, &$params, $entity = NULL) {
_civicrm_api3_format_params_for_create($params, $entity);
$args = array(&$params);
- if (!empty($entity)) {
+ if ($entity) {
$ids = array($entity => CRM_Utils_Array::value('id', $params));
$args[] = &$ids;
}