Consolidate fee preProcess into feeBuildForm
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 28 Nov 2023 21:42:15 +0000 (10:42 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 28 Nov 2023 21:42:15 +0000 (10:42 +1300)
CRM/Event/Form/EventFees.php
CRM/Event/Form/Participant.php

index 32a3f10ead3b1d6aadaf0ae2925ecb625cd4d6e9..8da6bdeaa8c515f0fb4735f74afa76d710cb79c7 100644 (file)
@@ -24,11 +24,14 @@ class CRM_Event_Form_EventFees {
   /**
    * Set variables up before form is built.
    *
+   * @deprecated since 5.69 will be removed around 5.74
+   *
    * @param CRM_Core_Form $form
    *
    * @throws \CRM_Core_Exception
    */
   public static function preProcess(&$form) {
+    CRM_Core_Error::deprecatedFunctionWarning('no alternative');
     //as when call come from register.php
     if (!$form->_eventId) {
       $form->_eventId = CRM_Utils_Request::retrieve('eventId', 'Positive', $form);
index 60ec4555209e44f0110c9ca0c732867d54d8c88f..2d846e993418aa9dc793fbfe3726f6a0f3dee1de 100644 (file)
@@ -295,7 +295,6 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $_GET['eventId'], 'is_monetary')) {
         $this->assign('feeBlockPaid', TRUE);
       }
-      CRM_Event_Form_EventFees::preProcess($this);
       return;
     }
 
@@ -318,7 +317,6 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       if ($this->_submitValues['event_id']) {
         $this->_eventId = (int) $this->_submitValues['event_id'];
       }
-      CRM_Event_Form_EventFees::preProcess($this);
       $this->buildEventFeeForm($this);
       CRM_Event_Form_EventFees::setDefaultValues($this);
     }
@@ -1238,6 +1236,20 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
    * @throws \Exception
    */
   public function buildEventFeeForm($form) {
+    //as when call come from register.php
+    if (!$form->_eventId) {
+      $form->_eventId = CRM_Utils_Request::retrieve('eventId', 'Positive', $form);
+    }
+
+    $form->_pId = CRM_Utils_Request::retrieve('participantId', 'Positive', $form);
+    $form->_discountId = CRM_Utils_Request::retrieve('discountId', 'Positive', $form);
+
+    //CRM-6907 set event specific currency.
+    if ($form->_eventId &&
+      ($currency = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'currency'))
+    ) {
+      CRM_Core_Config::singleton()->defaultCurrency = $currency;
+    }
     if ($form->_eventId) {
       $form->_isPaidEvent = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'is_monetary');
       if ($form->_isPaidEvent) {