Towards CRM-20392 form cleanup, shared setting of ->mode
authoreileen <emcnaughton@wikimedia.org>
Tue, 11 Apr 2017 11:53:16 +0000 (23:53 +1200)
committerdeb.monish <monish.deb@jmaconsulting.biz>
Wed, 12 Apr 2017 08:57:17 +0000 (14:27 +0530)
CRM/Contribute/Form/AbstractEditPayment.php
CRM/Contribute/Form/AdditionalPayment.php
CRM/Contribute/Form/Contribution.php

index 80bc7cee67f0fc956296668d75530cc7164097cf..dbab4cc87e46f054af99324a3fe5f574c1bb55ae 100644 (file)
@@ -213,6 +213,7 @@ class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task {
     $this->assign('contactID', $this->_contactID);
     CRM_Core_Resources::singleton()->addVars('coreForm', array('contact_id' => (int) $this->_contactID));
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
+    $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
   }
 
   /**
index 7476bf7b886f9a6450315c712acb211796be684c..387144a170bf50c09b54c19c67f72abfe8ecc9f2 100644 (file)
@@ -74,6 +74,8 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
   public $_action = NULL;
 
   public function preProcess() {
+
+    parent::preProcess();
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->_component = CRM_Utils_Request::retrieve('component', 'String', $this, TRUE);
@@ -130,9 +132,6 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
       CRM_Core_Error::fatal(ts('No payment information found for this record'));
     }
 
-    //set the payment mode - _mode property is defined in parent class
-    $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
-
     if (!empty($this->_mode) && $this->_paymentType == 'refund') {
       CRM_Core_Error::fatal(ts('Credit card payment is not for Refund payments use'));
     }
index 2d14c152ab4051239a25612876a07c34bd4b8fd3..95c8e4cc910e155ee164d65ae0a7ea5a27a1f5bc 100644 (file)
@@ -211,6 +211,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
   public function preProcess() {
     // Check permission for action.
     if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
+      // @todo replace with throw new CRM_Core_Exception().
       CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }