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 $this->assign('action', $this->_action
);
142 if ($this->_permission
== CRM_Core_Permission
::EDIT
&& !CRM_Core_Permission
::check('edit event participants')) {
143 // demote to view since user does not have edit event participants rights
144 $this->_permission
= CRM_Core_Permission
::VIEW
;
145 $this->assign('permission', 'view');
150 * 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.
158 // check if we can process credit card registration
159 $this->assign('newCredit', CRM_Core_Config
::isEnabledBackOfficeCreditCardPayments());
161 // Only show credit card registration button if user has CiviContribute permission
162 if (CRM_Core_Permission
::access('CiviContribute')) {
163 $this->assign('accessContribution', TRUE);
166 $this->assign('accessContribution', FALSE);
171 if ($this->_action
& CRM_Core_Action
::VIEW
) {
174 elseif ($this->_action
& (CRM_Core_Action
::UPDATE |
175 CRM_Core_Action
::ADD |
176 CRM_Core_Action
::DELETE
184 return parent
::run();
187 function setContext() {
188 $context = CRM_Utils_Request
::retrieve('context',
189 'String', $this, FALSE, 'search'
191 $compContext = CRM_Utils_Request
::retrieve('compContext',
195 $searchContext = CRM_Utils_Request
::retrieve('searchContext', 'String', $this);
197 $qfKey = CRM_Utils_Request
::retrieve('key', 'String', $this);
200 if (!CRM_Utils_Rule
::qfKey($qfKey)) {
206 $url = CRM_Utils_System
::url('civicrm/event', 'reset=1');
210 $urlParams = 'force=1';
212 $urlParams .= "&qfKey=$qfKey";
214 $this->assign('searchKey', $qfKey);
216 if ($compContext == 'advanced') {
217 $url = CRM_Utils_System
::url('civicrm/contact/search/advanced', $urlParams);
219 else if ($searchContext) {
220 $url = CRM_Utils_System
::url("civicrm/$searchContext/search", $urlParams);
223 $url = CRM_Utils_System
::url('civicrm/event/search', $urlParams);
228 $url = CRM_Utils_System
::url('civicrm/user', 'reset=1');
232 $url = CRM_Utils_System
::url('civicrm/contact/view',
233 "reset=1&force=1&cid={$this->_contactId}&selectedChild=participant"
238 $url = CRM_Utils_System
::url('civicrm/dashboard', 'force=1');
242 $url = CRM_Utils_System
::url('civicrm/contact/view',
243 "reset=1&force=1&cid={$this->_contactId}&selectedChild=activity"
248 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
253 $urlParams = 'force=1';
254 $urlString = 'civicrm/contact/search/custom';
255 if ($this->_action
== CRM_Core_Action
::UPDATE
) {
256 if ($this->_contactId
) {
257 $urlParams .= '&cid=' . $this->_contactId
;
260 $urlParams .= '&context=fulltext&action=view';
261 $urlString = 'civicrm/contact/view/participant';
264 $urlParams .= "$keyName=$qfKey";
266 $this->assign('searchKey', $qfKey);
267 $url = CRM_Utils_System
::url($urlString, $urlParams);
272 if ($this->_contactId
) {
273 $cid = '&cid=' . $this->_contactId
;
275 $url = CRM_Utils_System
::url('civicrm/event/search',
280 $session = CRM_Core_Session
::singleton();
281 $session->pushUserContext($url);
285 * This function is used for the to show the associated
286 * contribution for the participant
291 function associatedContribution() {
292 if (CRM_Core_Permission
::access('CiviContribute')) {
293 $this->assign('accessContribution', TRUE);
294 $controller = new CRM_Core_Controller_Simple(
295 'CRM_Contribute_Form_Search',
300 $controller->setEmbedded(TRUE);
301 $controller->set('force', 1);
302 $controller->set('cid', $this->_contactId
);
303 $controller->set('participantId', $this->_id
);
304 $controller->set('context', 'contribution');
305 $controller->process();
309 $this->assign('accessContribution', FALSE);