<?php
/**
+ * @file
* File for the CiviCRM APIv3 API wrapper
*
* @package CiviCRM_APIv3
<?php
/**
- * File for the CiviCRM APIv3 API wrapper
+ * @file
+ * File for the CiviCRM APIv3 API wrapper.
*
* @package CiviCRM_APIv3
* @subpackage API
* @subpackage API_ActionSchedule
*
* @copyright CiviCRM LLC (c) 2004-2014
- *
*/
/**
- * Get CiviCRM Action Schedule details
- * {@getfields action_schedule_create}
+ * Get CiviCRM Action Schedule details.
+ *
* @param array $params
+ *
* @return array
*/
function civicrm_api3_action_schedule_get($params) {
* @subpackage API_Activity
* @copyright CiviCRM LLC (c) 2004-2014
* @version $Id: Activity.php 30486 2010-11-02 16:12:09Z shot $
- *
*/
/**
- * Creates or updates an Activity. See the example for usage
+ * Creates or updates an Activity.
*
* @param array $params
- * Associative array of property name/value.
- * pairs for the activity.
- * {@getfields activity_create}
+ * Array per getfields documentation.
*
* @throws API_Exception
* @return array
- * Array containing 'is_error' to denote success or failure and details of the created activity
- *
- * @example ActivityCreate.php Standard create example
- * @example Activity/ContactRefCustomField.php Create example including setting a contact reference custom field
- * {@example ActivityCreate.php 0}
+ * Array containing 'is_error' to denote success or failure and details of the created activity.
*/
function civicrm_api3_activity_create($params) {
}
/**
- * Specify Meta data for create. Note that this data is retrievable via the getfields function
- * and is used for pre-filling defaults and ensuring mandatory requirements are met.
+ * Specify Meta data for create.
+ *
+ * Note that this data is retrievable via the getfields function and is used for pre-filling defaults and
+ * ensuring mandatory requirements are met.
+ *
* @param array $params
- * (reference) array of parameters determined by getfields.
+ * Array of parameters determined by getfields.
*/
function _civicrm_api3_activity_create_spec(&$params) {
- //default for source_contact_id = currently logged in user
+ // Default for source_contact_id = currently logged in user.
$params['source_contact_id']['api.default'] = 'user_contact_id';
$params['status_id']['api.aliases'] = array('activity_status');
}
/**
- * Gets a CiviCRM activity according to parameters
+ * Gets a CiviCRM activity according to parameters.
*
* @param array $params
- * Associative array of property name/value.
- * pairs for the activity.
+ * Array per getfields documentation.
*
* @return array
- *
- * {@getfields activity_get}
- * @example ActivityGet.php Basic example
- * @example Activity/DateTimeHigh.php Example get with date filtering
- * {@example ActivityGet.php 0}
*/
function civicrm_api3_activity_get($params) {
if (!empty($params['contact_id'])) {
$activities = CRM_Activity_BAO_Activity::getContactActivity($params['contact_id']);
- //BAO function doesn't actually return a contact ID - hack api for now & add to test so when api re-write happens it won't get missed
+ // BAO function doesn't actually return a contact ID - hack api for now & add to test so when api re-write
+ // happens it won't get missed.
foreach ($activities as $key => $activityArray) {
$activities[$key]['id'] = $key;
}
}
/**
- * Given a list of activities, append any extra data requested about the activities
+ * Given a list of activities, append any extra data requested about the activities.
*
* NOTE: Called by civicrm-core and CiviHR
*
* @param array $params
* API request parameters.
* @param array $activities
+ *
* @return array
* new activities list
*/
*
* @param array $params
* Array holding 'id' of activity to be deleted.
- * {@getfields activity_delete}
*
* @throws API_Exception
- * @return void|CRM_Core_Error An error if 'activityName or ID' is invalid,
- * permissions are insufficient, etc. or CiviCRM success array
- *
- *
- *
- * @example ActivityDelete.php Standard Delete Example
*
+ * @return array
*/
function civicrm_api3_activity_delete($params) {
}
/**
- * Check for required params
+ * Check for required params.
*
* @param array $params
* Associated array of fields.
FROM civicrm_contact
WHERE id IN (' . implode(', ', $contactIds) . ' )';
if (count($contactIds) != CRM_Core_DAO::singleValueQuery($sql)) {
- throw new API_Exception('Invalid ' . ' Contact Id');
+ throw new API_Exception('Invalid Contact Id');
}
}
}
/**
+ * Get parameters for activity list.
+ *
* @see _civicrm_api3_generic_getlist_params
*
* @param array $request
}
/**
+ * Get output for activity list.
+ *
* @see _civicrm_api3_generic_getlist_output
*
* @param array $result
*
* @package CiviCRM_APIv3
* @subpackage API_Batch
- *
*/
/**
- * Save a Batch
- *
- * Allowed @params array keys are:
- * {@getfields batch_create}
- * @example BatchCreate.php
+ * Save a Batch.
*
* @param array $params
*
}
/**
- * Internal function to format create params for processing
+ * Internal function to format create params for processing.
*
* @param array $params
*/
if (!$params['case_type_id']) {
$caseTypeLabels = CRM_Case_PseudoConstant::caseType('title', FALSE);
$params['case_type_id'] = array_search($params['case_type'], $caseTypeLabels);
- $params['case_type'] = $caseTypes[$params['case_type_id']]; // label => name
+ $params['case_type'] = $caseTypes[$params['case_type_id']];
}
}
elseif (empty($params['case_type'])) {
* @package CiviCRM_APIv3
* @subpackage API_Case
* @copyright CiviCRM LLC (c) 2004-2014
- *
*/
/**
}
/**
- * Retrieve one or more contacts, given a set of search params
+ * Retrieve one or more contacts, given a set of search params.
+ *
+ * @param array $params
*
* @return array
* API Result Array
}
/**
+ * Get count of contact.
+ *
* @param array $params
*
* @return int
<?php
/**
- * Retrieve a CustomSearches
+ * Retrieve custom searches.
*
* FIXME This is a bare-minimum placeholder
*
* @param array $params
*
- * {@example OptionValueGet.php 0}
- * @example OptionValueGet.php
- *
* @return array
* details of found Option Values
- * {@getfields OptionValue_get}
*/
function civicrm_api3_custom_search_get($params) {
require_once 'api/v3/OptionValue.php';
* @subpackage API_ActionSchedule
*
* @copyright CiviCRM LLC (c) 2004-2014
- *
*/
/**
- * Creates/Updates a new Dashboard Contact Entry
+ * Creates/Updates a new Dashboard Contact Entry.
*
* @param array $params
*
<?php
/**
+ * Get list of deprecated entities.
+ *
* @deprecated api notice
+ *
* @param array $entities
+ *
* @return array
* Array of deprecated api entities
*/
* @subpackage API_File
* @copyright CiviCRM LLC (c) 2004-2014
* $Id: $
- *
*/
/**
- * Create a file
+ * Create a file.
*
* This API is used for creating a file
*
<?php
/**
- * Get information about fields for a given api request. Getfields information
- * is used for documentation, validation, default setting
+ * Get information about fields for a given api request.
+ *
+ * Getfields information is used for documentation, validation, default setting
* We first query the scheme using the $dao->fields function & then augment
* that information by calling the _spec functions that apply to the relevant function
* Note that we use 'unique' field names as described in the xml/schema files
* API Result Array
*/
function civicrm_api3_job_execute($params) {
- // @noinspection PhpUnusedParameterInspection
$facility = new CRM_Core_JobManager();
$facility->execute(FALSE);
- // always creates success - results are handled elsewhere
- return civicrm_api3_create_success();
+ // Always creates success - results are handled elsewhere.
+ return civicrm_api3_create_success(1, $params);
}
/**
/**
- * This api checks and updates the status of all membership records for a given domain using the calc_membership_status and
- * update_contact_membership APIs.
+ * This api checks and updates the status of all membership records for a given domain.
+ *
+ * The function uses the calc_membership_status and update_contact_membership APIs.
*
* IMPORTANT:
* Sending renewal reminders has been migrated from this job to the Scheduled Reminders function as of 4.3.
$lock->release();
if ($result['is_error'] == 0) {
- return civicrm_api3_create_success($result['messages']);
+ return civicrm_api3_create_success($result['messages'], $params);
}
else {
return civicrm_api3_create_error($result['messages']);
*
* @return array
* API Result Array
- *
*/
function civicrm_api3_job_process_batch_merge($params) {
$rgid = CRM_Utils_Array::value('rgid', $params);
}
/**
+ * Metadata for batch merge function.
+ *
* @param $params
*/
function _civicrm_api3_job_process_batch_merge_spec(&$params) {
}
/**
- * Runs handlePaymentCron method in the specified payment processor
+ * Runs handlePaymentCron method in the specified payment processor.
*
* @param array $params
* Input parameters.
*
- * Expected @params array keys are:
+ * Expected @params array keys are: INCORRECTLY DOCUMENTED AND SHOULD BE IN THE _spec function
+ * for retrieval via getfields.
* {string 'processor_name' - the name of the payment processor, eg: Sagepay}
- *
*/
function civicrm_api3_job_run_payment_cron($params) {
}
/**
- * This api cleans up all the old session entries and temp tables. We recommend that sites run this on an hourly basis
+ * This api cleans up all the old session entries and temp tables.
+ *
+ * We recommend that sites run this on an hourly basis.
*
* @param array $params
* Sends in various config parameters to decide what needs to be cleaned.
/**
* Set expired relationships to disabled.
- * @param $params
+ *
+ * @param array $params
+ *
* @return array
* @throws \API_Exception
*/
function civicrm_api3_job_disable_expired_relationships($params) {
- /** @noinspection PhpUnusedParameterInspection */
$result = CRM_Contact_BAO_Relationship::disableExpiredRelationships();
if (!$result) {
throw new API_Exception('Failed to disable all expired relationships.');
}
- return civicrm_api3_create_success();
+ return civicrm_api3_create_success(1, $params);
}
/**
- * This api reloads all the smart groups. If the org has a large number of smart groups
- * it is recommended that they use the limit clause to limit the number of smart groups
- * evaluated on a per job basis. Might also help to increase the smartGroupCacheTimeout
- * and use the cache
+ * This api reloads all the smart groups.
+ *
+ * If the org has a large number of smart groups it is recommended that they use the limit clause
+ * to limit the number of smart groups evaluated on a per job basis.
+ *
+ * Might also help to increase the smartGroupCacheTimeout and use the cache.
*
* @param array $params
+ *
* @return array
* @throws \API_Exception
*/
<?php
/**
- * Functions to inform caller that Location is obsolete and Address, Phone, Email, Website should be used
+ * Function to inform caller that Location is obsolete and Address, Phone, Email, Website should be used.
+ *
* @param array $params
* @return array
*/
*
* @package CiviCRM_APIv3
* @subpackage API_mailing_component
- *
*/
/**
- * Save a mailing_component
- *
- * Allowed @params array keys are:
- * {@getfields mailing_component_create}
- * @example mailing_componentCreate.php
- *
+ * Save a mailing_component.
* @param array $params
*
* @throws API_Exception
*/
/**
+ * Create message template.
+ *
* @param array $params
+ *
* @return array
* @throws \API_Exception
*/
*
* @copyright CiviCRM LLC (c) 2004-2014
* @version $Id: Note.php 30879 2010-11-22 15:45:55Z shot $
- *
*/
/**
- * Create Note
+ * Create Note.
*
* This API is used for creating a note.
* Required parameters : entity_id AND note
<?php
/**
+ * Get option groups.
+ *
* @param array $params
*
* @return array
*/
/**
- * Add or update a plege payment. Pledge Payment API doesn't actually add a pledge
+ * Add or update a pledge payment. Pledge Payment API doesn't actually add a pledge
* if the request is to 'create' and 'id' is not passed in
* the oldest pledge with no associated contribution is updated
*
* @subpackage API_Settings
* @copyright CiviCRM LLC (c) 2004-2014
* @version $Id: Settings.php
+ */
+
+/**
+ * Get fields for setting api calls.
+ *
* @param array $params
+ *
* @return array
*/
function civicrm_api3_setting_getfields($params) {
*
* @copyright CiviCRM LLC (c) 2004-2014
* @version $Id: utils.php 30879 2010-11-22 15:45:55Z shot $
- *
*/
/**
- * Initialize CiviCRM - should be run at the start of each API function
+ * Initialize CiviCRM - should be run at the start of each API function.
*/
function _civicrm_api3_initialize() {
require_once 'CRM/Core/ClassLoader.php';
}
/**
- * Wrapper Function for civicrm_verify_mandatory to make it simple to pass either / or fields for checking
+ * Wrapper Function for civicrm_verify_mandatory to make it simple to pass either / or fields for checking.
*
* @param array $params
* Array of fields to check.
}
/**
- * check mandatory fields are included
+ * Check mandatory fields are included.
*
* @param array $params
* Array of fields to check.
}
/**
+ * Create error array.
*
- * @param $msg
+ * @param string $msg
* @param array $data
+ *
* @return array
*/
function civicrm_api3_create_error($msg, $data = array()) {
// we will show sql to privileged user only (not sure of a specific
// security hole here but seems sensible - perhaps should apply to the trace as well?)
if (isset($data['sql']) && CRM_Core_Permission::check('Administer CiviCRM')) {
- $data['debug_information'] = $data['sql']; // Isn't this redundant?
+ // Isn't this redundant?
+ $data['debug_information'] = $data['sql'];
}
else {
unset($data['sql']);
}
/**
- * Load the DAO of the entity
+ * Load the DAO of the entity.
+ *
* @param $entity
* @return bool
*/
}
/**
- * return the DAO of the function or Entity
+ * Return the DAO of the function or Entity.
+ *
* @param string $name
* Either a function of the api (civicrm_{entity}_create or the entity name.
* return the DAO name to manipulate this function
* eg. "civicrm_api3_contact_create" or "Contact" will return "CRM_Contact_BAO_Contact"
+ *
* @return mixed|string
*/
function _civicrm_api3_get_DAO($name) {
}
/**
- * return the DAO of the function or Entity
+ * Return the DAO of the function or Entity.
+ *
* @param string $name
* Is either a function of the api (civicrm_{entity}_create or the entity name.
* return the DAO name to manipulate this function
* eg. "civicrm_contact_create" or "Contact" will return "CRM_Contact_BAO_Contact"
+ *
* @return mixed
*/
function _civicrm_api3_get_BAO($name) {
}
/**
- * Recursive function to explode value-separated strings into arrays
+ * Recursive function to explode value-separated strings into arrays.
+ *
* @param $values
*/
function _civicrm_api3_separate_values(&$values) {
_civicrm_api3_separate_values($value);
}
elseif (is_string($value)) {
- if ($key == 'case_type_id') {// this is to honor the way case API was originally written
+ // This is to honor the way case API was originally written.
+ if ($key == 'case_type_id') {
$value = trim(str_replace($sp, ',', $value), ',');
}
elseif (strpos($value, $sp) !== FALSE) {
}
/**
- * This is a legacy wrapper for api_store_values which will check the suitable fields using getfields
- * rather than DAO->fields
+ * This is a legacy wrapper for api_store_values.
+ *
+ * It checks suitable fields using getfields rather than DAO->fields.
*
- * Getfields has handling for how to deal with uniquenames which dao->fields doesn't
+ * Getfields has handling for how to deal with unique names which dao->fields doesn't
*
* Note this is used by BAO type create functions - eg. contribution
+ *
* @param string $entity
* @param array $params
* @param array $values
_civicrm_api3_store_values($fields, $params, $values);
}
/**
+ * Store values.
*
* @param array $fields
* @param array $params
}
/**
- * The API supports 2 types of get requestion. The more complex uses the BAO query object.
+ * Get function for query object api.
+ *
+ * The API supports 2 types of get request. The more complex uses the BAO query object.
* This is a generic function for those functions that call it
*
* At the moment only called by contact we should extend to contribution &
*
* Ideally this would be merged with _civicrm_get_query_object but we need to resolve differences in what the
* 2 variants call
+ *
* @param $entity
* @param array $params
* As passed into api get or getcount function.
}
/**
- * get dao query object based on input params
+ * Get dao query object based on input params.
+ *
* Ideally this would be merged with _civicrm_get_using_query_object but we need to resolve differences in what the
* 2 variants call
*
* @param array $params
* @param string $mode
* @param string $entity
+ *
* @return array
* [CRM_Core_DAO|CRM_Contact_BAO_Query]
*/
}
/**
- * Function transfers the filters being passed into the DAO onto the params object
+ * Function transfers the filters being passed into the DAO onto the params object.
+ *
* @param CRM_Core_DAO $dao
* @param array $params
* @param bool $unique
$dao->selectAdd($returnValue);
}
- $unmatchedFields = array_diff(// not already matched on the field names
+ // Not already matched on the field names.
+ $unmatchedFields = array_diff(
array_keys($options['return']),
$returnMatched
);
}
/**
- * Apply filters (e.g. high, low) to DAO object (prior to find)
+ * Apply filters (e.g. high, low) to DAO object (prior to find).
+ *
* @param string $filterField
* Field name of filter.
* @param string $filterValue
}
/**
+ * Determine if custom fields need to be retrieved.
+ *
* We currently retrieve all custom fields or none at this level so if we know the entity
* && it can take custom fields & there is the string 'custom' in their return request we get them all, they are filtered on the way out
* @todo filter so only required fields are queried
return FALSE;
}
$options = _civicrm_api3_get_options_from_params($params);
- //we check for possibility of 'custom' => 1 as well as specific custom fields
+ // We check for possibility of 'custom' => 1 as well as specific custom fields.
$returnString = implode('', $options['return']) . implode('', array_keys($options['return']));
if (stristr($returnString, 'custom')) {
return TRUE;
}
}
/**
- * Converts an object to an array
+ * Converts an object to an array.
*
* @param object $dao
* (reference) object to convert.