Rationalise url variables onto shared parent for recurring contribution forms
authoreileen <emcnaughton@wikimedia.org>
Mon, 1 Apr 2019 23:37:36 +0000 (12:37 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 2 Apr 2019 19:52:51 +0000 (08:52 +1300)
CRM/Contribute/Form/CancelSubscription.php
CRM/Contribute/Form/ContributionRecur.php
CRM/Contribute/Form/UpdateBilling.php
CRM/Contribute/Form/UpdateSubscription.php

index e596ad54ee36f8bc2f0cff881751c5c7e812fa92..1ac38e03e3ea82d310402861b434a635d66b0088 100644 (file)
@@ -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.'));
index 8363ab5b5a0575e1829694d9ae08fbef76867d18..d0b1ee2873ad50d109940914d4f94071455d3dcd 100644 (file)
@@ -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);
+  }
+
 }
index eab578a3725cb2048f38eb690066f4972a873209..03c3b80c71724a36ea8908bf7f1b4a425cab1b92 100644 (file)
@@ -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');
index 2b713af9206b1d17bac78ce63377bd3cb02fcb9a..c1a092e53cbe31f0b876bfd9d47efec98e66197a 100644 (file)
  */
 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']);