3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
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
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->process();
54 if ($this->_contactId
) {
55 $displayName = CRM_Contact_BAO_Contact
::displayName($this->_contactId
);
56 $this->assign('displayName', $displayName);
57 $this->ajaxResponse
['tabCount'] = CRM_Contact_BAO_Contact
::getCountComponent('pledge', $this->_contactId
);
62 * This function is called when action is view
68 $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_PledgeView',
72 $controller->setEmbedded(TRUE);
73 $controller->set('id', $this->_id
);
74 $controller->set('cid', $this->_contactId
);
76 return $controller->run();
80 * This function is called when action is update or new
86 $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_Pledge',
90 $controller->setEmbedded(TRUE);
91 $controller->set('id', $this->_id
);
92 $controller->set('cid', $this->_contactId
);
94 return $controller->run();
97 function preProcess() {
98 $context = CRM_Utils_Request
::retrieve('context', 'String', $this);
99 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'browse');
100 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
102 if ($context == 'standalone') {
103 $this->_action
= CRM_Core_Action
::ADD
;
106 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE);
107 $this->assign('contactId', $this->_contactId
);
109 // check logged in url permission
110 CRM_Contact_Page_View
::checkUserPermission($this);
113 CRM_Contact_Page_View
::setTitle($this->_contactId
);
116 $this->assign('action', $this->_action
);
118 if ($this->_permission
== CRM_Core_Permission
::EDIT
&& !CRM_Core_Permission
::check('edit pledges')) {
119 // demote to view since user does not have edit pledge rights
120 $this->_permission
= CRM_Core_Permission
::VIEW
;
121 $this->assign('permission', 'view');
126 * 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 // check if we can process credit card registration
135 CRM_Core_Payment
::allowBackofficeCreditCard($this);
139 if ($this->_action
& CRM_Core_Action
::VIEW
) {
142 elseif ($this->_action
& (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD | CRM_Core_Action
::DELETE
)) {
145 elseif ($this->_action
& CRM_Core_Action
::DETACH
) {
146 CRM_Pledge_BAO_Pledge
::cancel($this->_id
);
147 $session = CRM_Core_Session
::singleton();
148 $session->setStatus(ts('Pledge has been Cancelled and all scheduled (not completed) payments have been cancelled.<br />'));
149 CRM_Utils_System
::redirect($session->popUserContext());
155 return parent
::run();
158 function setContext() {
159 $context = CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'search');
161 $qfKey = CRM_Utils_Request
::retrieve('key', 'String', $this);
163 if (!CRM_Utils_Rule
::qfKey($qfKey)) {
169 case 'pledgeDashboard':
170 $url = CRM_Utils_System
::url('civicrm/pledge', 'reset=1');
174 $urlParams = 'force=1';
176 $urlParams .= "&qfKey=$qfKey";
179 $url = CRM_Utils_System
::url('civicrm/pledge/search', $urlParams);
183 $url = CRM_Utils_System
::url('civicrm/user', 'reset=1');
187 $url = CRM_Utils_System
::url('civicrm/contact/view',
188 "reset=1&force=1&cid={$this->_contactId}&selectedChild=pledge"
193 $url = CRM_Utils_System
::url('civicrm/dashboard', 'force=1');
197 $url = CRM_Utils_System
::url('civicrm/contact/view',
198 "reset=1&force=1&cid={$this->_contactId}&selectedChild=activity"
203 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
208 if ($this->_contactId
) {
209 $cid = '&cid=' . $this->_contactId
;
211 $url = CRM_Utils_System
::url('civicrm/pledge/search',
216 $session = CRM_Core_Session
::singleton();
217 $session->pushUserContext($url);