+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
+ | Copyright CiviCRM LLC (c) 2004-2020 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC (c) 2004-2020
*/
/**
protected $_mode = NULL;
- protected $_selfService = FALSE;
+ /**
+ * Should custom data be suppressed on this form.
+ *
+ * We override to suppress custom data because historically it has not been
+ * shown on this form & we don't want to expose it as a by-product of
+ * other change without establishing that it would be good on this form.
+ *
+ * @return bool
+ */
+ protected function isSuppressCustomData() {
+ return TRUE;
+ }
/**
* Set variables up before form is built.
$this->_mode = 'auto_renew';
// CRM-18468: crid is more accurate than mid for getting
// subscriptionDetails, so don't get them again.
- if (!$this->_crid) {
- $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_mid, 'membership', 'obj');
- $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_mid, 'membership');
- }
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
$membershipTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_mid, 'membership_type_id');
(!$this->_crid && !$this->_coid && !$this->_mid) ||
(!$this->_subscriptionDetails)
) {
- CRM_Core_Error::fatal('Required information missing.');
- }
-
- 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;
+ CRM_Core_Error::statusBounce('Required information missing.');
}
- $this->assign('self_service', $this->_selfService);
// handle context redirection
CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext();
CRM_Utils_System::setTitle($this->_mid ? ts('Cancel Auto-renewal') : ts('Cancel Recurring Contribution'));
$this->assign('mode', $this->_mode);
+ if ($this->isSelfService()) {
+ unset($this->entityFields['send_cancel_request'], $this->entityFields['is_notify']);
+ }
+
if ($this->_subscriptionDetails->contact_id) {
list($this->_donorDisplayName, $this->_donorEmail)
= CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
}
}
+ /**
+ * Set entity fields for this cancellation.
+ */
+ public function setEntityFields() {
+ $this->entityFields = [
+ 'cancel_reason' => ['name' => 'cancel_reason'],
+ ];
+ $this->entityFields['send_cancel_request'] = [
+ 'title' => ts('Send cancellation request?'),
+ 'name' => 'send_cancel_request',
+ 'not-auto-addable' => TRUE,
+ ];
+ $this->entityFields['is_notify'] = [
+ 'title' => ts('Notify Contributor?'),
+ 'name' => 'is_notify',
+ 'not-auto-addable' => TRUE,
+ ];
+ }
+
/**
* Build the form object.
*/
public function buildQuickForm() {
+ $this->buildQuickEntityForm();
// Determine if we can cancel recurring contribution via API with this processor
$cancelSupported = $this->_paymentProcessorObj->supports('CancelRecurring');
if ($cancelSupported) {
}
$type = 'next';
- if ($this->_selfService) {
+ if ($this->isSelfService()) {
$type = 'submit';
}
$cancelSubscription = TRUE;
$params = $this->controller->exportValues($this->_name);
- if ($this->_selfService) {
+ if ($this->isSelfService()) {
// for self service force sending-request & notify
if ($this->_paymentProcessorObj->supports('cancelRecurring')) {
$params['send_cancel_request'] = 1;
'id' => $this->_subscriptionDetails->recur_id,
'membership_id' => $this->_mid,
'processor_message' => $message,
+ 'cancel_reason' => $params['cancel_reason'],
]);
$tplParams = [];