}
if (!empty($params['dupe_check'])) {
- $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, $params['contact_type'], 'Unsupervised', array(), $params['check_permission']);
+ $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, $params['contact_type'], 'Unsupervised', [], $params['check_permission']);
if (count($ids) > 0) {
- throw new API_Exception("Found matching contacts: " . implode(',', $ids), "duplicate", array("ids" => $ids));
+ throw new API_Exception("Found matching contacts: " . implode(',', $ids), "duplicate", ["ids" => $ids]);
}
}
// If we get here, we're ready to create a new contact
if (($email = CRM_Utils_Array::value('email', $params)) && !is_array($params['email'])) {
$defLocType = CRM_Core_BAO_LocationType::getDefault();
- $params['email'] = array(
- 1 => array(
+ $params['email'] = [
+ 1 => [
'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(
+ $params['website'] = [
+ 1 => [
'website_type_id' => key($websiteTypes),
'url' => $params['home_url'],
- ),
- );
+ ],
+ ];
}
_civicrm_api3_greeting_format_params($params);
- $values = array();
+ $values = [];
if (empty($params['contact_type']) && $contactID) {
$params['contact_type'] = CRM_Contact_BAO_Contact::getContactType($contactID);
throw new API_Exception($contact->_errors[0]['message']);
}
else {
- $values = array();
+ $values = [];
_civicrm_api3_object_to_array_unique_fields($contact, $values[$contact->id]);
}
*/
function _civicrm_api3_contact_create_spec(&$params) {
$params['contact_type']['api.required'] = 1;
- $params['id']['api.aliases'] = array('contact_id');
- $params['current_employer'] = array(
+ $params['id']['api.aliases'] = ['contact_id'];
+ $params['current_employer'] = [
'title' => 'Current Employer',
'description' => 'Name of Current Employer',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['dupe_check'] = array(
+ ];
+ $params['dupe_check'] = [
'title' => 'Check for Duplicates',
'description' => 'Throw error if contact create matches dedupe rule',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $params['skip_greeting_processing'] = array(
+ ];
+ $params['skip_greeting_processing'] = [
'title' => 'Skip Greeting processing',
'description' => 'Do not process greetings, (these can be done by scheduled job and there may be a preference to do so for performance reasons)',
'type' => CRM_Utils_Type::T_BOOLEAN,
'api.default' => 0,
- );
- $params['prefix_id']['api.aliases'] = array('individual_prefix', 'individual_prefix_id');
- $params['suffix_id']['api.aliases'] = array('individual_suffix', 'individual_suffix_id');
- $params['gender_id']['api.aliases'] = array('gender');
+ ];
+ $params['prefix_id']['api.aliases'] = [
+ 'individual_prefix',
+ 'individual_prefix_id',
+ ];
+ $params['suffix_id']['api.aliases'] = [
+ 'individual_suffix',
+ 'individual_suffix_id',
+ ];
+ $params['gender_id']['api.aliases'] = ['gender'];
}
/**
* API Result Array
*/
function civicrm_api3_contact_get($params) {
- $options = array();
+ $options = [];
_civicrm_api3_contact_get_supportanomalies($params, $options);
$contacts = _civicrm_api3_get_using_query_object('Contact', $params, $options);
$contacts = _civicrm_api3_contact_formatResult($params, $contacts);
* @throws \CRM_Core_Exception
*/
function _civicrm_api3_contact_formatResult($params, $result) {
- $apiKeyPerms = array('edit api keys', 'administer CiviCRM');
- $allowApiKey = empty($params['check_permissions']) || CRM_Core_Permission::check(array($apiKeyPerms));
+ $apiKeyPerms = ['edit api keys', 'administer CiviCRM'];
+ $allowApiKey = empty($params['check_permissions']) || CRM_Core_Permission::check([$apiKeyPerms]);
if (!$allowApiKey) {
if (is_array($result)) {
// Single-value $result
* @return int
*/
function civicrm_api3_contact_getcount($params) {
- $options = array();
+ $options = [];
_civicrm_api3_contact_get_supportanomalies($params, $options);
$count = _civicrm_api3_get_using_query_object('Contact', $params, $options, 1);
return (int) $count;
// We declare all these pseudoFields as there are other undocumented fields accessible
// via the api - but if check permissions is set we only allow declared fields
- $params['address_id'] = array(
+ $params['address_id'] = [
'title' => 'Primary Address ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['street_address'] = array(
+ ];
+ $params['street_address'] = [
'title' => 'Primary Address Street Address',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['supplemental_address_1'] = array(
+ ];
+ $params['supplemental_address_1'] = [
'title' => 'Primary Address Supplemental Address 1',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['supplemental_address_2'] = array(
+ ];
+ $params['supplemental_address_2'] = [
'title' => 'Primary Address Supplemental Address 2',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['supplemental_address_3'] = array(
+ ];
+ $params['supplemental_address_3'] = [
'title' => 'Primary Address Supplemental Address 3',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['current_employer'] = array(
+ ];
+ $params['current_employer'] = [
'title' => 'Current Employer',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['city'] = array(
+ ];
+ $params['city'] = [
'title' => 'Primary Address City',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['postal_code_suffix'] = array(
+ ];
+ $params['postal_code_suffix'] = [
'title' => 'Primary Address Post Code Suffix',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['postal_code'] = array(
+ ];
+ $params['postal_code'] = [
'title' => 'Primary Address Post Code',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['geo_code_1'] = array(
+ ];
+ $params['geo_code_1'] = [
'title' => 'Primary Address Latitude',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['geo_code_2'] = array(
+ ];
+ $params['geo_code_2'] = [
'title' => 'Primary Address Longitude',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['state_province_id'] = array(
+ ];
+ $params['state_province_id'] = [
'title' => 'Primary Address State Province ID',
'type' => CRM_Utils_Type::T_INT,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'table' => 'civicrm_state_province',
- ),
- );
- $params['state_province_name'] = array(
+ ],
+ ];
+ $params['state_province_name'] = [
'title' => 'Primary Address State Province Name',
'type' => CRM_Utils_Type::T_STRING,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'table' => 'civicrm_state_province',
- ),
- );
- $params['state_province'] = array(
+ ],
+ ];
+ $params['state_province'] = [
'title' => 'Primary Address State Province',
'type' => CRM_Utils_Type::T_STRING,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'table' => 'civicrm_state_province',
- ),
- );
- $params['country_id'] = array(
+ ],
+ ];
+ $params['country_id'] = [
'title' => 'Primary Address Country ID',
'type' => CRM_Utils_Type::T_INT,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'table' => 'civicrm_country',
- ),
- );
- $params['country'] = array(
+ ],
+ ];
+ $params['country'] = [
'title' => 'Primary Address country',
'type' => CRM_Utils_Type::T_STRING,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'table' => 'civicrm_country',
- ),
- );
- $params['worldregion_id'] = array(
+ ],
+ ];
+ $params['worldregion_id'] = [
'title' => 'Primary Address World Region ID',
'type' => CRM_Utils_Type::T_INT,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'table' => 'civicrm_world_region',
- ),
- );
- $params['worldregion'] = array(
+ ],
+ ];
+ $params['worldregion'] = [
'title' => 'Primary Address World Region',
'type' => CRM_Utils_Type::T_STRING,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'table' => 'civicrm_world_region',
- ),
- );
- $params['phone_id'] = array(
+ ],
+ ];
+ $params['phone_id'] = [
'title' => 'Primary Phone ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['phone'] = array(
+ ];
+ $params['phone'] = [
'title' => 'Primary Phone',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['phone_type_id'] = array(
+ ];
+ $params['phone_type_id'] = [
'title' => 'Primary Phone Type ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['provider_id'] = array(
+ ];
+ $params['provider_id'] = [
'title' => 'Primary Phone Provider ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['email_id'] = array(
+ ];
+ $params['email_id'] = [
'title' => 'Primary Email ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['email'] = array(
+ ];
+ $params['email'] = [
'title' => 'Primary Email',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['on_hold'] = array(
+ ];
+ $params['on_hold'] = [
'title' => 'Primary Email On Hold',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $params['im'] = array(
+ ];
+ $params['im'] = [
'title' => 'Primary Instant Messenger',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['im_id'] = array(
+ ];
+ $params['im_id'] = [
'title' => 'Primary Instant Messenger ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['group'] = array(
+ ];
+ $params['group'] = [
'title' => 'Group',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'table' => 'civicrm_group',
- ),
- );
- $params['tag'] = array(
+ ],
+ ];
+ $params['tag'] = [
'title' => 'Tags',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'table' => 'civicrm_tag',
- ),
- );
- $params['uf_user'] = array(
+ ],
+ ];
+ $params['uf_user'] = [
'title' => 'CMS User',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $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_high'] = array('name' => 'deceased_date_high', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Deceased Date is equal to or less than'));
+ ];
+ $params['birth_date_low'] = [
+ 'name' => 'birth_date_low',
+ 'type' => CRM_Utils_Type::T_DATE,
+ 'title' => ts('Birth Date is equal to or greater than'),
+ ];
+ $params['birth_date_high'] = [
+ 'name' => 'birth_date_high',
+ 'type' => CRM_Utils_Type::T_DATE,
+ 'title' => ts('Birth Date is equal to or less than'),
+ ];
+ $params['deceased_date_low'] = [
+ 'name' => 'deceased_date_low',
+ 'type' => CRM_Utils_Type::T_DATE,
+ 'title' => ts('Deceased Date is equal to or greater than'),
+ ];
+ $params['deceased_date_high'] = [
+ 'name' => 'deceased_date_high',
+ 'type' => CRM_Utils_Type::T_DATE,
+ 'title' => ts('Deceased Date is equal to or less than'),
+ ];
}
/**
}
}
}
- elseif (!is_numeric($groups) && !empty($allGroups[$groups])) {
+ elseif (!is_numeric($groups) && !empty($allGroups[$groups])) {
$groups = $allGroups[$groups];
}
$params['group'] = $groups;
// CRM-12929
// restrict permanent delete if a contact has financial trxn associated with it
$error = NULL;
- if ($skipUndelete && CRM_Financial_BAO_FinancialItem::checkContactPresent(array($contactID), $error)) {
+ if ($skipUndelete && CRM_Financial_BAO_FinancialItem::checkContactPresent([$contactID], $error)) {
return civicrm_api3_create_error($error['_qf_default']);
}
if (CRM_Contact_BAO_Contact::deleteContact($contactID, $restore, $skipUndelete,
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, ['household_name']);
break;
case 'organization':
- civicrm_api3_verify_mandatory($params, NULL, array('organization_name'));
+ civicrm_api3_verify_mandatory($params, NULL, ['organization_name']);
break;
case 'individual':
- civicrm_api3_verify_one_mandatory($params, NULL, array(
- 'first_name',
- 'last_name',
- 'email',
- 'display_name',
- )
+ civicrm_api3_verify_one_mandatory($params, NULL, [
+ 'first_name',
+ 'last_name',
+ 'email',
+ 'display_name',
+ ]
);
break;
}
// The BAO no longer supports the legacy param "current_employer" so here is a shim for api backward-compatability
if (!empty($params['current_employer'])) {
- $organizationParams = array(
+ $organizationParams = [
'organization_name' => $params['current_employer'],
- );
+ ];
- $dupeIds = CRM_Contact_BAO_Contact::getDuplicateContacts($organizationParams, 'Organization', 'Supervised', array(), FALSE);
+ $dupeIds = CRM_Contact_BAO_Contact::getDuplicateContacts($organizationParams, 'Organization', 'Supervised', [], FALSE);
// check for mismatch employer name and id
if (!empty($params['employer_id']) && !in_array($params['employer_id'], $dupeIds)) {
$params['employer_id'] = $dupeIds[0];
}
else {
- $result = civicrm_api3('Contact', 'create', array(
+ $result = civicrm_api3('Contact', 'create', [
'organization_name' => $params['current_employer'],
'contact_type' => 'Organization',
- ));
+ ]);
$params['employer_id'] = $result['id'];
}
}
* @throws API_Exception
*/
function _civicrm_api3_greeting_format_params($params) {
- $greetingParams = array('', '_id', '_custom');
- foreach (array('email', 'postal', 'addressee') as $key) {
+ $greetingParams = ['', '_id', '_custom'];
+ foreach (['email', 'postal', 'addressee'] as $key) {
$greeting = '_greeting';
if ($key == 'addressee') {
$greeting = '';
}
$nullValue = FALSE;
- $filter = array(
+ $filter = [
'greeting_type' => "{$key}{$greeting}",
- );
+ ];
- $greetings = CRM_Core_PseudoConstant::greeting($filter);
- $greetingId = CRM_Utils_Array::value("{$key}{$greeting}_id", $params);
- $greetingVal = CRM_Utils_Array::value("{$key}{$greeting}", $params);
+ $greetings = CRM_Core_PseudoConstant::greeting($filter);
+ $greetingId = CRM_Utils_Array::value("{$key}{$greeting}_id", $params);
+ $greetingVal = CRM_Utils_Array::value("{$key}{$greeting}", $params);
$customGreeting = CRM_Utils_Array::value("{$key}{$greeting}_custom", $params);
if (!$greetingId && $greetingVal) {
($greetingId != array_search('Customized', $greetings))
) {
throw new API_Exception(ts('Provide either %1 greeting id and/or %1 greeting or custom %1 greeting',
- array(1 => $key)
- ));
+ [1 => $key]
+ ));
}
if ($greetingVal && $greetingId &&
($greetingId != CRM_Utils_Array::key($greetingVal, $greetings))
) {
throw new API_Exception(ts('Mismatch in %1 greeting id and %1 greeting',
- array(1 => $key)
- ));
+ [1 => $key]
+ ));
}
if ($greetingId) {
if (!$customGreeting && ($greetingId == array_search('Customized', $greetings))) {
throw new API_Exception(ts('Please provide a custom value for %1 greeting',
- array(1 => $key)
- ));
+ [1 => $key]
+ ));
}
}
elseif ($greetingVal) {
if (!in_array($greetingVal, $greetings)) {
- throw new API_Exception(ts('Invalid %1 greeting', array(1 => $key)));
+ throw new API_Exception(ts('Invalid %1 greeting', [1 => $key]));
}
$greetingId = CRM_Utils_Array::key($greetingVal, $greetings);
}
$customValue = isset($params['contact_id']) ? CRM_Core_DAO::getFieldValue(
- 'CRM_Contact_DAO_Contact',
- $params['contact_id'],
- "{$key}{$greeting}_custom"
- ) : FALSE;
+ 'CRM_Contact_DAO_Contact',
+ $params['contact_id'],
+ "{$key}{$greeting}_custom"
+ ) : FALSE;
if (array_key_exists("{$key}{$greeting}_id", $params) && empty($params["{$key}{$greeting}_id"])) {
$nullValue = TRUE;
$params['name']['type'] = CRM_Utils_Type::T_STRING;
$params['field']['type'] = CRM_Utils_Type::T_STRING;
$params['field']['title'] = ts('Field to search on');
- $params['field']['options'] = array(
+ $params['field']['options'] = [
'',
'id',
'contact_id',
'email',
'city',
'phone_numeric',
- );
+ ];
$params['table_name']['type'] = CRM_Utils_Type::T_STRING;
$params['table_name']['title'] = ts('Table alias to search on');
$params['table_name']['api.default'] = 'cc';
// get the option values for contact autocomplete
$acOptions = CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, FALSE, NULL, 'name');
- $list = $from = array();
+ $list = $from = [];
foreach ($acpref as $value) {
if ($value && !empty($acOptions[$value])) {
$list[$value] = $acOptions[$value];
elseif (strpos($field_name, 'custom_') === 0) {
$customField = civicrm_api3('CustomField', 'getsingle', [
'id' => substr($field_name, 7),
- 'return' => ['custom_group_id.table_name', 'column_name', 'data_type', 'option_group_id', 'html_type'],
+ 'return' => [
+ 'custom_group_id.table_name',
+ 'column_name',
+ 'data_type',
+ 'option_group_id',
+ 'html_type',
+ ],
]);
$field_name = $customField['column_name'];
$table_name = CRM_Utils_String::munge($customField['custom_group_id.table_name']);
$field_name = 'sort_name';
}
- $select = $actualSelectElements = array('sort_name');
- $where = '';
+ $select = $actualSelectElements = ['sort_name'];
+ $where = '';
foreach ($list as $value) {
$suffix = substr($value, 0, 2) . substr($value, -1);
switch ($value) {
case 'city':
case 'postal_code':
$selectText = $value;
- $value = "address";
- $suffix = 'sts';
+ $value = "address";
+ $suffix = 'sts';
case 'phone':
case 'email':
$actualSelectElements[] = $select[] = ($value == 'address') ? $selectText : $value;
}
$config = CRM_Core_Config::singleton();
- $as = $select;
+ $as = $select;
$select = implode(', ', $select);
if (!empty($select)) {
$select = ", $select";
// CRM-7157, hack: get current employer details when
// employee_id is present.
- $currEmpDetails = array();
+ $currEmpDetails = [];
if (!empty($params['employee_id'])) {
if ($currentEmployer = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
- (int) $params['employee_id'],
- 'employer_id'
- )) {
+ (int) $params['employee_id'],
+ 'employer_id'
+ )) {
if ($isPrependWildcard) {
$strSearch = "%$name%";
}
$dao = CRM_Core_DAO::executeQuery("SELECT cc.id as id, CONCAT_WS( ' :: ', {$actualSelectElements} ) as data, sort_name
FROM civicrm_contact cc {$from} WHERE cc.contact_type = \"Organization\" AND cc.id = {$currentEmployer} AND cc.sort_name LIKE '$strSearch'");
if ($dao->fetch()) {
- $currEmpDetails = array(
+ $currEmpDetails = [
'id' => $dao->id,
'data' => $dao->data,
- );
+ ];
}
}
}
$relType = NULL;
if (!empty($params['rel'])) {
$relation = explode('_', CRM_Utils_Array::value('rel', $params));
- $relType = CRM_Utils_Type::escape($relation[0], 'Integer');
- $rel = CRM_Utils_Type::escape($relation[2], 'String');
+ $relType = CRM_Utils_Type::escape($relation[0], 'Integer');
+ $rel = CRM_Utils_Type::escape($relation[2], 'String');
}
if ($isPrependWildcard) {
$dao = CRM_Core_DAO::executeQuery($query);
- $contactList = array();
+ $contactList = [];
$listCurrentEmployer = TRUE;
while ($dao->fetch()) {
- $t = array('id' => $dao->id);
+ $t = ['id' => $dao->id];
foreach ($as as $k) {
$t[$k] = isset($dao->$k) ? $dao->$k : '';
}
if (empty($contactList)) {
if (!empty($params['org'])) {
if ($listCurrentEmployer && !empty($currEmpDetails)) {
- $contactList = array(
- array(
+ $contactList = [
+ [
'data' => $currEmpDetails['data'],
- 'id' => $currEmpDetails['id'],
- ),
- );
+ 'id' => $currEmpDetails['id'],
+ ],
+ ];
}
else {
- $contactList = array(
- array(
+ $contactList = [
+ [
'data' => $name,
- 'id' => $name,
- ),
- );
+ 'id' => $name,
+ ],
+ ];
}
}
}
* Array of deprecated actions
*/
function _civicrm_api3_contact_deprecation() {
- return array('getquick' => 'The "getquick" action is deprecated in favor of "getlist".');
+ return ['getquick' => 'The "getquick" action is deprecated in favor of "getlist".'];
}
/**
* @throws API_Exception
*/
function civicrm_api3_contact_merge($params) {
- if (($result = CRM_Dedupe_Merger::merge(array(
- array(
+ if (($result = CRM_Dedupe_Merger::merge([
+ [
'srcID' => $params['to_remove_id'],
'dstID' => $params['to_keep_id'],
- ),
- ), array(), $params['mode'])) != FALSE) {
+ ],
+ ], [], $params['mode'])) != FALSE) {
return civicrm_api3_create_success($result, $params);
}
throw new API_Exception('Merge failed');
* @param array $params
*/
function _civicrm_api3_contact_merge_spec(&$params) {
- $params['to_remove_id'] = array(
+ $params['to_remove_id'] = [
'title' => 'ID of the contact to merge & remove',
'description' => ts('Wow - these 2 params are the logical reverse of what I expect - but what to do?'),
'api.required' => 1,
'type' => CRM_Utils_Type::T_INT,
- 'api.aliases' => array('main_id'),
- );
- $params['to_keep_id'] = array(
+ 'api.aliases' => ['main_id'],
+ ];
+ $params['to_keep_id'] = [
'title' => 'ID of the contact to keep',
'description' => ts('Wow - these 2 params are the logical reverse of what I expect - but what to do?'),
'api.required' => 1,
'type' => CRM_Utils_Type::T_INT,
- 'api.aliases' => array('other_id'),
- );
- $params['mode'] = array(
+ 'api.aliases' => ['other_id'],
+ ];
+ $params['mode'] = [
// @todo need more detail on what this means.
'title' => 'Dedupe mode',
'api.default' => 'safe',
- );
+ ];
}
/**
'sequential' => 1,
'options' => [
'limit' => 1,
- 'sort' => 'activity_id.activity_date_time DESC'
+ 'sort' => 'activity_id.activity_date_time DESC',
],
])['values'];
if (!empty($deleteActivity)) {
* @param array $params
*/
function _civicrm_api3_contact_proximity_spec(&$params) {
- $params['latitude'] = array(
+ $params['latitude'] = [
'title' => 'Latitude',
'api.required' => 1,
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['longitude'] = array(
+ ];
+ $params['longitude'] = [
'title' => 'Longitude',
'api.required' => 1,
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
- $params['unit'] = array(
+ $params['unit'] = [
'title' => 'Unit of Measurement',
'api.default' => 'meter',
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
}
/**
* @throws Exception
*/
function civicrm_api3_contact_proximity($params) {
- $latitude = CRM_Utils_Array::value('latitude', $params);
+ $latitude = CRM_Utils_Array::value('latitude', $params);
$longitude = CRM_Utils_Array::value('longitude', $params);
- $distance = CRM_Utils_Array::value('distance', $params);
+ $distance = CRM_Utils_Array::value('distance', $params);
$unit = CRM_Utils_Array::value('unit', $params);
";
$dao = CRM_Core_DAO::executeQuery($query);
- $contacts = array();
+ $contacts = [];
while ($dao->fetch()) {
$contacts[] = $dao->toArray();
}
// get the option values for contact autocomplete
$acOptions = CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, FALSE, NULL, 'name');
- $list = array();
+ $list = [];
foreach ($acpref as $value) {
if ($value && !empty($acOptions[$value])) {
$list[] = $acOptions[$value];
* @return array
*/
function _civicrm_api3_contact_getlist_output($result, $request) {
- $output = array();
+ $output = [];
if (!empty($result['values'])) {
- $addressFields = array_intersect(array(
- 'street_address',
- 'city',
- 'state_province',
- 'country',
- ),
+ $addressFields = array_intersect([
+ 'street_address',
+ 'city',
+ 'state_province',
+ 'country',
+ ],
$request['params']['return']);
foreach ($result['values'] as $row) {
- $data = array(
+ $data = [
'id' => $row[$request['id_field']],
'label' => $row[$request['label_field']],
- 'description' => array(),
- );
+ 'description' => [],
+ ];
foreach ($request['description_field'] as $item) {
if (!strpos($item, '_name') && !in_array($item, $addressFields) && !empty($row[$item])) {
$data['description'][] = $row[$item];
}
}
- $address = array();
+ $address = [];
foreach ($addressFields as $item) {
if (!empty($row[$item])) {
$address[] = $row[$item];
CRM_Utils_Array::value('check_permissions', $params),
CRM_Utils_Array::value('dedupe_rule_id', $params)
);
- $values = array();
+ $values = [];
if ($dupes && !empty($params['return'])) {
- return civicrm_api3('Contact', 'get', array(
+ return civicrm_api3('Contact', 'get', [
'return' => $params['return'],
- 'id' => array('IN' => $dupes),
+ 'id' => ['IN' => $dupes],
'options' => CRM_Utils_Array::value('options', $params),
'sequential' => CRM_Utils_Array::value('sequential', $params),
'check_permissions' => CRM_Utils_Array::value('check_permissions', $params),
- ));
+ ]);
}
foreach ($dupes as $dupe) {
- $values[$dupe] = array('id' => $dupe);
+ $values[$dupe] = ['id' => $dupe];
}
return civicrm_api3_create_success($values, $params, 'Contact', 'duplicatecheck');
}
* @param $params
*/
function _civicrm_api3_contact_duplicatecheck_spec(&$params) {
- $params['dedupe_rule_id'] = array(
+ $params['dedupe_rule_id'] = [
'title' => 'Dedupe Rule ID (optional)',
'description' => 'This will default to the built in unsupervised rule',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['rule_type'] = array(
+ ];
+ $params['rule_type'] = [
'title' => 'Dedupe Rule Type',
'description' => 'If no rule id specified, pass "Unsupervised" or "Supervised"',
'type' => CRM_Utils_Type::T_STRING,
'api.default' => 'Unsupervised',
- );
+ ];
// @todo declare 'match' parameter. We don't have a standard for type = array yet.
}