* @return string
*/
public static function getImage($contactType, $urlOnly = FALSE, $contactId = NULL, $addProfileOverlay = TRUE) {
- static $imageInfo = array();
+ static $imageInfo = [];
$contactType = CRM_Utils_Array::explodePadded($contactType);
$contactType = $contactType[0];
if (!array_key_exists($contactType, $imageInfo)) {
- $imageInfo[$contactType] = array();
+ $imageInfo[$contactType] = [];
- $typeInfo = array();
- $params = array('name' => $contactType);
+ $typeInfo = [];
+ $params = ['name' => $contactType];
CRM_Contact_BAO_ContactType::retrieve($params, $typeInfo);
if (!empty($typeInfo['image_URL'])) {
* max locations for the contact
*/
public static function maxLocations($contactId) {
- $contactLocations = array();
+ $contactLocations = [];
// find number of location blocks for this contact and adjust value accordinly
// get location type from email
public static function createCurrentEmployerRelationship($contactID, $organization, $previousEmployerID = NULL, $newContact = FALSE) {
//if organization name is passed. CRM-15368,CRM-15547
if ($organization && !is_numeric($organization)) {
- $dupeIDs = CRM_Contact_BAO_Contact::getDuplicateContacts(array('organization_name' => $organization), 'Organization', 'Unsupervised', array(), FALSE);
+ $dupeIDs = CRM_Contact_BAO_Contact::getDuplicateContacts(['organization_name' => $organization], 'Organization', 'Unsupervised', [], FALSE);
if (is_array($dupeIDs) && !empty($dupeIDs)) {
// we should create relationship only w/ first org CRM-4193
}
else {
//create new organization
- $newOrg = array(
+ $newOrg = [
'contact_type' => 'Organization',
'organization_name' => $organization,
- );
+ ];
$org = CRM_Contact_BAO_Contact::create($newOrg);
$organization = $org->id;
}
}
if ($organization && is_numeric($organization)) {
- $cid = array('contact' => $contactID);
+ $cid = ['contact' => $contactID];
// get the relationship type id of "Employee of"
$relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Employee of', 'id', 'name_a_b');
}
// create employee of relationship
- $relationshipParams = array(
+ $relationshipParams = [
'is_active' => TRUE,
'relationship_type_id' => $relTypeId . '_a_b',
- 'contact_check' => array($organization => TRUE),
- );
+ 'contact_check' => [$organization => TRUE],
+ ];
list($valid, $invalid, $duplicate, $saved, $relationshipIds)
= CRM_Contact_BAO_Relationship::legacyCreateMultiple($relationshipParams, $cid);
}
// set current employer
- self::setCurrentEmployer(array($contactID => $organization));
+ self::setCurrentEmployer([$contactID => $organization]);
$relationshipParams['relationship_ids'] = $relationshipIds;
// Handle related memberships. CRM-3792
* @throws CiviCRM_API3_Exception
*/
public static function currentEmployerRelatedMembership($contactID, $employerID, $relationshipParams, $duplicate = FALSE, $previousEmpID = NULL) {
- $ids = array();
+ $ids = [];
$action = CRM_Core_Action::ADD;
//we do not know that triggered relationship record is active.
if ($relationship->find(TRUE)) {
CRM_Contact_BAO_Relationship::setIsActive($relationship->id, FALSE);
CRM_Contact_BAO_Relationship::relatedMemberships($contactId, $relMembershipParams,
- $ids = array(),
+ $ids = [],
CRM_Core_Action::DELETE
);
}
default:
// individual
$form->addElement('select', 'prefix_id', ts('Prefix'),
- array('' => ts('- prefix -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id')
+ ['' => ts('- prefix -')] + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id')
);
$form->addElement('text', 'first_name', ts('First Name'),
$attributes['first_name']
$attributes['last_name']
);
$form->addElement('select', 'suffix_id', ts('Suffix'),
- array('' => ts('- suffix -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id')
+ ['' => ts('- suffix -')] + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id')
);
}
* returns array with links to contact view
*/
public static function formatContactIDSToLinks($contactIDs, $addViewLink = TRUE, $addEditLink = TRUE, $originalId = NULL) {
- $contactLinks = array();
+ $contactLinks = [];
if (!is_array($contactIDs) || empty($contactIDs)) {
return $contactLinks;
}
// does contact has sufficient permissions.
- $permissions = array(
+ $permissions = [
'view' => 'view all contacts',
'edit' => 'edit all contacts',
'merge' => 'merge duplicate contacts',
- );
+ ];
- $permissionedContactIds = array();
+ $permissionedContactIds = [];
foreach ($permissions as $task => $permission) {
// give permission.
if (CRM_Core_Permission::check($permission)) {
}
// check permission on acl basis.
- if (in_array($task, array(
+ if (in_array($task, [
'view',
'edit',
- ))) {
+ ])) {
$aclPermission = CRM_Core_Permission::VIEW;
if ($task == 'edit') {
$aclPermission = CRM_Core_Permission::EDIT;
* @return array
* array of contact info.
*/
- public static function contactDetails($componentIds, $componentName, $returnProperties = array()) {
- $contactDetails = array();
+ public static function contactDetails($componentIds, $componentName, $returnProperties = []) {
+ $contactDetails = [];
if (empty($componentIds) ||
- !in_array($componentName, array('CiviContribute', 'CiviMember', 'CiviEvent', 'Activity', 'CiviCase'))
+ !in_array($componentName, ['CiviContribute', 'CiviMember', 'CiviEvent', 'Activity', 'CiviCase'])
) {
return $contactDetails;
}
$autocompleteContactSearch = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'contact_autocomplete_options'
);
- $returnProperties = array_fill_keys(array_merge(array('sort_name'),
+ $returnProperties = array_fill_keys(array_merge(['sort_name'],
array_keys($autocompleteContactSearch)
), 1);
}
$compTable = 'civicrm_participant';
}
- $select = $from = array();
+ $select = $from = [];
foreach ($returnProperties as $property => $ignore) {
- $value = (in_array($property, array(
+ $value = (in_array($property, [
'city',
'street_address',
'postal_code',
- ))) ? 'address' : $property;
+ ])) ? 'address' : $property;
switch ($property) {
case 'sort_name':
if ($componentName == 'Activity') {
$fromClause = implode(' ', $from);
$selectClause = implode(', ', $select);
$whereClause = "{$compTable}.id IN (" . implode(',', $componentIds) . ')';
- $groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($select, array("{$compTable}.id", 'contact.id'));
+ $groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($select, ["{$compTable}.id", 'contact.id']);
$query = "
SELECT contact.id as contactId, $compTable.id as componentId, $selectClause
// Normal update process will automatically create new address with submitted values
// 1. loop through entire submitted address array
- $skipFields = array('is_primary', 'location_type_id', 'is_billing', 'master_id', 'update_current_employer');
+ $skipFields = ['is_primary', 'location_type_id', 'is_billing', 'master_id', 'update_current_employer'];
foreach ($address as & $values) {
// 2. check if "Use another contact's address" is checked, if not continue
// Additionally, if master_id is set (address was shared), set master_id to empty value.
* associated array of contact names
*/
public static function getAddressShareContactNames(&$addresses) {
- $contactNames = array();
+ $contactNames = [];
// get the list of master id's for address
- $masterAddressIds = array();
+ $masterAddressIds = [];
foreach ($addresses as $key => $addressValue) {
if (!empty($addressValue['master_id'])) {
$masterAddressIds[] = $addressValue['master_id'];
while ($dao->fetch()) {
$contactViewUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->cid}");
- $contactNames[$dao->id] = array(
+ $contactNames[$dao->id] = [
'name' => "<a href='{$contactViewUrl}'>{$dao->display_name}</a>",
'is_deleted' => $dao->is_deleted,
'contact_id' => $dao->cid,
- );
+ ];
}
}
return $contactNames;
$valueID = $id = self::defaultGreeting($contactType, $greeting);
}
- $filter = array(
+ $filter = [
'contact_type' => $contactType,
'greeting_type' => $greeting,
- );
+ ];
$allGreetings = CRM_Core_PseudoConstant::greeting($filter);
$originalGreetingString = $greetingString = CRM_Utils_Array::value($valueID, $allGreetings);
if (!$greetingString) {
- CRM_Core_Error::fatal(ts('Incorrect greeting value id %1, or no default greeting for this contact type and greeting type.', array(1 => $valueID)));
+ CRM_Core_Error::fatal(ts('Incorrect greeting value id %1, or no default greeting for this contact type and greeting type.', [1 => $valueID]));
}
// build return properties based on tokens
$greetingTokens = CRM_Utils_Token::getTokens($greetingString);
$tokens = CRM_Utils_Array::value('contact', $greetingTokens);
- $greetingsReturnProperties = array();
+ $greetingsReturnProperties = [];
if (is_array($tokens)) {
$greetingsReturnProperties = array_fill_keys(array_values($tokens), 1);
}
}
//FIXME : apiQuery should handle these clause.
- $filterContactFldIds = $filterIds = array();
+ $filterContactFldIds = $filterIds = [];
$idFldName = $displayFldName = NULL;
if (in_array($greeting, CRM_Contact_BAO_Contact::$_greetingTypes)) {
$idFldName = $greeting . '_id';
}
if ($idFldName) {
- $queryParams = array(1 => array($contactType, 'String'));
+ $queryParams = [1 => [$contactType, 'String']];
// if $force == 1 then update all contacts else only
// those with NULL greeting or addressee value CRM-9476
FROM civicrm_contact
WHERE contact_type = %1
AND ({$idFldName} IS NULL
- OR ( {$idFldName} IS NOT NULL AND ({$displayFldName} IS NULL OR {$displayFldName} = '')) )";
+ OR ( {$idFldName} IS NOT NULL AND ({$displayFldName} IS NULL OR {$displayFldName} = '')) ) LIMIT 800";
}
if ($limit) {
$sql .= " LIMIT 0, %2";
- $queryParams += array(2 => array($limit, 'Integer'));
+ $queryParams += [2 => [$limit, 'Integer']];
}
$dao = CRM_Core_DAO::executeQuery($sql, $queryParams);
}
// retrieve only required contact information
- $extraParams[] = array('contact_type', '=', $contactType, 0, 0);
+ $extraParams[] = ['contact_type', '=', $contactType, 0, 0];
// we do token replacement in the replaceGreetingTokens hook
list($greetingDetails) = CRM_Utils_Token::getTokenDetails(array_keys($filterContactFldIds),
$greetingsReturnProperties,
FALSE, FALSE, $extraParams
);
// perform token replacement and build update SQL
- $contactIds = array();
+ $contactIds = [];
$cacheFieldQuery = "UPDATE civicrm_contact SET {$greeting}_display = CASE id ";
foreach ($greetingDetails as $contactID => $contactDetails) {
if (!$processAll &&
* @return int|NULL
*/
public static function defaultGreeting($contactType, $greetingType) {
- $contactTypeFilters = array(
+ $contactTypeFilters = [
'Individual' => 1,
'Household' => 2,
'Organization' => 3,
- );
+ ];
if (!isset($contactTypeFilters[$contactType])) {
return NULL;
}
* Array of tokens. The ALL ke
*/
public static function getTokensRequiredForContactGreetings($contactParams) {
- $tokens = array();
- foreach (array('addressee', 'email_greeting', 'postal_greeting') as $greeting) {
+ $tokens = [];
+ foreach (['addressee', 'email_greeting', 'postal_greeting'] as $greeting) {
$string = '';
if (!empty($contactParams[$greeting . '_id'])) {
$string = CRM_Core_PseudoConstant::getLabel('CRM_Contact_BAO_Contact', $greeting . '_id', $contactParams[$greeting . '_id']);
}
$string = isset($contactParams[$greeting . '_custom']) ? $contactParams[$greeting . '_custom'] : $string;
if (empty($string)) {
- $tokens[$greeting] = array();
+ $tokens[$greeting] = [];
}
else {
$tokens[$greeting] = CRM_Utils_Token::getTokens($string);