unset($params['preferred_communication_method']);
}
- $defaults = ['source' => CRM_Utils_Array::value('contact_source', $params)];
+ $defaults = ['source' => $params['contact_source'] ?? NULL];
if ($params['contact_type'] === 'Organization' && isset($params['organization_name'])) {
$defaults['display_name'] = $params['organization_name'];
$defaults['sort_name'] = $params['organization_name'];
}
$privacy = $params['privacy'] ?? NULL;
- if ($privacy &&
- is_array($privacy) &&
- !empty($privacy)
- ) {
+ if ($privacy && is_array($privacy)) {
$allNull = FALSE;
foreach (self::$_commPrefs as $name) {
- $contact->$name = CRM_Utils_Array::value($name, $privacy, FALSE);
+ $contact->$name = $privacy[$name] ?? FALSE;
}
}
if ($contact->contact_type === 'Individual' && (isset($params['current_employer']) || isset($params['employer_id']))) {
// Create current employer.
- $newEmployer = !empty($params['employer_id']) ? $params['employer_id'] : CRM_Utils_Array::value('current_employer', $params);
+ $newEmployer = !empty($params['employer_id']) ? $params['employer_id'] : $params['current_employer'] ?? NULL;
- $newContact = FALSE;
- if (empty($params['contact_id'])) {
- $newContact = TRUE;
- }
+ $newContact = empty($params['contact_id']);
if ($newEmployer) {
CRM_Contact_BAO_Contact_Utils::createCurrentEmployerRelationship($contact->id, $newEmployer, $employerId, $newContact);
}
- else {
- if ($employerId) {
- CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer($contact->id, $employerId);
- }
+ elseif ($employerId) {
+ CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer($contact->id, $employerId);
}
}
$currentUser = CRM_Core_Session::getLoggedInContactID();
$editOwn = $currentUser && CRM_Core_Permission::check('edit own api keys');
foreach ($contacts as &$contact) {
- $cid = is_object($contact) ? $contact->id : CRM_Utils_Array::value('id', $contact);
+ $cid = is_object($contact) ? $contact->id : $contact['id'] ?? NULL;
if (!($editOwn && $cid == $currentUser)) {
if (is_object($contact)) {
unset($contact->api_key);
$reverse
);
}
- $stateProvinceID = self::resolveStateProvinceID($values, CRM_Utils_Array::value('country_id', $values));
+ $stateProvinceID = self::resolveStateProvinceID($values, $values['country_id'] ?? NULL);
if ($stateProvinceID) {
$values['state_province_id'] = $stateProvinceID;
}
$cacheKeyString .= $checkPermission ? '_1' : '_0';
$cacheKeyString .= '_' . CRM_Core_Config::domainID() . '_';
- $fields = CRM_Utils_Array::value($cacheKeyString, self::$_importableFields) ?: Civi::cache('fields')->get($cacheKeyString);
+ $fields = self::$_importableFields[$cacheKeyString] ?? Civi::cache('fields')->get($cacheKeyString);
if (!$fields) {
$fields = CRM_Contact_DAO_Contact::import();
//as an interim fix we will cache the fields by contact
$cacheKeyString .= '_' . CRM_Core_Session::getLoggedInContactID();
- if (!self::$_exportableFields || !CRM_Utils_Array::value($cacheKeyString, self::$_exportableFields)) {
+ if (!self::$_exportableFields || empty(self::$_exportableFields[$cacheKeyString])) {
if (!self::$_exportableFields) {
self::$_exportableFields = [];
}
// manage is_opt_out
if (array_key_exists('is_opt_out', $fields) && array_key_exists('is_opt_out', $params)) {
- $wasOptOut = CRM_Utils_Array::value('is_opt_out', $contactDetails, FALSE);
- $isOptOut = CRM_Utils_Array::value('is_opt_out', $params, FALSE);
+ $wasOptOut = $contactDetails['is_opt_out'] ?? FALSE;
+ $isOptOut = $params['is_opt_out'];
$data['is_opt_out'] = $isOptOut;
// on change, create new civicrm_subscription_history entry
if (($wasOptOut != $isOptOut) && !empty($contactDetails['contact_id'])) {
'url' => CRM_Utils_System::url('civicrm/profile/create', "reset=1&context=dialog&gid=$id",
NULL, NULL, FALSE, FALSE, TRUE),
'type' => ucfirst(str_replace('new_', '', $profile['name'])),
- 'icon' => CRM_Utils_Array::value(str_replace('new_', '', $profile['name']), $icons),
+ 'icon' => $icons[str_replace('new_', '', $profile['name'])] ?? NULL,
];
}
else {