ffe7a7458c8a08e2fbaa0999440a95a324ab1d6d
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
35 class CRM_Pledge_Page_Tab
extends CRM_Core_Page
{
36 public $_permission = NULL;
37 public $_contactId = NULL;
40 * This function is called when action is browse
45 public function browse() {
46 $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_Search', ts('Pledges'), $this->_action
);
47 $controller->setEmbedded(TRUE);
49 $controller->set('cid', $this->_contactId
);
50 $controller->set('context', 'pledge');
51 $controller->set('limit', '25');
52 $controller->process();
55 if ($this->_contactId
) {
56 $displayName = CRM_Contact_BAO_Contact
::displayName($this->_contactId
);
57 $this->assign('displayName', $displayName);
58 $this->ajaxResponse
['tabCount'] = CRM_Contact_BAO_Contact
::getCountComponent('pledge', $this->_contactId
);
59 // Refresh other tabs with related data
60 $this->ajaxResponse
['updateTabs'] = array(
61 '#tab_contribute' => CRM_Contact_BAO_Contact
::getCountComponent('contribution', $this->_contactId
),
62 '#tab_activity' => CRM_Contact_BAO_Contact
::getCountComponent('activity', $this->_contactId
),
68 * This function is called when action is view
73 public function view() {
74 $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_PledgeView',
78 $controller->setEmbedded(TRUE);
79 $controller->set('id', $this->_id
);
80 $controller->set('cid', $this->_contactId
);
82 return $controller->run();
86 * This function is called when action is update or new
91 public function edit() {
92 $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_Pledge',
96 $controller->setEmbedded(TRUE);
97 $controller->set('id', $this->_id
);
98 $controller->set('cid', $this->_contactId
);
100 return $controller->run();
103 public function preProcess() {
104 $context = CRM_Utils_Request
::retrieve('context', 'String', $this);
105 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'browse');
106 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
108 if ($context == 'standalone') {
109 $this->_action
= CRM_Core_Action
::ADD
;
112 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE);
113 $this->assign('contactId', $this->_contactId
);
115 // check logged in url permission
116 CRM_Contact_Page_View
::checkUserPermission($this);
119 $this->assign('action', $this->_action
);
121 if ($this->_permission
== CRM_Core_Permission
::EDIT
&& !CRM_Core_Permission
::check('edit pledges')) {
122 // demote to view since user does not have edit pledge rights
123 $this->_permission
= CRM_Core_Permission
::VIEW
;
124 $this->assign('permission', 'view');
129 * This function is the main function that is called when the page loads, it decides the which action has to be taken for the page.
134 public function run() {
137 // check if we can process credit card registration
138 $this->assign('newCredit', CRM_Core_Config
::isEnabledBackOfficeCreditCardPayments());
140 self
::setContext($this);
142 if ($this->_action
& CRM_Core_Action
::VIEW
) {
145 elseif ($this->_action
& (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD | CRM_Core_Action
::DELETE
)) {
148 elseif ($this->_action
& CRM_Core_Action
::DETACH
) {
149 CRM_Pledge_BAO_Pledge
::cancel($this->_id
);
150 $session = CRM_Core_Session
::singleton();
151 $session->setStatus(ts('Pledge has been Cancelled and all scheduled (not completed) payments have been cancelled.<br />'));
152 CRM_Utils_System
::redirect($session->popUserContext());
158 return parent
::run();
161 public static function setContext(&$form) {
162 $context = CRM_Utils_Request
::retrieve('context', 'String', $form, FALSE, 'search');
164 $qfKey = CRM_Utils_Request
::retrieve('key', 'String', $form);
166 if (!CRM_Utils_Rule
::qfKey($qfKey)) {
172 case 'pledgeDashboard':
173 $url = CRM_Utils_System
::url('civicrm/pledge', 'reset=1');
177 $urlParams = 'force=1';
179 $urlParams .= "&qfKey=$qfKey";
182 $url = CRM_Utils_System
::url('civicrm/pledge/search', $urlParams);
186 $url = CRM_Utils_System
::url('civicrm/user', 'reset=1');
190 $url = CRM_Utils_System
::url('civicrm/contact/view',
191 "reset=1&force=1&cid={$form->_contactId}&selectedChild=pledge"
196 $url = CRM_Utils_System
::url('civicrm/dashboard', 'force=1');
200 $url = CRM_Utils_System
::url('civicrm/contact/view',
201 "reset=1&force=1&cid={$form->_contactId}&selectedChild=activity"
206 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
211 if ($form->_contactId
) {
212 $cid = '&cid=' . $form->_contactId
;
214 $url = CRM_Utils_System
::url('civicrm/pledge/search',
219 $session = CRM_Core_Session
::singleton();
220 $session->pushUserContext($url);