/**
* Class constructor
+ * @param null $title
+ * @param bool $modal
+ * @param int|mixed|null $action
*/
public function __construct($title = NULL, $modal = TRUE, $action = CRM_Core_Action::NONE) {
/**
* Shorthand for getting id by display name (makes code more readable)
+ * @param $displayName
+ * @return null|string
*/
protected function _getIdByDisplayName($displayName) {
return CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
/**
* Shorthand for getting display name by id (makes code more readable)
+ * @param $id
+ * @return null|string
*/
protected function _getDisplayNameById($id) {
return CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
/**
* Class constructor
+ * @param null $title
+ * @param bool|int $action
+ * @param bool $modal
*/
public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE) {
parent::__construct($title, $modal);
/**
* The value is in string format. convert the value to the type of this field
* and set the field value with the appropriate type
+ * @param $value
*/
public function setValue($value) {
$this->_value = $value;
/**
* Class constructor
+ * @param $mapperKeys
+ * @param null $mapperLocType
+ * @param null $mapperPhoneType
*/
public function __construct(&$mapperKeys, $mapperLocType = NULL, $mapperPhoneType = NULL) {
parent::__construct();
/**
* Class constructor
+ * @param object $controller
+ * @param \const|int $action
*/
public function __construct($controller, $action = CRM_Core_Action::NONE) {
parent::__construct($controller, $action);
/**
* Global validation rules for the form
+ * @param $fields
+ * @param $files
+ * @param $form
+ * @return array|bool
*/
public static function formRule($fields, $files, $form) {
$errors = array();
}
/**
+ * @param $sql
* @param $rows
*/
public function buildRows($sql, &$rows) {
/**
* Perform action
+ * @param $action
+ * @param $params
+ * @return bool
*/
public function __call($action, $params) {
// @TODO Check if it's a valid action.
/**
* As of PHP 5.3.0
+ * @param $name
+ * @param $arguments
*/
public static function __callStatic($name, $arguments) {
// Should we implement it ?
/**
* Call via rest
- * @return stdClass
+ * @param $entity
+ * @param $action
+ * @param array $params
+ * @return \stdClass
*/
function remoteCall($entity, $action, $params = array()) {
$fields = "key={$this->key}&api_key={$this->api_key}";
}
/**
+ * @param $name
+ * @param null $value
* @return $this
*/
public function attr($name, $value = NULL) {
}
/**
+ * @param $name
* @return $this
*/
public function __get($name) {
/**
* Get CiviCRM Action Schedule details
* {@getfields action_schedule_create}
- *
+ * @param $params
+ * @return array
*/
function civicrm_api3_action_schedule_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'action_schedule');
/**
* format definition
*
- * @param $caseTypes
+ * @param array $result
* @return mixed
+ * @throws \CRM_Core_Exception
*/
function _civicrm_api3_case_type_get_formatResult(&$result) {
foreach ($result['values'] as $key => $caseType) {
* @deprecated
*
* {@example ContactGetquick.php 0}
- *
+ * @param $params
+ * @return array
+ * @throws \API_Exception
*/
function civicrm_api3_contact_getquick($params) {
civicrm_api3_verify_mandatory($params, NULL, array('name'));
* The main purpose of the API is to provide integrators a level of stability not provided by
* the core code or schema - this means we have to provide support for api calls (where possible)
* across schema changes.
+ * @param $params
*/
function _civicrm_api3_contribution_create_legacy_support_45(&$params) {
//legacy soft credit handling - recommended approach is chaining
/**
* modify metadata. Legacy support for contribution_id
+ * @param $params
*/
function _civicrm_api3_contribution_delete_spec(&$params) {
$params['id']['api.aliases'] = array('contribution_id');
* This function is used to format the soft credit for backward compatibility
* as of v4.4 we support multiple soft credit, so now contribution returns array with 'soft_credit' as key
* but we still return first soft credit as a part of contribution array
+ * @param $contribution
*/
function _civicrm_api3_format_soft_credit(&$contribution) {
if (!empty($contribution['soft_credit'])) {
/**
* CRM-15191 - Hack to ensure the cache gets cleared after updating a custom field
+ * @param $params
+ * @return array
*/
function civicrm_api3_custom_field_setvalue($params) {
require_once 'api/v3/Generic/Setvalue.php';
/**
* CRM-15191 - Hack to ensure the cache gets cleared after updating a custom group
+ * @param $params
+ * @return array
*/
function civicrm_api3_custom_group_setvalue($params) {
require_once 'api/v3/Generic/Setvalue.php';
*
* {@getfields dashboard_contact_delete}
* @access public
+ * @param $params
+ * @return array
+ * @throws \API_Exception
*/
function civicrm_api3_dashboard_contact_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* Get CiviCRM domain details
* {@getfields domain_create}
* @example DomainGet.php
+ * @param $params
+ * @return array
+ * @throws \API_Exception
*/
function civicrm_api3_domain_get($params) {
/**
* Placeholder function. This should never be called, as it doesn't have any meaning
+ * @param $params
+ * @return array
*/
function civicrm_api3_entity_create($params) {
return civicrm_api3_create_error("API (Entity, Create) does not exist Creating a new entity means modifying the source code of civiCRM.");
/**
* Placeholder function. This should never be called, as it doesn't have any meaning
+ * @param $params
+ * @return array
*/
function civicrm_api3_entity_delete($params) {
return civicrm_api3_create_error("API (Entity, Delete) does not exist Deleting an entity means modifying the source code of civiCRM.");
/**
* Placeholder function. This should never be called, as it doesn't have any meaning
+ * @param $params
+ * @return array
*/
function civicrm_api3_entity_getfields($params) {
// we return an empty array so it makes it easier to write generic getdefaults / required tests
/**
* modify metadata
+ * @param $params
*/
function _civicrm_api3_entity_tag_delete_spec(&$params) {
// set as not required as tag_id also acceptable & no either/or std yet
* The main purpose of the API is to provide integrators a level of stability not provided by
* the core code or schema - this means we have to provide support for api calls (where possible)
* across schema changes.
+ * @param $params
*/
function _civicrm_api3_event_create_legacy_support_42(&$params) {
if (!empty($params['payment_processor_id'])) {
* The main purpose of the API is to provide integrators a level of stability not provided by
* the core code or schema - this means we have to provide support for api calls (where possible)
* across schema changes.
+ * @param $event
+ * @param $event_id
*/
function _civicrm_api3_event_get_legacy_support_42(&$event, $event_id) {
if (!empty($event[$event_id]['payment_processor'])) {
*
* This API is used for deleting a event
*
- * @param array $paramsArray containing event_id to be deleted.
- * Array containing event_id to be deleted.
+ * @param $params
+ * @return array
*
- * @return boolean
- * true if success, error otherwise
* @access public
* note API has legacy support for 'event_id'
* {@getfields event_delete}
*/
function civicrm_api3_event_delete($params) {
-
return CRM_Event_BAO_Event::del($params['id']) ? civicrm_api3_create_success() : civicrm_api3_create_error(ts('Error while deleting event'));
}
/*
* This api is used for updating an existing file.
* Required parameters : id of a file
*
- * @param array $paramsAn array of name/value property values of civicrm_file.
- * An array of name/value property values of civicrm_file.
- *
+ * @param array $params
* @return array
- * Array of updated file object property values
- * @access public
*/
function civicrm_api3_file_update($params) {
/**
* modify metadata
+ * @param $params
*/
function _civicrm_api3_group_contact_delete_spec(&$params) {
// set as not required no either/or std yet
/**
* @deprecated - this should be part of create but need to know we aren't missing something
+ * @param $params
+ * @return bool
+ * @throws \API_Exception
*/
function civicrm_api3_group_contact_update_status($params) {
* Fix the reset dates on the email record based on when a mail was last delivered
* We only consider mailings that were completed and finished in the last 3 to 7 days
* Both the min and max days can be set via the params
+ * @param $params
+ * @return array
*/
function civicrm_api3_mailing_update_email_resetdate($params) {
CRM_Mailing_Event_BAO_Delivered::updateEmailResetDate(
* Handle a create mailing ab testing
*
* @param array $params
- * @param array $ids
*
* @return array
* API Success Array
* Handle a delete event.
*
* @param array $params
- * @param array $ids
*
* @return array
* API Success Array
/**
* Handle creation of a Mailing Job for a Mailing.
+ * @param $params
+ * @return array
+ * @throws \API_Exception
*/
function civicrm_api3_mailing_job_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
/**
* Handle deletion of a Mailing Job for a Mailing.
+ * @param $params
+ * @return array
+ * @throws \API_Exception
*/
function civicrm_api3_mailing_job_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
/**
* @access public
+ * @param $params
+ * @return array
+ * @throws \API_Exception
*/
function civicrm_api3_message_template_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
/**
* Sends a template.
+ * @param $params
*/
function civicrm_api3_message_template_send($params) {
CRM_Core_BAO_MessageTemplates::sendTemplate($params);
/**
* @todo this should be done in the BAO not the api
* Create a default participant line item
+ * @param $params
+ * @param $participant
+ * @throws \CiviCRM_API3_Exception
*/
function _civicrm_api3_participant_createlineitem(&$params, $participant) {
// it is possible that a fee level contains information about multiple
* @access public
* {@getfields PaymentProcessorType_get}
* @example PaymentProcessorTypeGet.php
+ * @param $params
+ * @return array
*/
function civicrm_api3_payment_processor_type_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
/**
* return field specification specific to get requests
+ * @param $params
*/
function _civicrm_api3_pledge_get_spec(&$params) {
$params['next_pay_date'] = array(
/**
* return field specification specific to get requests
+ * @param $params
*/
function _civicrm_api3_pledge_create_spec(&$params) {
/**
* return field specification specific to get requests
+ * @param $params
*/
function _civicrm_api3_premium_get_spec(&$params) {
$params['premiums_active']['api.aliases'] = array('is_active');
/**
* return field specification specific to create requests
+ * @param $params
*/
function _civicrm_api3_premium_create_spec(&$params) {
$params['premiums_active']['api.aliases'] = array('is_active');
* @access public
* {@getfields RelationshipType_get}
* @example RelationshipTypeGet.php
+ * @param $params
+ * @return array
*/
function civicrm_api3_relationship_type_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @subpackage API_Settings
* @copyright CiviCRM LLC (c) 2004-2014
* @version $Id: Settings.php
- *
+ * @param $params
+ * @return array
*/
function civicrm_api3_setting_getfields($params) {
/**
* Alter metadata for getfields functions
+ * @param $params
*/
function _civicrm_api3_setting_getfields_spec(&$params) {
$params['filters'] = array('title' => 'Fields you wish to filter by e.g. array("group_name" => "CiviCRM Preferences")');
* Return default values for settings. We will domain key this as it could vary by domain (ie. urls)
* as we will be creating the option for a function rather than an value to be in the defaults
* Note that is not in place as yet
+ * @param $params
+ * @return array
+ * @throws \CiviCRM_API3_Exception
+ * @throws \Exception
*/
function civicrm_api3_setting_getdefaults(&$params) {
$settings = civicrm_api3('setting', 'getfields', $params);
/**
* Revert settings to defaults
+ * @param $params
+ * @return array
+ * @throws \Exception
*/
function civicrm_api3_setting_revert(&$params) {
$defaults = civicrm_api('setting', 'getdefaults', $params);
/**
* Alter metadata for getfields functions
+ * @param $params
*/
function _civicrm_api3_setting_revert_spec(&$params) {
$params['name'] = array('title' => 'Setting Name belongs to');
/**
* Revert settings to defaults
+ * @param $params
+ * @return array
+ * @throws \CiviCRM_API3_Exception
+ * @throws \Exception
*/
function civicrm_api3_setting_fill(&$params) {
$defaults = civicrm_api3('setting', 'getdefaults', $params);
/**
* Alter metadata for getfields functions
+ * @param $params
*/
function _civicrm_api3_setting_fill_spec(&$params) {
$params['name'] = array('title' => 'Setting Name belongs to');
* Really domain_id should always be set but doing an empty check because at the moment
* using crm-editable will pass an id & default won't be applied
* we did talk about id being a pseudonym for domain_id in this api so applying it here
+ * @param $params
+ * @return array
+ * @throws \Exception
*/
function _civicrm_api3_setting_getDomainArray(&$params) {
if (empty($params['domain_id']) && isset($params['id'])) {
/**
* @deprecated - api currently not supported
+ * @param $params
+ * @return array
*/
function &civicrm_api3_survey_respondant_count($params) {
return civicrm_api3_create_success($result, $params);
}
+
/**
* field id accepted for backward compatibility - unset required on id
+ * @param $params
*/
function _civicrm_api3_uf_field_delete_spec(&$params) {
// legacy support for field_id
/**
* Get CiviCRM Word Replacement details
* {@getfields word_replacement_create}
- *
+ * @param $params
+ * @return array
+ * @throws \API_Exception
*/
function civicrm_api3_word_replacement_get($params) {
$bao = new CRM_Core_BAO_WordReplacement();
/**
*
+ * @param $msg
* @param array $data
- *
- * @throws API_Exception
* @return array
- * <type>
*/
function civicrm_api3_create_error($msg, $data = array()) {
$data['is_error'] = 1;
/**
* Load the DAO of the entity
+ * @param $entity
+ * @return bool
*/
function _civicrm_api3_load_DAO($entity) {
$dao = _civicrm_api3_get_DAO($entity);
/**
* Recursive function to explode value-separated strings into arrays
- *
+ * @param $values
*/
function _civicrm_api3_separate_values(&$values) {
$sp = CRM_Core_DAO::VALUE_SEPARATOR;
/**
* build fields array. This is the array of fields as it relates to the given DAO
* returns unique fields as keys by default but if set but can return by DB fields
+ * @param $bao
+ * @param bool $unique
+ * @return
*/
function _civicrm_api3_build_fields_array(&$bao, $unique = TRUE) {
$fields = $bao->fields();
/**
* Wrapper for _civicrm_object_to_array when api supports unique fields
+ * @param $dao
+ * @param $values
+ * @return array
*/
function _civicrm_api3_object_to_array_unique_fields(&$dao, &$values) {
return _civicrm_api3_object_to_array($dao, $values, TRUE);
/**
* Validate foreign constraint fields being passed into API.
*
- * @param array $params
- * Params from civicrm_api.
+ * @param mixed $fieldValue
* @param string $fieldName
* Uniquename of field being checked.
* @param array $fieldInfo
* Array of fields from getfields function.
- * @throws Exception
+ * @throws \API_Exception
*/
function _civicrm_api3_validate_constraint(&$fieldValue, &$fieldName, &$fieldInfo) {
$dao = new $fieldInfo['FKClassName'];
$dao->selectAdd();
$dao->selectAdd('id');
if (!$dao->find()) {
- throw new Exception("$fieldName is not valid : " . $fieldValue);
+ throw new API_Exception("$fieldName is not valid : " . $fieldValue);
}
}
/**
* Return an array of fields for a given entity - this is the same as the BAO function but
* fields are prefixed with 'custom_' to represent api params
+ * @param $entity
+ * @param $params
+ * @return array
*/
function _civicrm_api_get_custom_fields($entity, &$params) {
$entity = _civicrm_api_get_camel_name($entity);
}
return $ret;
}
+
/**
* Translate the custom field data_type attribute into a std 'type'
+ * @param $dataType
+ * @return
*/
function _getStandardTypeFromCustomDataType($dataType) {
$mapping = array(
* If multiple aliases the last takes precedence
*
* Function also swaps unique fields for non-unique fields & vice versa.
+ * @param $apiRequest
+ * @param $fields
*/
function _civicrm_api3_swap_out_aliases(&$apiRequest, $fields) {
foreach ($fields as $field => $values) {
/**
* Validate & swap out any pseudoconstants / options
*
- * @param array $params: api parameters
- * @param string $entity: api entity name
- * @param string $fieldName: field name used in api call (not necessarily the canonical name)
- * @param array $fieldInfo: getfields meta-data
+ * @param mixed $fieldValue
+ * @param string $entity : api entity name
+ * @param string $fieldName : field name used in api call (not necessarily the canonical name)
+ * @param array $fieldInfo : getfields meta-data
+ * @throws \API_Exception
*/
function _civicrm_api3_api_match_pseudoconstant(&$fieldValue, $entity, $fieldName, $fieldInfo) {
$options = CRM_Utils_Array::value('options', $fieldInfo);