From 1f17c8ef2789ce8124490854454f38fa9bc812ab Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 2 Apr 2019 12:37:36 +1300 Subject: [PATCH] Rationalise url variables onto shared parent for recurring contribution forms --- CRM/Contribute/Form/CancelSubscription.php | 7 +----- CRM/Contribute/Form/ContributionRecur.php | 25 ++++++++++++++++++++++ CRM/Contribute/Form/UpdateBilling.php | 4 +--- CRM/Contribute/Form/UpdateSubscription.php | 10 +-------- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/CRM/Contribute/Form/CancelSubscription.php b/CRM/Contribute/Form/CancelSubscription.php index e596ad54ee..1ac38e03e3 100644 --- a/CRM/Contribute/Form/CancelSubscription.php +++ b/CRM/Contribute/Form/CancelSubscription.php @@ -41,17 +41,13 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib protected $_mode = NULL; - protected $_mid = NULL; - protected $_selfService = FALSE; /** * Set variables up before form is built. */ public function preProcess() { - $this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE); - - $this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE); + parent::preProcess(); if ($this->_crid) { $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj'); $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid); @@ -80,7 +76,6 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib $this->assign('membershipType', CRM_Utils_Array::value($membershipTypeId, $membershipTypes)); } - $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE); if ($this->_coid) { if (CRM_Contribute_BAO_Contribution::isSubscriptionCancelled($this->_coid)) { CRM_Core_Error::fatal(ts('The recurring contribution looks to have been cancelled already.')); diff --git a/CRM/Contribute/Form/ContributionRecur.php b/CRM/Contribute/Form/ContributionRecur.php index 8363ab5b5a..d0b1ee2873 100644 --- a/CRM/Contribute/Form/ContributionRecur.php +++ b/CRM/Contribute/Form/ContributionRecur.php @@ -46,6 +46,21 @@ class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form { */ protected $_crid = NULL; + /** + * The recurring contribution id, used when editing the recurring contribution. + * + * For historical reasons this duplicates _crid & since the name is more meaningful + * we should probably deprecate $_crid. + * + * @var int + */ + protected $contributionRecurID = NULL; + + /** + * @var int Membership ID + */ + protected $_mid = NULL; + /** * Explicitly declare the entity api name. */ @@ -60,4 +75,14 @@ class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form { return 'create'; } + /** + * Set variables up before form is built. + */ + public function preProcess() { + $this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE); + $this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE); + $this->contributionRecurID = $this->_crid; + $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE); + } + } diff --git a/CRM/Contribute/Form/UpdateBilling.php b/CRM/Contribute/Form/UpdateBilling.php index eab578a372..03c3b80c71 100644 --- a/CRM/Contribute/Form/UpdateBilling.php +++ b/CRM/Contribute/Form/UpdateBilling.php @@ -52,8 +52,7 @@ class CRM_Contribute_Form_UpdateBilling extends CRM_Contribute_Form_Contribution * Set variables up before form is built. */ public function preProcess() { - $this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE); - $this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE); + parent::preProcess(); if ($this->_crid) { $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'info'); $this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj'); @@ -65,7 +64,6 @@ class CRM_Contribute_Form_UpdateBilling extends CRM_Contribute_Form_Contribution } } - $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE); if ($this->_coid) { $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info'); $this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj'); diff --git a/CRM/Contribute/Form/UpdateSubscription.php b/CRM/Contribute/Form/UpdateSubscription.php index 2b713af920..c1a092e53c 100644 --- a/CRM/Contribute/Form/UpdateSubscription.php +++ b/CRM/Contribute/Form/UpdateSubscription.php @@ -39,13 +39,6 @@ */ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_ContributionRecur { - /** - * The recurring contribution id, used when editing the recurring contribution. - * - * @var int - */ - protected $contributionRecurID = NULL; - protected $_subscriptionDetails = NULL; protected $_selfService = FALSE; @@ -75,9 +68,9 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib */ public function preProcess() { + parent::preProcess(); $this->setAction(CRM_Core_Action::UPDATE); - $this->contributionRecurID = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE); if ($this->contributionRecurID) { try { $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorForRecurringContribution($this->contributionRecurID); @@ -91,7 +84,6 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->contributionRecurID); } - $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE); if ($this->_coid) { $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info'); // @todo test & replace with $this->_paymentProcessorObj = Civi\Payment\System::singleton()->getById($this->_paymentProcessor['id']); -- 2.25.1