From b6a469c552b1ec96186643c4cae2723b669fecfb Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 5 Apr 2013 14:19:26 -0700 Subject: [PATCH] Fix event payment fields display CRM-12279 --- CRM/Contribute/Form/Contribution/Main.php | 15 +++++++-------- CRM/Event/Form/Registration/Register.php | 16 +++++++++------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 0f31fbae11..332ebcba8c 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -387,7 +387,6 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu TRUE ); $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email'); - $this->_paymentProcessors = $this->get('paymentProcessors'); $pps = array(); if (!empty($this->_paymentProcessors)) { $pps = $this->_paymentProcessors; @@ -1336,13 +1335,13 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu * Handle Payment Processor switching * For contribution and event registration forms */ - static function preProcessPaymentOptions(&$form) { + static function preProcessPaymentOptions(&$form, $noFees = FALSE) { $form->_snippet = CRM_Utils_Array::value('snippet', $_GET); $form->assign('snippet', $form->_snippet); - $paymentProcessors = $form->get('paymentProcessors'); + $form->_paymentProcessors = $noFees ? array() : $form->get('paymentProcessors'); $form->_ppType = NULL; - if ($paymentProcessors) { + if ($form->_paymentProcessors) { // Fetch type during ajax request if (isset($_GET['type']) && $form->_snippet) { $form->_ppType = $_GET['type']; @@ -1350,15 +1349,15 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu // Remember type during form post elseif (!empty($form->_submitValues)) { $form->_ppType = CRM_Utils_Array::value('payment_processor', $form->_submitValues); - $form->_paymentProcessor = CRM_Utils_Array::value($form->_ppType, $paymentProcessors); + $form->_paymentProcessor = CRM_Utils_Array::value($form->_ppType, $form->_paymentProcessors); $form->set('type', $form->_ppType); $form->set('mode', $form->_mode); $form->set('paymentProcessor', $form->_paymentProcessor); } // Set default payment processor else { - foreach ($paymentProcessors as $values) { - if (!empty($values['is_default']) || count($paymentProcessors) == 1) { + foreach ($form->_paymentProcessors as $values) { + if (!empty($values['is_default']) || count($form->_paymentProcessors) == 1) { $form->_ppType = $values['id']; break; } @@ -1369,7 +1368,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu } //get payPal express id and make it available to template - foreach ($paymentProcessors as $ppId => $values) { + foreach ($form->_paymentProcessors as $ppId => $values) { $payPalExpressId = ($values['payment_processor_type'] == 'PayPal_Express') ? $values['id'] : 0; $form->assign('payPalExpressId', $payPalExpressId); if ($payPalExpressId) { diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index b9f97a3640..df56a419a1 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -80,18 +80,21 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { function preProcess() { parent::preProcess(); - CRM_Contribute_Form_Contribution_Main::preProcessPaymentOptions($this); - if ($this->_snippet) { - return; - } - //CRM-4320. //here we can't use parent $this->_allowWaitlist as user might //walk back and we maight set this value in this postProcess. //(we set when spaces < group count and want to allow become part of waiting ) - $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $this->_values['event'])); + // Get payment processors if appropriate for this event + // We hide the payment fields if the event is full or requires approval, + // and the current user has not yet been approved CRM-12279 + $noFees = (($eventFull || $this->_requireApproval) && !$this->_allowConfirmation); + CRM_Contribute_Form_Contribution_Main::preProcessPaymentOptions($this, $noFees); + if ($this->_snippet) { + return; + } + $this->_allowWaitlist = FALSE; if ($eventFull && !$this->_allowConfirmation && CRM_Utils_Array::value('has_waitlist', $this->_values['event']) @@ -413,7 +416,6 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { } $pps = NULL; - $this->_paymentProcessors = $this->get('paymentProcessors'); if (!empty($this->_paymentProcessors)) { $pps = $this->_paymentProcessors; foreach ($pps as $key => & $name) { -- 2.25.1