Skip to content

Commit e72e6ac

Browse files
dev/core#5422 Fix no full message showing up for logged in registered users
1 parent e07f5be commit e72e6ac

File tree

6 files changed

+39
-17
lines changed

6 files changed

+39
-17
lines changed

CRM/Event/Form/Registration/ParticipantConfirm.php

+2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ public function postProcess() {
199199

200200
$this->postProcessHook();
201201
CRM_Core_Session::setStatus($statusMessage);
202+
// The noFullMsg here is about suppressing the event full message as the person
203+
// is potentially just being bounced to that screen.
202204
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/info',
203205
"reset=1&id={$this->_eventId}&noFullMsg=1",
204206
FALSE, NULL, FALSE, TRUE

CRM/Event/Form/Registration/Register.php

+1
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,7 @@ public static function checkRegistration($fields, $form, $isAdditional = FALSE)
984984
}
985985
$status .= ' ' . ts('You can also <a href="%1">register another participant</a>.', [1 => $registerUrl]);
986986
CRM_Core_Session::singleton()->setStatus($status, '', 'alert');
987+
// @todo - pass cid=0 in the url & remove noFullMsg here.
987988
$url = CRM_Utils_System::url('civicrm/event/info',
988989
"reset=1&id={$form->_values['event']['id']}&noFullMsg=true"
989990
);

CRM/Event/Form/SelfSvcUpdate.php

+2
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ public function cancelParticipant($params) {
317317
if (!empty($this->isBackoffice)) {
318318
return;
319319
}
320+
// The noFullMsg here is about suppressing the event full message as the person
321+
// is potentially just being bounced to that screen.
320322
$url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_event_id}&noFullMsg=true");
321323
CRM_Utils_System::redirect($url);
322324
}

CRM/Event/Page/EventInfo.php

+34-14
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ public function run() {
4949
$this->assign('iCal', CRM_Event_BAO_Event::getICalLinks($this->_id));
5050
$this->assign('isShowICalIconsInline', TRUE);
5151

52-
// Sometimes we want to suppress the Event Full msg
53-
$noFullMsg = CRM_Utils_Request::retrieve('noFullMsg', 'String', $this, FALSE, 'false');
54-
5552
//retrieve event information
5653
$params = ['id' => $this->_id];
5754
$values = ['event' => NULL];
@@ -271,17 +268,25 @@ public function run() {
271268
$this->assign('registerClosed', !empty($values['event']['is_online_registration']) && !$isEventOpenForRegistration && CRM_Core_Permission::check('register for events'));
272269
$this->assign('allowRegistration', $allowRegistration);
273270

274-
$session = CRM_Core_Session::singleton();
275-
$params = [
276-
'contact_id' => $session->get('userID'),
277-
'event_id' => $values['event']['id'] ?? NULL,
278-
'role_id' => $values['event']['default_role_id'] ?? NULL,
279-
];
280-
281-
if (($this->isEventFull() && $noFullMsg === 'false') || CRM_Event_BAO_Event::checkRegistration($params)) {
282-
$statusMessage = $this->getEventValue('event_full_text');
283-
if (CRM_Event_BAO_Event::checkRegistration($params)) {
284-
if ($noFullMsg == 'false') {
271+
$isAlreadyRegistered = $this->isAlreadyRegistered();
272+
// noFullMsg was originally passed in to suppress the message about the event being full. The intent
273+
// was originally such that when you were sending the user back to the info page after registering
274+
// they would not be told it was full. Along the way it got overloaded to encompass
275+
// the scenario where the user is potentially trying to register another user & hence became very confusing.
276+
// We could probably make this make more sense by
277+
// 1) always passing cid in the url if the person is being redirected to register another person
278+
// and using that rather than the logged in use to check for existing registrations
279+
// 2) using a more positive 'you are registered' message rather than making it
280+
// sound like a mistake.
281+
// 3) using the normal button to pass cid=0 information rather than a link.
282+
$noFullMsg = CRM_Utils_Request::retrieve('noFullMsg', 'String', $this, FALSE, 'false');
283+
$isSuppressEventFullMessage = $noFullMsg !== 'false';
284+
$statusMessage = ($this->isEventFull() && !$isSuppressEventFullMessage && !$isAlreadyRegistered) ? $this->getEventValue('event_full_text') : '';
285+
if (($this->isEventFull() && $noFullMsg === 'false') || $isAlreadyRegistered) {
286+
if ($isAlreadyRegistered) {
287+
// @todo - this usage of `$isSuppressEventFullMessage` is where the historical mis-use makes it
288+
// confusing - better use of cid in the url would help.
289+
if (!$isSuppressEventFullMessage) {
285290
if ($values['event']['allow_same_participant_emails']) {
286291
$statusMessage = ts('It looks like you are already registered for this event. You may proceed if you want to create an additional registration.');
287292
}
@@ -377,4 +382,19 @@ public function getPriceSetID(): ?int {
377382
return NULL;
378383
}
379384

385+
/**
386+
* @return bool
387+
* @throws \CRM_Core_Exception
388+
*/
389+
public function isAlreadyRegistered(): bool {
390+
$params = [
391+
// @todo - instead of just checking logged in user check for cid=0 or an integer
392+
// in the url. (For zero there should be no check).
393+
'contact_id' => CRM_Core_Session::getLoggedInContactID(),
394+
'event_id' => $this->getEventID(),
395+
'role_id' => $this->getEventValue('default_role_id'),
396+
];
397+
return CRM_Event_BAO_Event::checkRegistration($params);
398+
}
399+
380400
}

Civi/Test/PageWrapper.php

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Civi\Civi\Test;
1313

14-
use Civi\Api4\Utils\ReflectionUtils;
15-
1614
class PageWrapper {
1715

1816
/**

tests/phpunit/CRM/Event/Page/EventInfoTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
class CRM_Event_Page_EventInfoTest extends CiviUnitTestCase {
66
use EventTestTrait;
77

8-
98
public function tearDown(): void {
109
$this->quickCleanUpFinancialEntities();
1110
parent::tearDown();

0 commit comments

Comments
 (0)