3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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_Event_Page_Tab
extends CRM_Core_Page
{
37 public $_permission = NULL;
38 public $_contactId = NULL;
41 * This function is called when action is browse
47 $controller = new CRM_Core_Controller_Simple(
48 'CRM_Event_Form_Search',
52 $controller->setEmbedded(TRUE);
54 $controller->set('cid', $this->_contactId
);
55 $controller->set('context', 'participant');
56 $controller->process();
59 if ($this->_contactId
) {
60 $displayName = CRM_Contact_BAO_Contact
::displayName($this->_contactId
);
61 $this->assign('displayName', $displayName);
62 $this->ajaxResponse
['tabCount'] = CRM_Contact_BAO_Contact
::getCountComponent('participant', $this->_contactId
);
63 // Refresh other tabs with related data
64 $this->ajaxResponse
['updateTabs'] = array(
65 '#tab_activity' => CRM_Contact_BAO_Contact
::getCountComponent('activity', $this->_contactId
),
67 if (CRM_Core_Permission
::access('CiviContribute')) {
68 $this->ajaxResponse
['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact
::getCountComponent('contribution', $this->_contactId
);
74 * This function is called when action is view
80 // build associated contributions
81 $this->associatedContribution();
83 $controller = new CRM_Core_Controller_Simple(
84 'CRM_Event_Form_ParticipantView',
85 ts('View Participant'),
88 $controller->setEmbedded(TRUE);
89 $controller->set('id', $this->_id
);
90 $controller->set('cid', $this->_contactId
);
92 return $controller->run();
96 * This function is called when action is update or new
102 // set https for offline cc transaction
103 $mode = CRM_Utils_Request
::retrieve('mode', 'String', $this);
104 if ($mode == 'test' ||
$mode == 'live') {
105 CRM_Utils_System
::redirectToSSL();
108 if ($this->_action
!= CRM_Core_Action
::ADD
) {
109 // get associated contributions only on edit/delete
110 $this->associatedContribution();
113 $controller = new CRM_Core_Controller_Simple(
114 'CRM_Event_Form_Participant',
115 'Create Participation',
119 $controller->setEmbedded(TRUE);
120 $controller->set('id', $this->_id
);
121 $controller->set('cid', $this->_contactId
);
123 return $controller->run();
126 function preProcess() {
127 $context = CRM_Utils_Request
::retrieve('context', 'String', $this);
128 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'browse');
129 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
131 if ($context == 'standalone') {
132 $this->_action
= CRM_Core_Action
::ADD
;
135 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE);
136 $this->assign('contactId', $this->_contactId
);
138 // check logged in url permission
139 CRM_Contact_Page_View
::checkUserPermission($this);
142 $this->assign('action', $this->_action
);
144 if ($this->_permission
== CRM_Core_Permission
::EDIT
&& !CRM_Core_Permission
::check('edit event participants')) {
145 // demote to view since user does not have edit event participants rights
146 $this->_permission
= CRM_Core_Permission
::VIEW
;
147 $this->assign('permission', 'view');
152 * 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.
160 // check if we can process credit card registration
161 $this->assign('newCredit', CRM_Core_Config
::isEnabledBackOfficeCreditCardPayments());
163 // Only show credit card registration button if user has CiviContribute permission
164 if (CRM_Core_Permission
::access('CiviContribute')) {
165 $this->assign('accessContribution', TRUE);
168 $this->assign('accessContribution', FALSE);
173 if ($this->_action
& CRM_Core_Action
::VIEW
) {
176 elseif ($this->_action
& (CRM_Core_Action
::UPDATE |
177 CRM_Core_Action
::ADD |
178 CRM_Core_Action
::DELETE
186 return parent
::run();
189 function setContext() {
190 $context = CRM_Utils_Request
::retrieve('context',
191 'String', $this, FALSE, 'search'
193 $compContext = CRM_Utils_Request
::retrieve('compContext',
197 $searchContext = CRM_Utils_Request
::retrieve('searchContext', 'String', $this);
199 $qfKey = CRM_Utils_Request
::retrieve('key', 'String', $this);
202 if (!CRM_Utils_Rule
::qfKey($qfKey)) {
208 $url = CRM_Utils_System
::url('civicrm/event', 'reset=1');
212 $urlParams = 'force=1';
214 $urlParams .= "&qfKey=$qfKey";
216 $this->assign('searchKey', $qfKey);
218 if ($compContext == 'advanced') {
219 $url = CRM_Utils_System
::url('civicrm/contact/search/advanced', $urlParams);
221 else if ($searchContext) {
222 $url = CRM_Utils_System
::url("civicrm/$searchContext/search", $urlParams);
225 $url = CRM_Utils_System
::url('civicrm/event/search', $urlParams);
230 $url = CRM_Utils_System
::url('civicrm/user', 'reset=1');
234 $url = CRM_Utils_System
::url('civicrm/contact/view',
235 "reset=1&force=1&cid={$this->_contactId}&selectedChild=participant"
240 $url = CRM_Utils_System
::url('civicrm/dashboard', 'force=1');
244 $url = CRM_Utils_System
::url('civicrm/contact/view',
245 "reset=1&force=1&cid={$this->_contactId}&selectedChild=activity"
250 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
255 $urlParams = 'force=1';
256 $urlString = 'civicrm/contact/search/custom';
257 if ($this->_action
== CRM_Core_Action
::UPDATE
) {
258 if ($this->_contactId
) {
259 $urlParams .= '&cid=' . $this->_contactId
;
262 $urlParams .= '&context=fulltext&action=view';
263 $urlString = 'civicrm/contact/view/participant';
266 $urlParams .= "$keyName=$qfKey";
268 $this->assign('searchKey', $qfKey);
269 $url = CRM_Utils_System
::url($urlString, $urlParams);
274 if ($this->_contactId
) {
275 $cid = '&cid=' . $this->_contactId
;
277 $url = CRM_Utils_System
::url('civicrm/event/search',
282 $session = CRM_Core_Session
::singleton();
283 $session->pushUserContext($url);
287 * This function is used for the to show the associated
288 * contribution for the participant
293 function associatedContribution() {
294 if (CRM_Core_Permission
::access('CiviContribute')) {
295 $this->assign('accessContribution', TRUE);
296 $controller = new CRM_Core_Controller_Simple(
297 'CRM_Contribute_Form_Search',
302 $controller->setEmbedded(TRUE);
303 $controller->set('force', 1);
304 $controller->set('cid', $this->_contactId
);
305 $controller->set('participantId', $this->_id
);
306 $controller->set('context', 'contribution');
307 $controller->process();
311 $this->assign('accessContribution', FALSE);