diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index 1f19c32f74b4..f18198b20961 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -1877,7 +1877,6 @@ public static function formatFieldsAndSetProfileDefaults($contactId, &$form) { * Evaluate whether a participant record is eligible for self-service transfer/cancellation. If so, * return additional participant/event details. * - * TODO: This function fails when the "hours until self-service" is less than zero. * @param int $participantId * @param string $url * @param bool $isBackOffice @@ -1930,7 +1929,12 @@ public static function getSelfServiceEligibility(int $participantId, string $url $cancelDeadline = (new Datetime($start_date))->sub($cancelInterval); if ($timenow > $cancelDeadline) { $details['eligible'] = FALSE; - $details['ineligible_message'] = ts("Registration for this event cannot be cancelled or transferred less than %1 hours prior to the event's start time. Contact the event organizer if you have questions.", [1 => $time_limit]); + // Change the language of the status message based on whether the waitlist time limit is positive or negative. + $afterOrPrior = $time_limit < 0 ? 'after' : 'prior'; + $moreOrLess = $time_limit < 0 ? 'more' : 'less'; + $details['ineligible_message'] = ts("Registration for this event cannot be cancelled or transferred %1 than %2 hours %3 to the event's start time. Contact the event organizer if you have questions.", + [1 => $moreOrLess, 2 => $cancelHours, 3 => $afterOrPrior]); + } } return $details; diff --git a/CRM/Event/DAO/Event.php b/CRM/Event/DAO/Event.php index adcf39c5d7aa..742de59cf45b 100644 --- a/CRM/Event/DAO/Event.php +++ b/CRM/Event/DAO/Event.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Event/Event.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:331a210ceb36b5e9460705dbfbe71abf) + * (GenCodeChecksum:5f01b2be07ae960dffdbaa5249f23783) */ /** diff --git a/CRM/Upgrade/Incremental/sql/5.29.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.29.alpha1.mysql.tpl index 18b176d4b0f0..487d949dc604 100644 --- a/CRM/Upgrade/Incremental/sql/5.29.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/5.29.alpha1.mysql.tpl @@ -45,3 +45,6 @@ SET body_text = '{ts escape="sql" 1=$unsubgroup 2=$actresub 3=$actresuburl}You h WHERE component_type = 'Unsubscribe' AND (body_text = '{ts escape="sql" 1=$unsubgroup 2=$actresub}You have been un-subscribed from the following groups: %1. You can re-subscribe by mailing %2 or clicking %3{/ts}' OR body_text = '{ts escape="sql" 1=$unsubgroup 2=$actresub}You have been un-subscribed from the following groups: %1. You can re-subscribe by mailing %2 or clicking {/ts}'); + +-- Allow self-service/transfer to have a negative time. +ALTER TABLE civicrm_event MODIFY COLUMN selfcancelxfer_time INT; diff --git a/tests/phpunit/CRM/Event/BAO/ParticipantTest.php b/tests/phpunit/CRM/Event/BAO/ParticipantTest.php index eb8dc5700842..4dc15134dc0a 100644 --- a/tests/phpunit/CRM/Event/BAO/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/BAO/ParticipantTest.php @@ -493,6 +493,15 @@ public function selfServiceScenarios() { 'isBackOffice' => FALSE, 'successExpected' => FALSE, ]; + // Cancellation deadline is < 0 hours + $scenarios[] = [ + 'selfSvcEnabled' => 1, + 'selfSvcHours' => -12, + 'hoursToEvent' => 4, + 'participantStatusId' => 1, + 'isBackOffice' => FALSE, + 'successExpected' => TRUE, + ]; return $scenarios; } diff --git a/xml/schema/Event/Event.xml b/xml/schema/Event/Event.xml index d4c9c65299df..60ec46b0ef8d 100644 --- a/xml/schema/Event/Event.xml +++ b/xml/schema/Event/Event.xml @@ -679,7 +679,7 @@ selfcancelxfer_time - int unsigned + int 0 Self-service Cancellation or Transfer Time Number of hours prior to event start date to allow self-service cancellation or transfer.