From 33744cdabdaa17a3cb9b3bc75cca7467b0d27171 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 7 Aug 2023 13:41:00 +1200 Subject: [PATCH] Separate getStatusMessage function The CRM_Event_Form_Task_Register form was once part of CRM_Event_Form_Participant It now extends it & the goal is to disentangle it from the parent. In general _single is only set for the parent & describes actions for that whereas the Register form is a task that can act on many --- CRM/Event/Form/Participant.php | 17 +++-------------- CRM/Event/Form/Task/Register.php | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index c82d7a1c67..7b7a2a4b02 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1400,20 +1400,9 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment } } elseif ($this->_action & CRM_Core_Action::ADD) { - if ($this->_single) { - $statusMsg = ts('Event registration for %1 has been added.', [1 => $this->_contributorDisplayName]); - if (!empty($params['send_receipt']) && $numberSent) { - $statusMsg .= ' ' . ts('A confirmation email has been sent to %1.', [1 => $this->_contributorEmail]); - } - } - else { - $statusMsg = ts('Total Participant(s) added to event: %1.', [1 => count($this->_contactIds)]); - if ($numberNotSent > 0) { - $statusMsg .= ' ' . ts('Email has NOT been sent to %1 contact(s) - communication preferences specify DO NOT EMAIL OR valid Email is NOT present. ', [1 => $numberNotSent]); - } - elseif (isset($params['send_receipt'])) { - $statusMsg .= ' ' . ts('A confirmation email has been sent to ALL participants'); - } + $statusMsg = ts('Event registration for %1 has been added.', [1 => $this->_contributorDisplayName]); + if (!empty($params['send_receipt']) && $numberSent) { + $statusMsg .= ' ' . ts('A confirmation email has been sent to %1.', [1 => $this->_contributorEmail]); } } return $statusMsg; diff --git a/CRM/Event/Form/Task/Register.php b/CRM/Event/Form/Task/Register.php index 2b8d9a12f6..e30f912657 100644 --- a/CRM/Event/Form/Task/Register.php +++ b/CRM/Event/Form/Task/Register.php @@ -154,6 +154,30 @@ class CRM_Event_Form_Task_Register extends CRM_Event_Form_Participant { CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success'); } + /** + * Get status message + * + * @param array $params + * @param int $numberSent + * @param int $numberNotSent + * @param string $updateStatusMsg + * + * @return string + */ + protected function getStatusMsg(array $params, int $numberSent, int $numberNotSent, string $updateStatusMsg): string { + $statusMsg = ''; + if ($this->_action & CRM_Core_Action::ADD) { + $statusMsg = ts('Total Participant(s) added to event: %1.', [1 => count($this->_contactIds)]); + if ($numberNotSent > 0) { + $statusMsg .= ' ' . ts('Email has NOT been sent to %1 contact(s) - communication preferences specify DO NOT EMAIL OR valid Email is NOT present. ', [1 => $numberNotSent]); + } + elseif (isset($params['send_receipt'])) { + $statusMsg .= ' ' . ts('A confirmation email has been sent to ALL participants'); + } + } + return $statusMsg; + } + /** * Add local and global form rules. * -- 2.25.1