Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Move Self service handlng to shared function to allow for use i… #14963

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

}