From 8f262a0b72df56db4bdf9777082cc62f8b22b7e2 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 11 Apr 2017 23:53:16 +1200 Subject: [PATCH] Towards CRM-20392 form cleanup, shared setting of ->mode --- CRM/Contribute/Form/AbstractEditPayment.php | 1 + CRM/Contribute/Form/AdditionalPayment.php | 5 ++--- CRM/Contribute/Form/Contribution.php | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index 80bc7cee67..dbab4cc87e 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -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); } /** diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index 7476bf7b88..387144a170 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -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')); } diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 2d14c152ab..95c8e4cc91 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -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.')); } -- 2.25.1