/**
* Create or update a contact (note you should always call this via civicrm_api() & never directly)
*
- * @param array $params input parameters
+ * @param array $params
+ * Input parameters.
*
* Allowed @params array keys are:
* {@getfields contact_create}
* @throws API_Exception
* @example ContactCreate.php Example of Create Call
*
- * @return array API Result Array
+ * @return array
+ * API Result Array
*
- * @static void
- * @access public
*/
function civicrm_api3_contact_create($params) {
if (($email = CRM_Utils_Array::value('email', $params)) && !is_array($params['email'])) {
$defLocType = CRM_Core_BAO_LocationType::getDefault();
$params['email'] = array(
- 1 => array('email' => $email,
+ 1 => array(
+ 'email' => $email,
'is_primary' => 1,
'location_type_id' => ($defLocType->id) ? $defLocType->id : 1,
),
if (!empty($params['home_url'])) {
$websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
- $params['website'] = array(1 => array('website_type_id' => key($websiteTypes),
+ $params['website'] = array(
+ 1 => array(
+ 'website_type_id' => key($websiteTypes),
'url' => $params['home_url'],
),
);
/**
* Adjust Metadata for Create action
*
- * @param array $params array or parameters determined by getfields
+ * @param array $params
+ * Array or parameters determined by getfields.
*/
function _civicrm_api3_contact_create_spec(&$params) {
$params['contact_type']['api.required'] = 1;
/**
* Retrieve one or more contacts, given a set of search params
*
- * @param array input parameters
- *
- * @return array API Result Array
- * (@getfields contact_get}
- * @static void
- * @access public
- *
- * @example ContactGet.php Standard GET example
+ * @param array input parameters
*
+ * @return array
+ * API Result Array
*/
function civicrm_api3_contact_get($params) {
$options = array();
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;
}
/**
* Adjust Metadata for Get action
*
- * @param array $params array or parameters determined by getfields
+ * @param array $params
+ * Array or parameters determined by getfields.
*/
function _civicrm_api3_contact_get_spec(&$params) {
$params['contact_is_deleted']['api.default'] = 0;
$params['tag']['title'] = 'Assigned tags (filter, array)';
$params['birth_date_low'] = array('name' => 'birth_date_low', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Birth Date is equal to or greater than'));
$params['birth_date_high'] = array('name' => 'birth_date_high', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Birth Date is equal to or less than'));
- $params['deceased_date_low'] = array('name' => 'deceased_date_low','type' => CRM_Utils_Type::T_DATE, 'title' => ts('Deceased Date is equal to or greater than'));
+ $params['deceased_date_low'] = array('name' => 'deceased_date_low', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Deceased Date is equal to or greater than'));
$params['deceased_date_high'] = array('name' => 'deceased_date_high', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Deceased Date is equal to or less than'));
}
*
* We also support 'filter_group_id' & 'filter.group_id'
*
- * @param array $params as passed into api get or getcount function
- * @param array $options array of options (so we can modify the filter)
+ * @param array $params
+ * As passed into api get or getcount function.
+ * @param array $options
+ * Array of options (so we can modify the filter).
*/
function _civicrm_api3_contact_get_supportanomalies(&$params, &$options) {
if (isset($params['showAll'])) {
if (is_array($params['filter.group_id'])) {
$groups = $params['filter.group_id'];
}
- else $groups = explode(',', $params['filter.group_id']);
+ else {
+ $groups = explode(',', $params['filter.group_id']);
+ }
unset($params['filter.group_id']);
$groups = array_flip($groups);
$groups[key($groups)] = 1;
/**
* Delete a contact with given contact id
*
- * @param array $params (reference ) input parameters, contact_id element required
- *
- * @return array API Result Array
- * @access public
+ * @param array $params
+ * input parameters per getfields
*
- * @example ContactDelete.php
- * {@getfields contact_delete}
+ * @return array
+ * API Result Array
*/
function civicrm_api3_contact_delete($params) {
/**
* @param array $params
* @param bool $dupeCheck
- * @param bool $dupeErrorArray
- * @param bool $obsoletevalue
- * @param int $dedupeRuleGroupID
*
* @return null
* @throws API_Exception
* @throws CiviCRM_API3_Exception
*/
-function _civicrm_api3_contact_check_params( &$params, $dupeCheck = true, $dupeErrorArray = false, $obsoletevalue = true, $dedupeRuleGroupID = null )
-{
+function _civicrm_api3_contact_check_params(&$params, $dupeCheck) {
switch (strtolower(CRM_Utils_Array::value('contact_type', $params))) {
case 'household':
- civicrm_api3_verify_mandatory($params, null, array('household_name'));
+ civicrm_api3_verify_mandatory($params, NULL, array('household_name'));
break;
+
case 'organization':
- civicrm_api3_verify_mandatory($params, null, array('organization_name'));
+ civicrm_api3_verify_mandatory($params, NULL, array('organization_name'));
break;
+
case 'individual':
- civicrm_api3_verify_one_mandatory($params, null, array(
+ civicrm_api3_verify_one_mandatory($params, NULL, array(
'first_name',
'last_name',
'email',
'display_name',
)
- );
- break;
+ );
+ break;
}
// Fixme: This really needs to be handled at a lower level. @See CRM-13123
}
if (!empty($params['contact_sub_type']) && !empty($params['contact_type'])) {
- if (!(CRM_Contact_BAO_ContactType::isExtendsContactType($params['contact_sub_type'], $params['contact_type']))) {
- throw new API_Exception("Invalid or Mismatched Contact Subtype: " . implode(', ', (array)$params['contact_sub_type']));
- }
+ if (!(CRM_Contact_BAO_ContactType::isExtendsContactType($params['contact_sub_type'], $params['contact_type']))) {
+ throw new API_Exception("Invalid or Mismatched Contact Subtype: " . implode(', ', (array) $params['contact_sub_type']));
}
+ }
if ($dupeCheck) {
// check for record already existing
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $params['contact_type'], 'Unsupervised', array());
- if (count($ids) >0) {
- throw new API_Exception("Found matching contacts: ". implode(',',$ids),"duplicate",array("ids"=>$ids));
+ if (count($ids) > 0) {
+ throw new API_Exception("Found matching contacts: " . implode(',', $ids), "duplicate", array("ids" => $ids));
}
}
else {
$result = civicrm_api3('contact', 'create', array(
'organization_name' => $params['current_employer'],
- 'contact_type' => 'Organization'
+ 'contact_type' => 'Organization',
));
$params['employer_id'] = $result['id'];
}
* Takes an associative array and creates a contact object and all the associated
* derived objects (i.e. individual, location, email, phone etc)
*
- * @param array $params (reference ) an assoc array of name/value pairs
- * @param int $contactID if present the contact with that ID is updated
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
+ * @param int $contactID
+ * If present the contact with that ID is updated.
*
- * @return CRM_Contact_BAO_Contact object
- * @access public
- * @static
+ * @return CRM_Contact_BAO_Contact|CRM_Core_Error
*/
function _civicrm_api3_contact_update($params, $contactID = NULL) {
//@todo - doesn't contact create support 'id' which is already set- check & remove
/**
* Validate the addressee or email or postal greetings
*
- * @param array $params Associative array of property name/value
+ * @param array $params
+ * Associative array of property name/value.
* pairs to insert in new contact.
*
* @throws API_Exception
*
- * @access public
*/
function _civicrm_api3_greeting_format_params($params) {
$greetingParams = array('', '_id', '_custom');
$greetingId = CRM_Utils_Array::key('Customized', $greetings);
}
- $customValue = isset($params['contact_id']) ?
- CRM_Core_DAO::getFieldValue(
+ $customValue = isset($params['contact_id']) ? CRM_Core_DAO::getFieldValue(
'CRM_Contact_DAO_Contact',
$params['contact_id'],
"{$key}{$greeting}_custom"
- ) :
- FALSE;
+ ) : FALSE;
if (array_key_exists("{$key}{$greeting}_id", $params) && empty($params["{$key}{$greeting}_id"])) {
$nullValue = TRUE;
* @deprecated
*
* {@example ContactGetquick.php 0}
- *
+ * @param array $params
+ * @return array
+ * @throws \API_Exception
*/
function civicrm_api3_contact_getquick($params) {
civicrm_api3_verify_mandatory($params, NULL, array('name'));
}
// phone_numeric should be phone
$searchField = str_replace('_numeric', '', $field_name);
- if(!in_array($searchField, $list)) {
+ if (!in_array($searchField, $list)) {
$list[] = $searchField;
}
}
while ($dao->fetch()) {
$t = array('id' => $dao->id);
foreach ($as as $k) {
- $t[$k] = isset($dao->$k)? $dao->$k: '';
+ $t[$k] = isset($dao->$k) ? $dao->$k : '';
}
$t['data'] = $dao->data;
$contactList[] = $t;
$contactList = array(
array(
'data' => $currEmpDetails['data'],
- 'id' => $currEmpDetails['id']
- )
+ 'id' => $currEmpDetails['id'],
+ ),
);
}
else {
$contactList = array(
array(
'data' => $name,
- 'id' => $name
- )
+ 'id' => $name,
+ ),
);
}
}
/**
* @deprecated api notice
- * @return array of deprecated actions
+ * @return array
+ * Array of deprecated actions
*/
function _civicrm_api3_contact_deprecation() {
return array('getquick' => 'The "getquick" action is deprecated in favor of "getlist".');
/**
* Merges given pair of duplicate contacts.
*
- * @param array $params input parameters
+ * @param array $params
+ * Input parameters.
*
* Allowed @params array keys are:
* {int main_id main contact id with whom merge has to happen}
* A 'safe' value skips the merge if there are no conflicts. Does a force merge otherwise.}
* {boolean auto_flip wether to let api decide which contact to retain and which to delete.}
*
- * @return array API Result Array
+ * @return array
+ * API Result Array
*
- * @static void
- * @access public
*/
function civicrm_api3_contact_merge($params) {
$mode = CRM_Utils_Array::value('mode', $params, 'safe');
$autoFlip = CRM_Utils_Array::value('auto_flip', $params, TRUE);
- $dupePairs = array(array('srcID' => CRM_Utils_Array::value('main_id', $params),
+ $dupePairs = array(array(
+ 'srcID' => CRM_Utils_Array::value('main_id', $params),
'dstID' => CRM_Utils_Array::value('other_id', $params),
));
$result = CRM_Dedupe_Merger::merge($dupePairs, array(), $mode, $autoFlip);
/**
* @see _civicrm_api3_generic_getlist_params
*
- * @param $request array
+ * @param $request
+ * Array.
*/
function _civicrm_api3_contact_getlist_params(&$request) {
// get the autocomplete options from settings
}
// phone_numeric should be phone
$searchField = str_replace('_numeric', '', $field_name);
- if(!in_array($searchField, $list)) {
+ if (!in_array($searchField, $list)) {
$list[] = $searchField;
}
$request['description_field'] = $list;
/**
* @see _civicrm_api3_generic_getlist_output
*
- * @param $result array
- * @param $request array
+ * @param $result
+ * Array.
+ * @param $request
+ * Array.
*
* @return array
*/
}
}
$address = array();
- foreach($addressFields as $item) {
+ foreach ($addressFields as $item) {
if (!empty($row[$item])) {
$address[] = $row[$item];
}