Skip to content

Commit

Permalink
Merge pull request #32012 from colemanw/eventDep
Browse files Browse the repository at this point in the history
[REF] CRM/Event - Refactor out uses of deprecated CRM_Utils_Array::value
  • Loading branch information
demeritcowboy authored Feb 10, 2025
2 parents c73fb00 + dff2550 commit 07cdd0c
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions CRM/Event/BAO/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ public static function copy($id, $params = []) {
$copyEvent = CRM_Core_DAO::copyGeneric('CRM_Event_DAO_Event',
['id' => $id],
// since the location is sharable, lets use the same loc_block_id.
['loc_block_id' => CRM_Utils_Array::value('loc_block_id', $eventValues)] + $params,
['loc_block_id' => $eventValues['loc_block_id'] ?? NULL] + $params,
$fieldsFix,
NULL,
$blockCopyOfCustomValue
Expand Down Expand Up @@ -1119,8 +1119,8 @@ public static function sendMail($contactID, $values, $participantId, $isTest = F
'email' => $notifyEmail,
'confirm_email_text' => $values['event']['confirm_email_text'] ?? NULL,
'isShowLocation' => $values['event']['is_show_location'] ?? NULL,
'credit_card_number' => CRM_Utils_System::mungeCreditCard(CRM_Utils_Array::value('credit_card_number', $participantParams)),
'credit_card_exp_date' => CRM_Utils_Date::mysqlToIso(CRM_Utils_Date::format(CRM_Utils_Array::value('credit_card_exp_date', $participantParams))),
'credit_card_number' => CRM_Utils_System::mungeCreditCard($participantParams['credit_card_number'] ?? NULL),
'credit_card_exp_date' => CRM_Utils_Date::mysqlToIso(CRM_Utils_Date::format($participantParams['credit_card_exp_date'] ?? NULL)),
'selfcancelxfer_time' => abs($values['event']['selfcancelxfer_time']),
'selfservice_preposition' => $values['event']['selfcancelxfer_time'] < 0 ? ts('after') : ts('before'),
'currency' => $values['event']['currency'] ?? CRM_Core_Config::singleton()->defaultCurrency,
Expand Down Expand Up @@ -1621,7 +1621,7 @@ public static function buildCustomProfile(
//get the params submitted by participant.
$participantParams = NULL;
if (isset($values['params'])) {
$participantParams = CRM_Utils_Array::value($pId, $values['params'], []);
$participantParams = $values['params'][$pId] ?? [];
}

[$profilePre, $groupTitles] = self::buildCustomDisplay($preProfileID,
Expand Down
4 changes: 2 additions & 2 deletions CRM/Event/Form/ManageEvent/Fee.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function setDefaultValues() {
$maxKey = count($totalLables) - 1;
if (isset($maxKey) && !empty($totalLables[$maxKey]['value'])) {
foreach ($totalLables[$maxKey]['value'] as $i => $v) {
if ($totalLables[$maxKey]['amount_id'][$i] == CRM_Utils_Array::value('default_discount_fee_id', $defaults)) {
if ($totalLables[$maxKey]['amount_id'][$i] == ($defaults['default_discount_fee_id'] ?? NULL)) {
$defaults['discounted_default'] = $i;
break;
}
Expand Down Expand Up @@ -632,7 +632,7 @@ public function postProcess() {
$fieldParams['option_id'] = $params['price_field_value'];

$priceSet = new CRM_Price_BAO_PriceSet();
$priceSet->id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $params), 'price_set_id');
$priceSet->id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $params['price_field_id'] ?? NULL, 'price_set_id');

if ($this->_defaultValues['financial_type_id'] != $params['financial_type_id']) {
CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $priceSet->id, 'financial_type_id', $params['financial_type_id']);
Expand Down
16 changes: 8 additions & 8 deletions CRM/Event/Form/ManageEvent/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,12 @@ public static function formRule($values, $files, $form) {

//check that the selected profiles have either firstname+lastname or email required
$profileIds = [
CRM_Utils_Array::value('custom_pre_id', $values),
CRM_Utils_Array::value('custom_post_id', $values),
$values['custom_pre_id'] ?? NULL,
$values['custom_post_id'] ?? NULL,
];
$additionalProfileIds = [
CRM_Utils_Array::value('additional_custom_pre_id', $values),
CRM_Utils_Array::value('additional_custom_post_id', $values),
$values['additional_custom_pre_id'] ?? NULL,
$values['additional_custom_post_id'] ?? NULL,
];
//additional profile fields default to main if not set
if (!is_numeric($additionalProfileIds[0])) {
Expand Down Expand Up @@ -905,12 +905,12 @@ public function postProcess() {

// get the profiles to evaluate what they collect
$profileIds = [
CRM_Utils_Array::value('custom_pre_id', $params),
CRM_Utils_Array::value('custom_post_id', $params),
$params['custom_pre_id'] ?? NULL,
$params['custom_post_id'] ?? NULL,
];
$additionalProfileIds = [
CRM_Utils_Array::value('additional_custom_pre_id', $params),
CRM_Utils_Array::value('additional_custom_post_id', $params),
$params['additional_custom_pre_id'] ?? NULL,
$params['additional_custom_post_id'] ?? NULL,
];
// additional profile fields default to main if not set
if (!is_numeric($additionalProfileIds[0])) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ protected function assignUrlPath() {
protected function sendReceipts($params, array $participants): array {
$sent = [];
$notSent = [];
$this->assignEventDetailsToTpl($params['event_id'], CRM_Utils_Array::value('role_id', $params), CRM_Utils_Array::value('receipt_text', $params));
$this->assignEventDetailsToTpl($params['event_id'], $params['role_id'] ?? NULL, $params['receipt_text'] ?? NULL);

if ($this->_mode) {
$valuesForForm = CRM_Contribute_Form_AbstractEditPayment::formatCreditCardDetails($params);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/ParticipantFeeSelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ protected function buildAmount($discountId, $priceSetID) {
continue;
}

$optionFullIds = CRM_Utils_Array::value('option_full_ids', $field, []);
$optionFullIds = $field['option_full_ids'] ?? [];

//soft suppress required rule when option is full.
if (!empty($optionFullIds) && (count($options) == count($optionFullIds))) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/ParticipantView.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function preProcess() {
$participantCount = [];
$totalTaxAmount = $totalAmount = 0;
foreach ($lineItem as $k => $v) {
if (CRM_Utils_Array::value('participant_count', $lineItem[$k]) > 0) {
if (($lineItem[$k]['participant_count'] ?? 0) > 0) {
$participantCount[] = $lineItem[$k]['participant_count'];
}
$totalTaxAmount = $v['tax_amount'] + $totalTaxAmount;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2059,7 +2059,7 @@ protected function buildAmount() {
$adminVisibilityID = CRM_Price_BAO_PriceField::getVisibilityOptionID('admin');

foreach ($options as $key => $currentOption) {
$optionVisibility = CRM_Utils_Array::value('visibility_id', $currentOption, $publicVisibilityID);
$optionVisibility = $currentOption['visibility_id'] ?? $publicVisibilityID;
if ($optionVisibility == $adminVisibilityID) {
unset($options[$key]);
}
Expand Down
20 changes: 10 additions & 10 deletions CRM/Event/Form/Registration/AdditionalParticipant.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public function buildQuickForm() {

//truly spaces are less than required.
if (is_numeric($spaces) && $spaces <= ($processedCnt + $currentPageMaxCount)) {
if (CRM_Utils_Array::value('amount', $this->_params[0], 0) == 0 || $this->_requireApproval) {
if (($this->_params[0]['amount'] ?? 0) == 0 || $this->_requireApproval) {
$this->_allowWaitlist = FALSE;
$this->set('allowWaitlist', $this->_allowWaitlist);
if ($this->_requireApproval) {
Expand All @@ -304,7 +304,7 @@ public function buildQuickForm() {
CRM_Core_Session::setStatus($statusMessage, ts('Registration Error'), 'error');
}
elseif ($processedCnt == $spaces) {
if (CRM_Utils_Array::value('amount', $this->_params[0], 0) == 0
if (($this->_params[0]['amount'] ?? 0) == 0
|| $realPayLater || $this->_requireApproval
) {
$this->_resetAllowWaitlist = TRUE;
Expand Down Expand Up @@ -356,7 +356,7 @@ public function buildQuickForm() {
!$this->_allowWaitlist &&
!$realPayLater &&
!$this->_requireApproval &&
!(CRM_Utils_Array::value('amount', $this->_params[0], 0) == 0)
!(($this->_params[0]['amount'] ?? 0) == 0)
) {
$paymentBypassed = ts('Please go back to the main registration page, to complete payment information.');
}
Expand Down Expand Up @@ -481,8 +481,8 @@ public static function formRule($fields, $files, $self) {
}
else {
// check with first_name and last_name for additional participants
if (!empty($value['first_name']) && ($value['first_name'] == CRM_Utils_Array::value('first_name', $fields)) &&
(($value['last_name'] ?? NULL) == CRM_Utils_Array::value('last_name', $fields))
if (!empty($value['first_name']) && ($value['first_name'] == ($fields['first_name'] ?? NULL)) &&
(($value['last_name'] ?? NULL) == ($fields['last_name'] ?? NULL))
) {
$errors['first_name'] = ts('The first name and last name must be unique for each participant.');
break;
Expand All @@ -502,7 +502,7 @@ public static function formRule($fields, $files, $self) {

//validate price field params.
$priceSetErrors = $self->validatePriceSet($allParticipantParams, $self->get('priceSetId'), $self->get('priceSet'));
$errors = array_merge($errors, CRM_Utils_Array::value($addParticipantNum, $priceSetErrors, []));
$errors = array_merge($errors, $priceSetErrors[$addParticipantNum] ?? []);

if (!$self->_allowConfirmation &&
is_numeric($self->_availableRegistrations)
Expand All @@ -511,7 +511,7 @@ public static function formRule($fields, $files, $self) {
!$self->_allowWaitlist &&
!$realPayLater &&
!$self->_requireApproval &&
!(CRM_Utils_Array::value('amount', $self->_params[0], 0) == 0) &&
!(($self->_params[0]['amount'] ?? 0) == 0) &&
$totalParticipants < $self->_availableRegistrations
) {
$errors['_qf_default'] = ts("Your event registration will be confirmed. Please go back to the main registration page, to complete payment information.");
Expand Down Expand Up @@ -539,7 +539,7 @@ public static function formRule($fields, $files, $self) {
!$self->_allowWaitlist &&
!$realPayLater &&
!$self->_requireApproval &&
!(CRM_Utils_Array::value('amount', $self->_params[0], 0) == 0)
!(($self->_params[0]['amount'] ?? 0) == 0)
) {
$errors['_qf_default'] = ts("You are going to skip the last participant, your event registration will be confirmed. Please go back to the main registration page, to complete payment information.");
}
Expand Down Expand Up @@ -571,7 +571,7 @@ public function validatePaymentValues($self, $fields) {
if (!empty($self->_params[0]['bypass_payment']) ||
$self->_allowWaitlist ||
empty($self->_fields) ||
CRM_Utils_Array::value('amount', $self->_params[0]) > 0
($self->_params[0]['amount'] ?? 0) > 0
) {
return TRUE;
}
Expand All @@ -586,7 +586,7 @@ public function validatePaymentValues($self, $fields) {
}
}
elseif (!empty($fields['amount']) &&
(CRM_Utils_Array::value('value', $self->_values['fee'][$fields['amount']]) > 0)
(($self->_values['fee'][$fields['amount']]['value'] ?? 0) > 0)
) {
$validatePayement = TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions CRM/Event/Form/Registration/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function preProcess() {
//here we can't use parent $this->_allowWaitlist as user might
//walk back and we might set this value in this postProcess.
//(we set when spaces < group count and want to allow become part of waiting )
$eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
$eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, $this->_values['event']['has_waitlist'] ?? NULL);

// Get payment processors if appropriate for this event
$this->_noFees = $suppressPayment = $this->isSuppressPayment();
Expand Down Expand Up @@ -600,7 +600,7 @@ public static function formRule($fields, $files, $form) {
/// see https://lab.civicrm.org/dev/core/-/issues/5168
if ($form->getPriceSetID() && !empty($fields['bypass_payment']) && $form->_allowConfirmation) {
if ($spacesAvailable === 0 ||
(empty($fields['priceSetId']) && CRM_Utils_Array::value('additional_participants', $fields) < $spacesAvailable)
(empty($fields['priceSetId']) && ($fields['additional_participants'] ?? 0) < $spacesAvailable)
) {
$errors['bypass_payment'] = ts("You have not been added to the waiting list because there are spaces available for this event. We recommend registering yourself for an available space instead.");
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/Registration/ThankYou.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function preProcess(): void {

CRM_Event_Form_Registration_Confirm::assignProfiles($this);

$this->setTitle(CRM_Utils_Array::value('thankyou_title', $this->_values['event']));
$this->setTitle($this->_values['event']['thankyou_title'] ?? NULL);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Page/EventInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function run() {

$this->assign('isShowLocation', $values['event']['is_show_location'] ?? NULL);

$eventCurrency = CRM_Utils_Array::value('currency', $values['event'], $config->defaultCurrency);
$eventCurrency = $values['event']['currency'] ?? $config->defaultCurrency;
$this->assign('eventCurrency', $eventCurrency);

// show event fees.
Expand Down

0 comments on commit 07cdd0c

Please sign in to comment.