Skip to content

Commit

Permalink
[REF] Move Self service handlng to shared function to allow for use i…
Browse files Browse the repository at this point in the history
…n other contribution recur functions
  • Loading branch information
seamuslee001 committed Aug 5, 2019
1 parent 6c71cee commit 6a719e2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 0 additions & 26 deletions CRM/Contribute/Form/CancelSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}

}
26 changes: 26 additions & 0 deletions CRM/Contribute/Form/ContributionRecur.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;
}

}

0 comments on commit 6a719e2

Please sign in to comment.