3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Main page for viewing Recurring Contributions.
21 class CRM_Contribute_Page_ContributionRecur
extends CRM_Core_Page
{
23 public static $_links = NULL;
24 public $_permission = NULL;
25 public $_contactId = NULL;
27 public $_action = NULL;
30 * View details of a recurring contribution.
32 public function view() {
33 if (empty($this->_id
)) {
34 CRM_Core_Error
::statusBounce('Recurring contribution not found');
38 $contributionRecur = civicrm_api3('ContributionRecur', 'getsingle', [
42 catch (Exception
$e) {
43 CRM_Core_Error
::statusBounce('Recurring contribution not found (ID: ' . $this->_id
);
46 $contributionRecur['payment_processor'] = CRM_Financial_BAO_PaymentProcessor
::getPaymentProcessorName(
47 CRM_Utils_Array
::value('payment_processor_id', $contributionRecur)
49 $idFields = ['contribution_status_id', 'campaign_id', 'financial_type_id'];
50 foreach ($idFields as $idField) {
51 if (!empty($contributionRecur[$idField])) {
52 $contributionRecur[substr($idField, 0, -3)] = CRM_Core_PseudoConstant
::getLabel('CRM_Contribute_BAO_ContributionRecur', $idField, $contributionRecur[$idField]);
56 // Add linked membership
57 $membership = civicrm_api3('Membership', 'get', [
58 'contribution_recur_id' => $contributionRecur['id'],
60 if (!empty($membership['count'])) {
61 $membershipDetails = reset($membership['values']);
62 $contributionRecur['membership_id'] = $membershipDetails['id'];
63 $contributionRecur['membership_name'] = $membershipDetails['membership_name'];
66 $groupTree = CRM_Core_BAO_CustomGroup
::getTree('ContributionRecur', NULL, $contributionRecur['id']);
67 CRM_Core_BAO_CustomGroup
::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $contributionRecur['id']);
69 $this->assign('recur', $contributionRecur);
71 $displayName = CRM_Contact_BAO_Contact
::displayName($contributionRecur['contact_id']);
72 $this->assign('displayName', $displayName);
74 // Check if this is default domain contact CRM-10482
75 if (CRM_Contact_BAO_Contact
::checkDomainContact($contributionRecur['contact_id'])) {
76 $displayName .= ' (' . ts('default organization') . ')';
79 // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
80 CRM_Utils_System
::setTitle(ts('View Recurring Contribution from') . ' ' . $displayName);
83 public function preProcess() {
84 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'view');
85 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
86 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE);
87 $this->assign('contactId', $this->_contactId
);
89 // check logged in url permission
90 CRM_Contact_Page_View
::checkUserPermission($this);
92 $this->assign('action', $this->_action
);
94 if ($this->_permission
== CRM_Core_Permission
::EDIT
&& !CRM_Core_Permission
::check('edit contributions')) {
95 // demote to view since user does not have edit contrib rights
96 $this->_permission
= CRM_Core_Permission
::VIEW
;
97 $this->assign('permission', 'view');
102 * the main function that is called when the page loads,
103 * it decides the which action has to be taken for the page.
107 public function run() {
110 if ($this->_action
& CRM_Core_Action
::VIEW
) {
114 return parent
::run();