From 6a2b3da25677525fbca3860229f51e8b98d227db Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Fri, 5 Jun 2020 10:45:29 +0100 Subject: [PATCH] Add isBackOffice, isPayLater, getPaymentMode helpers to frontendpaymentformtrait --- CRM/Event/Form/Registration.php | 13 +--- CRM/Event/Form/Registration/Register.php | 2 +- .../Form/FrontEndPaymentFormTrait.php | 59 +++++++++++++++++++ 3 files changed, 61 insertions(+), 13 deletions(-) diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index 8e69eb560e..638f2b8f2d 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -78,14 +78,6 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { */ public $_additionalParticipantIds; - /** - * The mode that we are in. - * - * @var string - * @protect - */ - public $_mode; - /** * The values for the contribution db object. * @@ -182,12 +174,9 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { public function preProcess() { $this->_eventId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); $this->_action = CRM_Utils_Request::retrieve('action', 'Alphanumeric', $this, FALSE, CRM_Core_Action::ADD); - //CRM-4320 $this->_participantId = CRM_Utils_Request::retrieve('participantId', 'Positive', $this); - - // current mode - $this->_mode = ($this->_action == 1024) ? 'test' : 'live'; + $this->setPaymentMode(); $this->_values = $this->get('values'); $this->_fields = $this->get('fields'); diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index a2bc57ef5f..80e3f7c72f 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -1157,7 +1157,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { // CRM-3907, skip check for preview registrations // CRM-4320 participant need to walk wizard if ( - ($form->_mode == 'test' || $form->_allowConfirmation) + ($form->getPaymentMode() === 'test' || $form->_allowConfirmation) ) { return FALSE; } diff --git a/CRM/Financial/Form/FrontEndPaymentFormTrait.php b/CRM/Financial/Form/FrontEndPaymentFormTrait.php index 1f29680112..dbf787e27d 100644 --- a/CRM/Financial/Form/FrontEndPaymentFormTrait.php +++ b/CRM/Financial/Form/FrontEndPaymentFormTrait.php @@ -20,6 +20,13 @@ */ trait CRM_Financial_Form_FrontEndPaymentFormTrait { + /** + * Is pay later enabled on this form? + * + * @var bool + */ + protected $isPayLater = FALSE; + /** * The label for the pay later pseudoprocessor option. * @@ -27,6 +34,58 @@ trait CRM_Financial_Form_FrontEndPaymentFormTrait { */ protected $payLaterLabel; + /** + * Is this a back office form + * + * @var bool + */ + public $isBackOffice = FALSE; + + /** + * The payment mode that we are in ("live" or "test") + * This should be protected and retrieved via getPaymentMode() but it's accessed all over the place so we have to leave it public for now. + * + * @var string + */ + public $_mode; + + /** + * @return bool + */ + public function isPayLater() { + return $this->isPayLater; + } + + /** + * @param bool $isPayLater + */ + public function setIsPayLater($isPayLater) { + $this->isPayLater = $isPayLater; + } + + /** + * @return bool + */ + public function getIsBackOffice() { + return $this->isBackOffice; + } + + /** + * Get the payment mode ('live' or 'test') + * + * @return string + */ + public function getPaymentMode() { + return $this->_mode; + } + + /** + * Set the payment mode ('live' or 'test') + */ + public function setPaymentMode() { + $this->_mode = ($this->_action === CRM_Core_Action::PREVIEW) ? 'test' : 'live'; + } + /** * @return string */ -- 2.25.1