Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple registrations from search actions #26303

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions CRM/Event/Form/Task/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ public function postProcess(): void {
$event_id = $params['event_id'];
}
if (!empty($event_id)) {
$allowSameParticipantEmails = \Civi\Api4\Event::get()
->addSelect('allow_same_participant_emails')->addWhere('id', '=', $event_id)->execute()
->first()['allow_same_participant_emails'];
$duplicateContacts = 0;
foreach ($this->_contactIds as $k => $dupeCheckContactId) {
// Eliminate contacts that have already been assigned to this event.
Expand All @@ -118,14 +121,24 @@ public function postProcess(): void {
$dupeCheck->find(TRUE);
if (!empty($dupeCheck->id)) {
$duplicateContacts++;
unset($this->_contactIds[$k]);
if (!$allowSameParticipantEmails) {
unset($this->_contactIds[$k]);
}
}
}
if ($duplicateContacts > 0) {
$msg = ts(
'%1 contacts have already been assigned to this event. They were not added a second time.',
[1 => $duplicateContacts]
);
if ($allowSameParticipantEmails) {
$msg = ts(
'%1 contacts were already registered for this event, but have been added a second time.',
[1 => $duplicateContacts]
);
}
else {
$msg = ts(
'%1 contacts have already been assigned to this event. They were not added a second time.',
[1 => $duplicateContacts]
);
}
CRM_Core_Session::setStatus($msg);
}
if (count($this->_contactIds) === 0) {
Expand All @@ -137,7 +150,6 @@ public function postProcess(): void {
// will be created below.
$this->_contactIds = array_values($this->_contactIds);
}

$statusMsg = $this->submit($params);
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
}
Expand Down