$values['target_contact_value'] = $values['target_contact_value'] ?? NULL;
// Get the campaign.
- if ($campaignId = CRM_Utils_Array::value('campaign_id', $defaults)) {
+ $campaignId = $defaults['campaign_id'] ?? NULL;
+ if ($campaignId) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
- if ($engagementLevel = CRM_Utils_Array::value('engagement_level', $defaults)) {
+ $engagementLevel = $defaults['engagement_level'] ?? NULL;
+ if ($engagementLevel) {
$engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
$values['engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
}
$row['status'] = $row['status_id'] ? $activityStatus[$row['status_id']] : NULL;
- if ($engagementLevel = CRM_Utils_Array::value('engagement_level', $row)) {
+ $engagementLevel = $row['engagement_level'] ?? NULL;
+ if ($engagementLevel) {
$row['engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
}
$row['campaign'] = $allCampaigns[$result->activity_campaign_id] ?? NULL;
$row['campaign_id'] = $result->activity_campaign_id;
- if ($engagementLevel = CRM_Utils_Array::value('activity_engagement_level', $row)) {
+ $engagementLevel = $row['activity_engagement_level'] ?? NULL;
+ if ($engagementLevel) {
$row['activity_engagement_level'] = CRM_Utils_Array::value($engagementLevel,
$engagementLevels, $engagementLevel
);
$defaults['entity'] = $entityStatus;
}
- if ($recipientListing = CRM_Utils_Array::value('recipient_listing', $defaults)) {
+ $recipientListing = $defaults['recipient_listing'] ?? NULL;
+ if ($recipientListing) {
$defaults['recipient_listing'] = explode(CRM_Core_DAO::VALUE_SEPARATOR,
$recipientListing
);
$defaults['recipient'] = 'manual';
$defaults['recipient_manual_id'] = $defaults['recipient_manual'];
}
- if ($contactLanguage = CRM_Utils_Array::value('filter_contact_language', $defaults)) {
+ $contactLanguage = $defaults['filter_contact_language'] ?? NULL;
+ if ($contactLanguage) {
$defaults['filter_contact_language'] = explode(CRM_Core_DAO::VALUE_SEPARATOR, $contactLanguage);
}
}
$this->_resultOptions = $this->get('resultOptions');
if (!is_array($this->_resultOptions)) {
$this->_resultOptions = [];
- if ($resultOptionId = CRM_Utils_Array::value('result_id', $this->_surveyValues)) {
+ $resultOptionId = $this->_surveyValues['result_id'] ?? NULL;
+ if ($resultOptionId) {
$this->_resultOptions = CRM_Core_OptionGroup::valuesByID($resultOptionId);
}
$this->set('resultOptions', $this->_resultOptions);
if (isset($id) && array_key_exists($id, $this->_relatedContacts) && isset($this->_relatedContacts[$id]['email'])) {
//if email already exists in array then append with ', ' another role only otherwise add it to array.
- if ($contactDetails = CRM_Utils_Array::value($this->_relatedContacts[$id]['email'], $mailToContacts)) {
+ $contactDetails = $mailToContacts[$this->_relatedContacts[$id]['email']] ?? NULL;
+ if ($contactDetails) {
$caseRole = $this->_relatedContacts[$id]['role'] ?? NULL;
$mailToContacts[$this->_relatedContacts[$id]['email']]['role'] = $contactDetails['role'] . ', ' . $caseRole;
}
$contactIds[] = $contactID;
}
else {
- if ($greetingBuffer = CRM_Utils_Array::value($filterContactFldIds[$contactID], $allGreetings)) {
+ $greetingBuffer = $allGreetings[$filterContactFldIds[$contactID]] ?? NULL;
+ if ($greetingBuffer) {
$greetingString = $greetingBuffer;
}
}
$typeValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $key);
$cType = $typeValue['0'] ?? NULL;
$typeUrl = 'ct=' . $cType;
- if ($csType = CRM_Utils_Array::value('1', $typeValue)) {
+ $csType = $typeValue['1'] ?? NULL;
+ if ($csType) {
$typeUrl .= "&cst=$csType";
}
$shortCut = [
'ref' => "new-$value",
'title' => $value,
];
- if ($csType = CRM_Utils_Array::value('1', $typeValue)) {
+ $csType = $typeValue['1'] ?? NULL;
+ if ($csType) {
$shortCuts[$cType]['shortCuts'][] = $shortCut;
}
else {
$params[5] = [$parent_id, 'Integer'];
}
- if ($createdBy = CRM_Utils_Array::value('created_by', $params)) {
+ $createdBy = $params['created_by'] ?? NULL;
+ if ($createdBy) {
$clauses[] = "createdBy.sort_name LIKE %6";
if (strpos($createdBy, '%') !== FALSE) {
$params[6] = [$createdBy, 'String', FALSE];
}
}
elseif ($id === 'email_on_hold') {
- if ($onHoldValue = CRM_Utils_Array::value('email_on_hold', $formValues)) {
+ $onHoldValue = $formValues['email_on_hold'] ?? NULL;
+ if ($onHoldValue) {
// onHoldValue should be 0 or 1 or an array. Some legacy groups may hold ''
// so in 5.11 we have an extra if that should become redundant over time.
// https://lab.civicrm.org/dev/core/issues/745
continue;
}
+ $baoName = $value['bao'] ?? NULL;
if (CRM_Utils_System::isNull($val)) {
$dao->$key = NULL;
}
$dao->$key = CRM_Core_PseudoConstant::getLabel($value['bao'], $value['idCol'], $val);
}
}
- elseif ($baoName = CRM_Utils_Array::value('bao', $value, NULL)) {
+ elseif ($baoName) {
//preserve id value
$idColumn = "{$key}_id";
$dao->$idColumn = $val;
' AND contact_id_b = ' . CRM_Utils_Type::escape($id, 'Integer') . " ) ) ";
//if caseId is provided, include it duplicate checking.
- if ($caseId = CRM_Utils_Array::value('case_id', $params)) {
+ $caseId = $params['case_id'] ?? NULL;
+ if ($caseId) {
$queryString .= ' AND case_id = ' . CRM_Utils_Type::escape($caseId, 'Integer');
}
if (!empty($_POST['hidden_custom'])) {
$customGroupCount = $_POST['hidden_custom_group_count'] ?? NULL;
- if ($contactSubType = CRM_Utils_Array::value('contact_sub_type', $_POST)) {
+ $contactSubType = $_POST['contact_sub_type'] ?? NULL;
+ if ($contactSubType) {
$paramSubType = implode(',', $contactSubType);
}
) {
$invalidStreetNumbers = [];
foreach ($fields['address'] as $cnt => $address) {
- if ($streetNumber = CRM_Utils_Array::value('street_number', $address)) {
+ $streetNumber = $address['street_number'] ?? NULL;
+ if ($streetNumber) {
$parsedAddress = CRM_Core_BAO_Address::parseStreetAddress($address['street_number']);
if (empty($parsedAddress['street_number'])) {
$invalidStreetNumbers[] = $cnt;
//contact type for pick up profiles as per selected contact types with subtypes
//CRM-5521
- if ($selectedTypes = CRM_Utils_Array::value('contact_type', self::$_searchFormValues)) {
+ $selectedTypes = self::$_searchFormValues['contact_type'] ?? NULL;
+ if ($selectedTypes) {
if (!is_array($selectedTypes)) {
$selectedTypes = explode(' ', $selectedTypes);
}
// format the addresses according to CIVICRM_ADDRESS_FORMAT (CRM-1327)
foreach ($rows as $id => $row) {
- if ($commMethods = CRM_Utils_Array::value('preferred_communication_method', $row)) {
+ $commMethods = $row['preferred_communication_method'] ?? NULL;
+ if ($commMethods) {
$val = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $commMethods));
$comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
$temp = [];
//Modify mapper fields title if fields are present in dedupe rule
if (is_array($this->_dedupeFields[$contactType])) {
foreach ($this->_dedupeFields[$contactType] as $val) {
- if ($valTitle = CRM_Utils_Array::value($val, $this->_mapperFields)) {
+ $valTitle = $this->_mapperFields[$val] ?? NULL;
+ if ($valTitle) {
$this->_mapperFields[$val] = $valTitle . ' (match to contact)';
}
}
static $cTypeArray = [];
if ($relatedContactType !== $this->getContactType() && !in_array($relatedContactType, $cTypeArray)) {
foreach ($this->_dedupeFields[$relatedContactType] as $val) {
- if ($valTitle = CRM_Utils_Array::value($val, $this->_formattedFieldNames[$relatedContactType])) {
+ $valTitle = $this->_formattedFieldNames[$relatedContactType][$val] ?? NULL;
+ if ($valTitle) {
$this->_formattedFieldNames[$relatedContactType][$val] = $valTitle . ' (match to contact)';
}
}
//profile is of Individual ( including the custom data of membership/contribution )
//IF Individual type not present in profile then it is consider as Organization data.
$userID = $contactID;
- if ($preID = CRM_Utils_Array::value('custom_pre_id', $values)) {
+ $preID = $values['custom_pre_id'] ?? NULL;
+ if ($preID) {
if (!empty($values['related_contact'])) {
$preProfileTypes = CRM_Core_BAO_UFGroup::profileGroups($preID);
if (in_array('Individual', $preProfileTypes) || in_array('Contact', $preProfileTypes)) {
[$values['customPre_grouptitle'], $values['customPre']] = self::getProfileNameAndFields($preID, $userID, $params['custom_pre_id']);
}
$userID = $contactID;
- if ($postID = CRM_Utils_Array::value('custom_post_id', $values)) {
+ $postID = $values['custom_post_id'] ?? NULL;
+ if ($postID) {
if (!empty($values['related_contact'])) {
$postProfileTypes = CRM_Core_BAO_UFGroup::profileGroups($postID);
if (in_array('Individual', $postProfileTypes) || in_array('Contact', $postProfileTypes)) {
$tplParams['contributionTypeName'] = $tplParams['financialTypeName'];
}
- if ($contributionPageId = CRM_Utils_Array::value('id', $values)) {
+ $contributionPageId = $values['id'] ?? NULL;
+ if ($contributionPageId) {
$tplParams['contributionPageId'] = $contributionPageId;
}
// address required during receipt processing (pdf and email receipt)
- if ($displayAddress = CRM_Utils_Array::value('address', $values)) {
+ $displayAddress = $values['address'] ?? NULL;
+ if ($displayAddress) {
$tplParams['address'] = $displayAddress;
}
$this->assign('organisationId', $contactID);
}
- if ($parentId = CRM_Utils_Array::value('parent_id', $defaults)) {
+ $parentId = $defaults['parent_id'] ?? NULL;
+ if ($parentId) {
$this->assign('parentId', $parentId);
}
}
if ($pledgePaymentId) {
$buildPriceSet = FALSE;
}
- if ($participantID = CRM_Utils_Array::value('participant', $componentDetails)) {
+ $participantID = $componentDetails['participant'] ?? NULL;
+ if ($participantID) {
$participantLI = CRM_Price_BAO_LineItem::getLineItems($participantID);
if (!CRM_Utils_System::isNull($participantLI)) {
$buildPriceSet = FALSE;
// Do the amount validations.
if (empty($fields['total_amount']) && empty($self->_lineItems)) {
- if ($priceSetId = CRM_Utils_Array::value('price_set_id', $fields)) {
+ $priceSetId = $fields['price_set_id'] ?? NULL;
+ if ($priceSetId) {
CRM_Price_BAO_PriceField::priceSetValidation($priceSetId, $fields, $errors);
}
}
}
$qParams = "reset=1&id={$this->_id}";
- if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
+ $pcpId = $this->_pcpInfo['pcp_id'] ?? NULL;
+ if ($pcpId) {
$qParams .= "&pcpId={$pcpId}";
}
$this->assign('qParams', $qParams);
}
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
- if ($greetingType = CRM_Utils_Array::value($greeting, $fields)) {
+ $greetingType = $fields[$greeting] ?? NULL;
+ if ($greetingType) {
$customizedValue = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greeting . '_id', 'Customized');
if ($customizedValue == $greetingType && empty($fielse[$greeting . '_custom'])) {
$errors[$greeting . '_custom'] = ts('Custom %1 is a required field if %1 is of type Customized.',
$this->set('amount_level', CRM_Utils_Array::value('amount_level', $params));
}
+ $priceSetId = $params['priceSetId'] ?? NULL;
if (!empty($this->_ccid)) {
$this->set('lineItem', [$this->getPriceSetID() => $this->getExistingContributionLineItems()]);
}
- elseif ($priceSetId = CRM_Utils_Array::value('priceSetId', $params)) {
+ elseif ($priceSetId) {
$lineItem = [];
if ($this->isQuickConfig()) {
foreach ($this->_values['fee'] as $key => & $val) {
}
// don't allow price set w/ membership signup, CRM-5095
- if ($priceSetId = CRM_Utils_Array::value('price_set_id', $fields)) {
+ $priceSetId = $fields['price_set_id'] ?? NULL;
+ if ($priceSetId) {
// don't allow price set w/ membership.
if ($hasMembershipBlk) {
$errors['price_set_id'] = ts('You cannot enable both a Contribution Price Set and Membership Signup on the same online contribution page.');
$priceSetId = $usedPriceSetId;
}
else {
- if ($priceFieldId = CRM_Utils_Array::value('price_field_id', $params)) {
+ $priceFieldId = $params['price_field_id'] ?? NULL;
+ if ($priceFieldId) {
foreach ($params['price_field_value'] as $arrayID => $fieldValueID) {
if (empty($params['label'][$arrayID]) && empty($params['value'][$arrayID]) && !empty($fieldValueID)) {
CRM_Price_BAO_PriceFieldValue::setIsActive($fieldValueID, '0');
CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
- if (!$priceFieldID = CRM_Utils_Array::value('id', $editedResults)) {
+ $priceFieldID = $editedResults['id'] ?? NULL;
+ if (!$priceFieldID) {
$fieldParams = [
'name' => 'other_amount',
'label' => ts('Other Amount'),
//do check for campaigns
$values['campaign'] = '';
- if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
+ $campaignId = $values['campaign_id'] ?? NULL;
+ if ($campaignId) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
];
foreach ($billing as $key => $val) {
- if ($value = CRM_Utils_Array::value($val, $params)) {
+ $value = $params[$val] ?? NULL;
+ if ($value) {
if (!empty($params[$key])) {
unset($params[$val]);
}
}
$default = array_merge(['Contact'], CRM_Contact_BAO_ContactType::basicTypes(TRUE));
- if (!($type = CRM_Utils_Array::value('entityType', $params)) ||
- in_array($params['entityType'], $default)
- ) {
+ $type = $params['entityType'] ?? NULL;
+ if (!$type || in_array($params['entityType'], $default)) {
$type = NULL;
}
else {
) {
/* re/calculate the weight, if the Parent ID changed OR create new menu */
- if ($navName = CRM_Utils_Array::value('name', $params)) {
+ $navName = $params['name'] ?? NULL;
+ $navLabel = $params['label'] ?? NULL;
+ if ($navName) {
$params['name'] = $navName;
}
- elseif ($navLabel = CRM_Utils_Array::value('label', $params)) {
+ elseif ($navLabel) {
$params['name'] = $navLabel;
}
public static function lookupValues(&$params, $names, $flip = FALSE) {
foreach ($names as $postName => $value) {
// See if $params field is in $names array (i.e. is a value that we need to lookup)
- if ($postalName = CRM_Utils_Array::value($postName, $params)) {
+ $postalName = $params[$postName] ?? NULL;
+ if ($postalName) {
$postValues = [];
// params[$postName] may be a Ctrl+A separated value list
if (is_string($postalName) &&
* @return int
*/
public static function getCreditCardExpirationMonth($src) {
- if ($month = CRM_Utils_Array::value('M', $src['credit_card_exp_date'])) {
+ $month = $src['credit_card_exp_date']['M'] ?? NULL;
+ if ($month) {
return $month;
}
}
// CRM-15681 merge sub_types
- if ($other_sub_types = CRM_Utils_Array::value('contact_sub_type', $migrationInfo['other_details'])) {
- if ($main_sub_types = CRM_Utils_Array::value('contact_sub_type', $migrationInfo['main_details'])) {
+ $other_sub_types = $migrationInfo['other_details']['contact_sub_type'] ?? NULL;
+ $main_sub_types = $migrationInfo['main_details']['contact_sub_type'] ?? NULL;
+ if ($other_sub_types) {
+ if ($main_sub_types) {
$submitted['contact_sub_type'] = array_unique(array_merge($main_sub_types, $other_sub_types));
}
else {
];
// address required during receipt processing (pdf and email receipt)
- if ($displayAddress = CRM_Utils_Array::value('address', $values)) {
+ $displayAddress = $values['address'] ?? NULL;
+ if ($displayAddress) {
$sendTemplateParams['tplParams']['address'] = $displayAddress;
// The concept of contributeMode is deprecated.
$sendTemplateParams['tplParams']['contributeMode'] = NULL;
}
// set lineItem details
- if ($lineItem = CRM_Utils_Array::value('lineItem', $values)) {
+ $lineItem = $values['lineItem'] ?? NULL;
+ if ($lineItem) {
// check if additional participant, if so filter only to relevant ones
// CRM-9902
if (!empty($values['params']['additionalParticipant'])) {
if ($contactID) {
$params = ['contact_id' => $contactID];
- if ($eventId = CRM_Utils_Array::value('id', $values['event'])) {
+ $eventId = $values['event']['id'] ?? NULL;
+ if ($eventId) {
$params['event_id'] = $eventId;
}
- if ($roleId = CRM_Utils_Array::value('default_role_id', $values['event'])) {
+ $roleId = $values['event']['default_role_id'] ?? NULL;
+ if ($roleId) {
$params['role_id'] = $roleId;
}
$alreadyRegistered = self::checkRegistration($params);
$urlParams = "id={$this->_id}&addProfileBottom=1&qfKey={$this->controller->_key}";
$this->assign('addProfileParams', $urlParams);
- if ($addProfileBottom = CRM_Utils_Array::value('custom_post_id_multiple', $_POST)) {
+ $addProfileBottom = $_POST['custom_post_id_multiple'] ?? NULL;
+ if ($addProfileBottom) {
foreach (array_keys($addProfileBottom) as $profileNum) {
self::buildMultipleProfileBottom($this, $profileNum);
}
$urlParamsAdd = "id={$this->_id}&addProfileBottomAdd=1&qfKey={$this->controller->_key}";
$this->assign('addProfileParamsAdd', $urlParamsAdd);
- if ($addProfileBottomAdd = CRM_Utils_Array::value('additional_custom_post_id_multiple', $_POST)) {
+ $addProfileBottomAdd = $_POST['additional_custom_post_id_multiple'] ?? NULL;
+ if ($addProfileBottomAdd) {
foreach (array_keys($addProfileBottomAdd) as $profileNum) {
self::buildMultipleProfileBottom($this, $profileNum, 'additional_', ts('Profile for Additional Participants'));
}
* @param string $field
*/
public static function addMultipleProfiles(&$profileIds, $values, $field) {
- if ($multipleProfiles = CRM_Utils_Array::value($field, $values)) {
+ $multipleProfiles = $values[$field] ?? NULL;
+ if ($multipleProfiles) {
foreach ($multipleProfiles as $profileId) {
$profileIds[] = $profileId;
}
) ||
($self->_id && !$self->_paymentId && isset($self->_values['line_items']) && is_array($self->_values['line_items']))
) {
- if ($priceSetId = CRM_Utils_Array::value('priceSetId', $values)) {
+ $priceSetId = $values['priceSetId'] ?? NULL;
+ if ($priceSetId) {
CRM_Price_BAO_PriceField::priceSetValidation($priceSetId, $values, $errorMsg, TRUE);
}
}
$this->_contributorDisplayName = ($this->_contributorDisplayName == ' ') ? $this->_contributorEmail : $this->_contributorDisplayName;
$waitStatus = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
- if ($waitingStatus = CRM_Utils_Array::value($params['status_id'], $waitStatus)) {
+ $waitingStatus = $waitStatus[$params['status_id']] ?? NULL;
+ if ($waitingStatus) {
$this->assign('isOnWaitlist', TRUE);
}
}
//do check for campaigns
- if ($campaignId = CRM_Utils_Array::value('campaign_id', $values[$participantID])) {
+ $campaignId = $values[$participantID]['campaign_id'] ?? NULL;
+ if ($campaignId) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values[$participantID]['campaign'] = $campaigns[$campaignId];
}
}
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
- if ($greetingType = CRM_Utils_Array::value($greeting, $self->_params[0])) {
+ $greetingType = $self->_params[0][$greeting] ?? NULL;
+ if ($greetingType) {
$customizedValue = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greeting . '_id', 'Customized');
if ($customizedValue == $greetingType && empty($self->_params[0][$greeting . '_custom'])) {
return FALSE;
}
}
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
- if ($greetingType = CRM_Utils_Array::value($greeting, $fields)) {
+ $greetingType = $fields[$greeting] ?? NULL;
+ if ($greetingType) {
$customizedValue = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greeting . '_id', 'Customized');
if ($customizedValue == $greetingType && empty($fields[$greeting . '_custom'])) {
$errors[$greeting . '_custom'] = ts('Custom %1 is a required field if %1 is of type Customized.',
}
if (!empty($this->_formValues['participant_status_id'])) {
$seatClause[] = CRM_Contact_BAO_Query::buildClause("participant.status_id", 'IN', $this->_formValues['participant_status_id'], 'Int');
- if ($status = CRM_Utils_Array::value('IN', $this->_formValues['participant_status_id'])) {
+ $status = $this->_formValues['participant_status_id']['IN'] ?? NULL;
+ if ($status) {
$this->_formValues['participant_status_id'] = $status;
}
}
if (empty($values['total_amount']) &&
empty($self->_values['line_items'])
) {
- if ($priceSetId = CRM_Utils_Array::value('priceSetId', $values)) {
+ $priceSetId = $values['priceSetId'] ?? NULL;
+ if ($priceSetId) {
CRM_Price_BAO_PriceField::priceSetValidation($priceSetId, $values, $errorMsg, TRUE);
}
}
}
$logTypeTableClause = '(1)';
- if ($logTypeTableValue = CRM_Utils_Array::value("log_type_table_value", $this->_params)) {
+ $logTypeTableValue = $this->_params["log_type_table_value"] ?? NULL;
+ if ($logTypeTableValue) {
$logTypeTableClause = $this->whereClause($this->_columns['log_civicrm_entity']['filters']['log_type_table'],
$this->_params['log_type_table_op'], $logTypeTableValue, NULL, NULL);
unset($this->_params['log_type_table_value']);
}
//get the campaign
- if ($campaignId = CRM_Utils_Array::value('campaign_id', $report['mailing'])) {
+ $campaignId = $report['mailing']['campaign_id'] ?? NULL;
+ if ($campaignId) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$report['mailing']['campaign'] = $campaigns[$campaignId];
}
$values['auto_renew'] = ($autoRenew && !$subscriptionCancelled) ? 'Yes' : 'No';
//do check for campaigns
- if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
+ $campaignId = $values['campaign_id'] ?? NULL;
+ if ($campaignId) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
}
// format the addresses according to CIVICRM_ADDRESS_FORMAT (CRM-1327)
foreach ((array) $rows as $id => $row) {
- if ($commMethods = CRM_Utils_Array::value('preferred_communication_method', $row)) {
+ $commMethods = $row['preferred_communication_method'] ?? NULL;
+ if ($commMethods) {
$val = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $commMethods));
$comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
$temp = [];
);
$tplParams['pcpInfoURL'] = $pcpInfoURL;
$tplParams['contribPageTitle'] = $contribPageTitle;
- if ($emails = CRM_Utils_Array::value('notify_email', $pcpBlockInfo)) {
+ $emails = $pcpBlockInfo['notify_email'] ?? NULL;
+ if ($emails) {
$emailArray = explode(',', $emails);
$tplParams['pcpNotifyEmailAddress'] = $emailArray[0];
}
}
}
- if ($emails = CRM_Utils_Array::value('notify_email', $params)) {
+ $emails = $params['notify_email'] ?? NULL;
+ if ($emails) {
$emailArray = explode(',', $emails);
foreach ($emailArray as $email) {
if ($email && !CRM_Utils_Rule::email(trim($email))) {
}
}
- if ($emails = CRM_Utils_Array::value('notify_email', $params)) {
+ $emails = $params['notify_email'] ?? NULL;
+ if ($emails) {
$emailArray = explode(',', $emails);
foreach ($emailArray as $email) {
if ($email && !CRM_Utils_Rule::email(trim($email))) {
$this->setTitle(ts('View Pledge by') . ' ' . $displayName);
// do check for campaigns
- if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
+ $campaignId = $values['campaign_id'] ?? NULL;
+ if ($campaignId) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
elseif (!empty($params['financial_type_id'])) {
$options['financial_type_id'] = $params['financial_type_id'];
}
- if ($opIds = CRM_Utils_Array::value('option_id', $params)) {
- if ($opId = CRM_Utils_Array::value($index, $opIds)) {
+ $opIds = $params['option_id'] ?? NULL;
+ if ($opIds) {
+ $opId = $opIds[$index] ?? NULL;
+ if ($opId) {
$options['id'] = $opId;
}
else {
public static function getSetId(&$params) {
$fid = NULL;
- if ($oid = CRM_Utils_Array::value('oid', $params)) {
+ $oid = $params['oid'] ?? NULL;
+ if ($oid) {
$fieldValue = new CRM_Price_DAO_PriceFieldValue();
$fieldValue->id = $oid;
if ($fieldValue->find(TRUE)) {
}
}
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
- if ($greetingType = CRM_Utils_Array::value($greeting, $fields)) {
+ $greetingType = $fields[$greeting] ?? NULL;
+ if ($greetingType) {
$customizedValue = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greeting . '_id', 'Customized');
if ($customizedValue == $greetingType && empty($fields[$greeting . '_custom'])) {
$errors[$greeting . '_custom'] = ts('Custom %1 is a required field if %1 is of type Customized.',
$returnProperties = ['is_multiple', 'table_name'];
CRM_Core_DAO::commonRetrieve("CRM_Core_DAO_CustomGroup", $filterParams, $returnValues, $returnProperties);
if (!empty($returnValues['is_multiple'])) {
- if ($tableName = CRM_Utils_Array::value('table_name', $returnValues)) {
+ $tableName = $returnValues['table_name'] ?? NULL;
+ if ($tableName) {
$sql = "DELETE FROM {$tableName} WHERE id = %1 AND entity_id = %2";
$sqlParams = [
1 => [$this->_recordId, 'Integer'],
}
if (!$instanceID) {
- if ($reportID = CRM_Utils_Array::value('report_id', $params)) {
+ $reportID = $params['report_id'] ?? NULL;
+ if ($reportID) {
$instance->report_id = $reportID;
}
elseif ($instanceID) {
$navigationParams['parent_id'] = $params['parent_id'] ?? NULL;
$navigationParams['is_active'] = 1;
- if ($permission = CRM_Utils_Array::value('permission', $params)) {
+ $permission = $params['permission'] ?? NULL;
+ if ($permission) {
$navigationParams['permission'][] = $permission;
}
'label' => $params['title'],
'is_active' => 1,
];
- if ($permission = CRM_Utils_Array::value('permission', $params)) {
+ $permission = $params['permission'] ?? NULL;
+ if ($permission) {
$dashletParams['permission'][] = $permission;
}
}
) {
$this->_defaults["{$fieldName}_op"] = 'mhas';
}
- elseif ($op = CRM_Utils_Array::value('default_op', $field)) {
- $this->_defaults["{$fieldName}_op"] = $op;
+ elseif (!empty($field['default_op'])) {
+ $this->_defaults["{$fieldName}_op"] = $field['default_op'];
}
}
}
$from = $select = [];
$case = $this->_aliases['civicrm_case'];
- if ($activityType = CRM_Utils_Array::value('case_activity_all_dates', $this->_params['case_detail_extra'])) {
+ $activityType = $this->_params['case_detail_extra']['case_activity_all_dates'] ?? NULL;
+ if ($activityType) {
$select[] = "GROUP_CONCAT(DISTINCT(civireport_activity_all_{$activityType}.{$this->_caseDetailExtra['case_activity_all_dates']['name']}) ORDER BY civireport_activity_all_{$activityType}.{$this->_caseDetailExtra['case_activity_all_dates']['name']}) as case_activity_all_dates";
$from[] = " LEFT JOIN civicrm_case_activity civireport_case_activity_all_{$activityType} ON ( civireport_case_activity_all_{$activityType}.case_id = {$case}.id)
foreach ($rows as $rowNum => $row) {
// handle contribution
if ($component == 'contribution_civireport') {
- if ($val = CRM_Utils_Array::value('civicrm_contribution_financial_type_id', $row)) {
+ $val = $row['civicrm_contribution_financial_type_id'] ?? NULL;
+ if ($val) {
$componentRows[$contactID][$component][$rowNum]['civicrm_contribution_financial_type_id'] = CRM_Contribute_PseudoConstant::financialType($val, FALSE);
}
- if ($val = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) {
+ $val = $row['civicrm_contribution_contribution_status_id'] ?? NULL;
+ if ($val) {
$componentRows[$contactID][$component][$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Contribute_PseudoConstant::contributionStatus($val, 'label');
}
$entryFound = TRUE;
}
if ($component === 'membership_civireport') {
- if ($val = CRM_Utils_Array::value('civicrm_membership_membership_type_id', $row)) {
+ $val = $row['civicrm_membership_membership_type_id'] ?? NULL;
+ if ($val) {
$componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant::membershipType($val, FALSE);
}
- if ($val = CRM_Utils_Array::value('civicrm_membership_status_id', $row)) {
+ $val = $row['civicrm_membership_status_id'] ?? NULL;
+ if ($val) {
$componentRows[$contactID][$component][$rowNum]['civicrm_membership_status_id'] = CRM_Member_PseudoConstant::membershipStatus($val, FALSE);
}
$entryFound = TRUE;
}
if ($component == 'participant_civireport') {
- if ($val = CRM_Utils_Array::value('civicrm_participant_event_id', $row)) {
+ $val = $row['civicrm_participant_event_id'] ?? NULL;
+ if ($val) {
$componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($val, FALSE);
$url = CRM_Report_Utils_Report::getNextUrl('event/income',
'reset=1&force=1&id_op=in&id_value=' . $val,
$entryFound = TRUE;
}
- if ($val = CRM_Utils_Array::value('civicrm_participant_participant_status_id', $row)) {
+ $val = $row['civicrm_participant_participant_status_id'] ?? NULL;
+ if ($val) {
$componentRows[$contactID][$component][$rowNum]['civicrm_participant_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($val, FALSE);
}
- if ($val = CRM_Utils_Array::value('civicrm_participant_role_id', $row)) {
+ $val = $row['civicrm_participant_role_id'] ?? NULL;
+ if ($val) {
$roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $val);
$value = [];
foreach ($roles as $role) {
}
if ($component == 'activity_civireport') {
- if ($val = CRM_Utils_Array::value('civicrm_activity_activity_type_id', $row)) {
+ $val = $row['civicrm_activity_activity_type_id'] ?? NULL;
+ if ($val) {
$componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_type_id'] = $activityTypes[$val];
}
- if ($val = CRM_Utils_Array::value('civicrm_activity_activity_status_id', $row)) {
+ $val = $row['civicrm_activity_activity_status_id'] ?? NULL;
+ if ($val) {
$componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_status_id'] = $activityStatus[$val];
}
$entryFound = TRUE;
}
if ($component == 'membership_civireport') {
- if ($val = CRM_Utils_Array::value('civicrm_membership_membership_status_id', $row)) {
+ $val = $row['civicrm_membership_membership_status_id'] ?? NULL;
+ if ($val) {
$componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_status_id'] = CRM_Member_PseudoConstant::membershipStatus($val);
}
$entryFound = TRUE;
}
// handle contribution status id
- if ($value = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) {
+ $value = $row['civicrm_contribution_contribution_status_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_contribution_status_id'] = $contributionStatus[$value];
}
// handle payment instrument id
- if ($value = CRM_Utils_Array::value('civicrm_financial_trxn_payment_instrument_id', $row)) {
+ $value = $row['civicrm_financial_trxn_payment_instrument_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_financial_trxn_payment_instrument_id'] = $paymentInstruments[$value];
}
// handle financial type id
- if ($value = CRM_Utils_Array::value('civicrm_line_item_financial_type_id', $row)) {
+ $value = $row['civicrm_line_item_financial_type_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_line_item_financial_type_id'] = $contributionTypes[$value];
}
- if ($value = CRM_Utils_Array::value('civicrm_entity_financial_trxn_amount', $row)) {
+ $value = $row['civicrm_entity_financial_trxn_amount'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_entity_financial_trxn_amount'] = CRM_Utils_Money::format($rows[$rowNum]['civicrm_entity_financial_trxn_amount'], $rows[$rowNum]['civicrm_financial_trxn_currency']);
}
foreach ($entry['rows'] as $rowNum => &$row) {
// convert transaction status id to status name
- if ($status = CRM_Utils_Array::value('civicrm_financial_trxn_status_id', $row)) {
+ $status = $row['civicrm_financial_trxn_status_id'] ?? NULL;
+ if ($status) {
$row['civicrm_financial_trxn_status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'status_id', $status);
$entryFound = TRUE;
}
// convert batch id to batch title
- if ($batchId = CRM_Utils_Array::value('civicrm_batch_batch_id', $row)) {
+ $batchId = $row['civicrm_batch_batch_id'] ?? NULL;
+ if ($batchId) {
$row['civicrm_batch_batch_id'] = $this->getLabels($batchId, 'CRM_Batch_BAO_EntityBatch', 'batch_id');
$entryFound = TRUE;
}
// add hotlink for contribution
- if ($amount = CRM_Utils_Array::value('civicrm_financial_trxn_total_amount', $row)) {
+ $amount = $row['civicrm_financial_trxn_total_amount'] ?? NULL;
+ if ($amount) {
$contributionUrl = CRM_Utils_System::url("civicrm/contact/view/contribution",
'reset=1&action=view&cid=' . $row['civicrm_contact_id'] . '&id=' . $row['civicrm_contribution_contribution_id'],
$this->_absoluteUrl
);
$row['civicrm_financial_trxn_total_amount'] = "<a href={$contributionUrl}>{$amount}</a>";
- if ($contributionId = CRM_Utils_Array::value('civicrm_contribution_id', $row)) {
+ $contributionId = $row['civicrm_contribution_id'] ?? NULL;
+ if ($contributionId) {
$row['civicrm_contribution_id'] = "<a href={$contributionUrl}>{$contributionId}</a>";
}
$entryFound = TRUE;
}
// add hotlink for contact
- if ($contactName = CRM_Utils_Array::value('civicrm_contact_display_name', $row)) {
+ $contactName = $row['civicrm_contact_display_name'] ?? NULL;
+ if ($contactName) {
$contactUrl = CRM_Utils_System::url("civicrm/contact/view",
'reset=1&cid=' . $row['civicrm_contact_id'],
$this->_absoluteUrl
$entryFound = TRUE;
}
- if ($contactId = CRM_Utils_Array::value('civicrm_contribution_contact_id', $row)) {
+ $contactId = $row['civicrm_contribution_contact_id'] ?? NULL;
+ if ($contactId) {
$contactUrl = CRM_Utils_System::url("civicrm/contact/view",
'reset=1&cid=' . $row['civicrm_contact_id'],
$this->_absoluteUrl
$rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contact Summary for this Contact.");
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_financial_type_id', $row)) {
+ $value = $row['civicrm_contribution_financial_type_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_financial_type_id'] = $contributionTypes[$value];
$entryFound = TRUE;
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) {
+ $value = $row['civicrm_contribution_contribution_status_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_contribution_status_id'] = $contributionStatus[$value];
$entryFound = TRUE;
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_contribution_page_id', $row)) {
+ $value = $row['civicrm_contribution_contribution_page_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_contribution_page_id'] = $contributionPages[$value];
$entryFound = TRUE;
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_payment_instrument_id', $row)) {
+ $value = $row['civicrm_contribution_payment_instrument_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_payment_instrument_id'] = $paymentInstruments[$value];
$entryFound = TRUE;
}
}
// Contribution amount links to viewing contribution
- if ($value = CRM_Utils_Array::value('civicrm_contribution_total_amount', $row)) {
+ $value = $row['civicrm_contribution_total_amount'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_total_amount'] = CRM_Utils_Money::format($value, $row['civicrm_contribution_currency']);
if (CRM_Core_Permission::check('access CiviContribute')) {
$url = CRM_Utils_System::url(
}
// Contribution amount links to viewing contribution
- if ($value = CRM_Utils_Array::value('civicrm_pledge_payment_pledge_id', $row)) {
+ $value = $row['civicrm_pledge_payment_pledge_id'] ?? NULL;
+ if ($value) {
if (CRM_Core_Permission::check('access CiviContribute')) {
$url = CRM_Utils_System::url(
"civicrm/contact/view/pledge",
}
// handle contribution status id
- if ($value = CRM_Utils_Array::value('civicrm_contribution_recur_contribution_status_id', $row)) {
+ $value = $row['civicrm_contribution_recur_contribution_status_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_recur_contribution_status_id'] = $contributionStatus[$value];
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_recur_amount', $row)) {
+ $value = $row['civicrm_contribution_recur_amount'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_recur_amount'] = CRM_Utils_Money::format($rows[$rowNum]['civicrm_contribution_recur_amount'], $rows[$rowNum]['civicrm_contribution_recur_currency']);
}
$total = $total + $amountDao->amount;
// handle payment instrument id
- if ($value = CRM_Utils_Array::value('civicrm_contribution_recur_payment_instrument_id', $row)) {
+ $value = $row['civicrm_contribution_recur_payment_instrument_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_recur_payment_instrument_id'] = $paymentInstruments[$value];
$entryFound = TRUE;
}
}
// convert contribution status id to status name
- if ($value = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) {
+ $value = $row['civicrm_contribution_contribution_status_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_contribution_status_id'] = $contributionStatus[$value];
$entryFound = TRUE;
}
$entryFound = TRUE;
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_contribution_page_id', $row)) {
+ $value = $row['civicrm_contribution_contribution_page_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_contribution_page_id'] = $contributionPages[$value];
$entryFound = TRUE;
}
}
}
//add blank column at the end
- if ($blankcols = CRM_Utils_Array::value('blank_column_end', $this->_params)) {
+ $blankcols = $this->_params['blank_column_end'] ?? NULL;
+ if ($blankcols) {
for ($i = 1; $i <= $blankcols; $i++) {
$select[] = " '' as blankColumnEnd_{$i}";
$this->_columnHeaders["blank_{$i}"]['title'] = "_ _ _ _";
$rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact.');
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_financial_type_id', $row)) {
+ $value = $row['civicrm_contribution_financial_type_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_financial_type_id'] = $contributionTypes[$value];
$entryFound = TRUE;
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) {
+ $value = $row['civicrm_contribution_contribution_status_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_contribution_status_id'] = $contributionStatus[$value];
$entryFound = TRUE;
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_payment_instrument_id', $row)) {
+ $value = $row['civicrm_contribution_payment_instrument_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_payment_instrument_id'] = $paymentInstruments[$value];
$entryFound = TRUE;
}
$entryFound = TRUE;
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_financial_type_id', $row)) {
+ $value = $row['civicrm_contribution_financial_type_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_financial_type_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_Contribution', 'financial_type_id', $value);
$entryFound = TRUE;
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) {
+ $value = $row['civicrm_contribution_contribution_status_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $value);
$entryFound = TRUE;
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_payment_instrument_id', $row)) {
+ $value = $row['civicrm_contribution_payment_instrument_id'] ?? NULL;
+ if ($value) {
$rows[$rowNum]['civicrm_contribution_payment_instrument_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', $value);
$entryFound = TRUE;
}
if (is_array($fieldGrp)) {
foreach ($fieldGrp as $tableName => $fields) {
- if ($groupBys = CRM_Utils_Array::value("gby", $_GET)) {
+ $groupBys = $_GET["gby"] ?? NULL;
+ if ($groupBys) {
$groupBys = explode(' ', $groupBys);
if (!empty($groupBys)) {
if (!$flag) {
public static function processFields(&$reportFields, &$defaults) {
//add filters from url
if (is_array($reportFields)) {
- if ($urlFields = CRM_Utils_Array::value("fld", $_GET)) {
+ $urlFields = $_GET["fld"] ?? NULL;
+ if ($urlFields) {
$urlFields = explode(',', $urlFields);
}
if (($_GET["ufld"] ?? NULL) == 1) {
$action = 1;
- if ($optionValueID = CRM_Utils_Array::value('option_value_id', $params)) {
+ $optionValueID = $params['option_value_id'] ?? NULL;
+ if ($optionValueID) {
$action = 2;
}
* Array of status id and status name
*/
function civicrm_api3_membership_status_calc($membershipParams) {
- if (!($membershipID = CRM_Utils_Array::value('membership_id', $membershipParams))) {
+ $membershipID = $membershipParams['membership_id'] ?? NULL;
+ if (!$membershipID) {
throw new CRM_Core_Exception('membershipParams do not contain membership_id');
}
);
}
- if ($type = CRM_Utils_Array::value('civicrm_contact_contact_type', $values)) {
+ $type = $values['civicrm_contact_contact_type'] ?? NULL;
+ if ($type) {
$grantStatistics['civicrm_contact_contact_type']['title'] = ts('By Contact Type');
$title = "Total Number of {$type}(s)";
self::getStatistics($grantStatistics['civicrm_contact_contact_type'], $title, $values,
'value' => '6',
'is_active' => 1,
]);
- if ($id = CRM_Utils_Array::value('id', $result)) {
+ $id = $result['id'] ?? NULL;
+ if ($id) {
$this->callAPISuccess('OptionValue', 'delete', ['id' => $id]);
}
}