From 6a719e23435befd13f7a75fa6295e4783c53f579 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 5 Aug 2019 11:38:45 +1000 Subject: [PATCH] [REF] Move Self service handlng to shared function to allow for use in other contribution recur functions --- CRM/Contribute/Form/CancelSubscription.php | 26 ---------------------- CRM/Contribute/Form/ContributionRecur.php | 26 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/CRM/Contribute/Form/CancelSubscription.php b/CRM/Contribute/Form/CancelSubscription.php index d65e8d39478a..ef9dbe32ca32 100644 --- a/CRM/Contribute/Form/CancelSubscription.php +++ b/CRM/Contribute/Form/CancelSubscription.php @@ -53,13 +53,6 @@ protected function isSuppressCustomData() { return TRUE; } - /** - * Is the from being accessed by a front end user to update their own recurring. - * - * @var bool - */ - protected $selfService; - /** * Set variables up before form is built. * @@ -339,23 +332,4 @@ public function postProcess() { } } - /** - * Is this being used by a front end user to update their own recurring. - * - * @return bool - */ - protected function isSelfService() { - if (!is_null($this->selfService)) { - return $this->selfService; - } - $this->selfService = FALSE; - if (!CRM_Core_Permission::check('edit contributions')) { - if ($this->_subscriptionDetails->contact_id != $this->getContactID()) { - CRM_Core_Error::statusBounce(ts('You do not have permission to cancel this recurring contribution.')); - } - $this->selfService = TRUE; - } - return $this->selfService; - } - } diff --git a/CRM/Contribute/Form/ContributionRecur.php b/CRM/Contribute/Form/ContributionRecur.php index 9e96e10d1483..2ec9a2fbc67c 100644 --- a/CRM/Contribute/Form/ContributionRecur.php +++ b/CRM/Contribute/Form/ContributionRecur.php @@ -107,6 +107,13 @@ class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form { */ protected $subscriptionDetails = []; + /** + * Is the from being accessed by a front end user to update their own recurring. + * + * @var bool + */ + protected $selfService; + /** * Explicitly declare the entity api name. */ @@ -204,4 +211,23 @@ protected function getSubscriptionContactID() { return isset($sub->contact_id) ? $sub->contact_id : FALSE; } + /** + * Is this being used by a front end user to update their own recurring. + * + * @return bool + */ + protected function isSelfService() { + if (!is_null($this->selfService)) { + return $this->selfService; + } + $this->selfService = FALSE; + if (!CRM_Core_Permission::check('edit contributions')) { + if ($this->_subscriptionDetails->contact_id != $this->getContactID()) { + CRM_Core_Error::statusBounce(ts('You do not have permission to cancel this recurring contribution.')); + } + $this->selfService = TRUE; + } + return $this->selfService; + } + }