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_contribute' => CRM_Contact_BAO_Contact
::getCountComponent('contribution', $this->_contactId
),
66 '#tab_activity' => CRM_Contact_BAO_Contact
::getCountComponent('activity', $this->_contactId
),
72 * This function is called when action is view
78 // build associated contributions
79 $this->associatedContribution();
81 $controller = new CRM_Core_Controller_Simple(
82 'CRM_Event_Form_ParticipantView',
83 ts('View Participant'),
86 $controller->setEmbedded(TRUE);
87 $controller->set('id', $this->_id
);
88 $controller->set('cid', $this->_contactId
);
90 return $controller->run();
94 * This function is called when action is update or new
100 // set https for offline cc transaction
101 $mode = CRM_Utils_Request
::retrieve('mode', 'String', $this);
102 if ($mode == 'test' ||
$mode == 'live') {
103 CRM_Utils_System
::redirectToSSL();
106 if ($this->_action
!= CRM_Core_Action
::ADD
) {
107 // get associated contributions only on edit/delete
108 $this->associatedContribution();
111 $controller = new CRM_Core_Controller_Simple(
112 'CRM_Event_Form_Participant',
113 'Create Participation',
117 $controller->setEmbedded(TRUE);
118 $controller->set('id', $this->_id
);
119 $controller->set('cid', $this->_contactId
);
121 return $controller->run();
124 function preProcess() {
125 $context = CRM_Utils_Request
::retrieve('context', 'String', $this);
126 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'browse');
127 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
129 if ($context == 'standalone') {
130 $this->_action
= CRM_Core_Action
::ADD
;
133 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE);
134 $this->assign('contactId', $this->_contactId
);
136 // check logged in url permission
137 CRM_Contact_Page_View
::checkUserPermission($this);
140 CRM_Contact_Page_View
::setTitle($this->_contactId
);
143 $this->assign('action', $this->_action
);
145 if ($this->_permission
== CRM_Core_Permission
::EDIT
&& !CRM_Core_Permission
::check('edit event participants')) {
146 // demote to view since user does not have edit event participants rights
147 $this->_permission
= CRM_Core_Permission
::VIEW
;
148 $this->assign('permission', 'view');
153 * 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.
161 // check if we can process credit card registration
162 $this->assign('newCredit', CRM_Core_Config
::isEnabledBackOfficeCreditCardPayments());
164 // Only show credit card registration button if user has CiviContribute permission
165 if (CRM_Core_Permission
::access('CiviContribute')) {
166 $this->assign('accessContribution', TRUE);
169 $this->assign('accessContribution', FALSE);
174 if ($this->_action
& CRM_Core_Action
::VIEW
) {
177 elseif ($this->_action
& (CRM_Core_Action
::UPDATE |
178 CRM_Core_Action
::ADD |
179 CRM_Core_Action
::DELETE
187 return parent
::run();
190 function setContext() {
191 $context = CRM_Utils_Request
::retrieve('context',
192 'String', $this, FALSE, 'search'
194 $compContext = CRM_Utils_Request
::retrieve('compContext',
198 $searchContext = CRM_Utils_Request
::retrieve('searchContext', 'String', $this);
200 $qfKey = CRM_Utils_Request
::retrieve('key', 'String', $this);
203 if (!CRM_Utils_Rule
::qfKey($qfKey)) {
209 $url = CRM_Utils_System
::url('civicrm/event', 'reset=1');
213 $urlParams = 'force=1';
215 $urlParams .= "&qfKey=$qfKey";
217 $this->assign('searchKey', $qfKey);
219 if ($compContext == 'advanced') {
220 $url = CRM_Utils_System
::url('civicrm/contact/search/advanced', $urlParams);
222 else if ($searchContext) {
223 $url = CRM_Utils_System
::url("civicrm/$searchContext/search", $urlParams);
226 $url = CRM_Utils_System
::url('civicrm/event/search', $urlParams);
231 $url = CRM_Utils_System
::url('civicrm/user', 'reset=1');
235 $url = CRM_Utils_System
::url('civicrm/contact/view',
236 "reset=1&force=1&cid={$this->_contactId}&selectedChild=participant"
241 $url = CRM_Utils_System
::url('civicrm/dashboard', 'force=1');
245 $url = CRM_Utils_System
::url('civicrm/contact/view',
246 "reset=1&force=1&cid={$this->_contactId}&selectedChild=activity"
251 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
256 $urlParams = 'force=1';
257 $urlString = 'civicrm/contact/search/custom';
258 if ($this->_action
== CRM_Core_Action
::UPDATE
) {
259 if ($this->_contactId
) {
260 $urlParams .= '&cid=' . $this->_contactId
;
263 $urlParams .= '&context=fulltext&action=view';
264 $urlString = 'civicrm/contact/view/participant';
267 $urlParams .= "$keyName=$qfKey";
269 $this->assign('searchKey', $qfKey);
270 $url = CRM_Utils_System
::url($urlString, $urlParams);
275 if ($this->_contactId
) {
276 $cid = '&cid=' . $this->_contactId
;
278 $url = CRM_Utils_System
::url('civicrm/event/search',
283 $session = CRM_Core_Session
::singleton();
284 $session->pushUserContext($url);
288 * This function is used for the to show the associated
289 * contribution for the participant
294 function associatedContribution() {
295 if (CRM_Core_Permission
::access('CiviContribute')) {
296 $this->assign('accessContribution', TRUE);
297 $controller = new CRM_Core_Controller_Simple(
298 'CRM_Contribute_Form_Search',
303 $controller->setEmbedded(TRUE);
304 $controller->set('force', 1);
305 $controller->set('cid', $this->_contactId
);
306 $controller->set('participantId', $this->_id
);
307 $controller->set('context', 'contribution');
308 $controller->process();
312 $this->assign('accessContribution', FALSE);