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_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);
66 * This function is called when action is view
72 // build associated contributions
73 $this->associatedContribution();
75 $controller = new CRM_Core_Controller_Simple(
76 'CRM_Event_Form_ParticipantView',
77 ts('View Participant'),
80 $controller->setEmbedded(TRUE);
81 $controller->set('id', $this->_id
);
82 $controller->set('cid', $this->_contactId
);
84 return $controller->run();
88 * This function is called when action is update or new
94 // set https for offline cc transaction
95 $mode = CRM_Utils_Request
::retrieve('mode', 'String', $this);
96 if ($mode == 'test' ||
$mode == 'live') {
97 CRM_Utils_System
::redirectToSSL();
100 if ($this->_action
!= CRM_Core_Action
::ADD
) {
101 // get associated contributions only on edit/delete
102 $this->associatedContribution();
105 $controller = new CRM_Core_Controller_Simple(
106 'CRM_Event_Form_Participant',
107 'Create Participation',
111 $controller->setEmbedded(TRUE);
112 $controller->set('id', $this->_id
);
113 $controller->set('cid', $this->_contactId
);
115 return $controller->run();
118 function preProcess() {
119 $context = CRM_Utils_Request
::retrieve('context', 'String', $this);
120 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'browse');
121 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
123 if ($context == 'standalone') {
124 $this->_action
= CRM_Core_Action
::ADD
;
127 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE);
128 $this->assign('contactId', $this->_contactId
);
130 // check logged in url permission
131 CRM_Contact_Page_View
::checkUserPermission($this);
134 CRM_Contact_Page_View
::setTitle($this->_contactId
);
137 $this->assign('action', $this->_action
);
139 if ($this->_permission
== CRM_Core_Permission
::EDIT
&& !CRM_Core_Permission
::check('edit event participants')) {
140 // demote to view since user does not have edit event participants rights
141 $this->_permission
= CRM_Core_Permission
::VIEW
;
142 $this->assign('permission', 'view');
147 * 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.
155 // check if we can process credit card registration
156 CRM_Core_Payment
::allowBackofficeCreditCard($this);
158 // Only show credit card registration button if user has CiviContribute permission
159 if (CRM_Core_Permission
::access('CiviContribute')) {
160 $this->assign('accessContribution', TRUE);
163 $this->assign('accessContribution', FALSE);
168 if ($this->_action
& CRM_Core_Action
::VIEW
) {
171 elseif ($this->_action
& (CRM_Core_Action
::UPDATE |
172 CRM_Core_Action
::ADD |
173 CRM_Core_Action
::DELETE
181 return parent
::run();
184 function setContext() {
185 $context = CRM_Utils_Request
::retrieve('context',
186 'String', $this, FALSE, 'search'
188 $compContext = CRM_Utils_Request
::retrieve('compContext',
192 $qfKey = CRM_Utils_Request
::retrieve('key', 'String', $this);
195 if (!CRM_Utils_Rule
::qfKey($qfKey)) {
201 $url = CRM_Utils_System
::url('civicrm/event', 'reset=1');
205 $urlParams = 'force=1';
207 $urlParams .= "&qfKey=$qfKey";
209 $this->assign('searchKey', $qfKey);
211 if ($compContext == 'advanced') {
212 $url = CRM_Utils_System
::url('civicrm/contact/search/advanced', $urlParams);
215 $url = CRM_Utils_System
::url('civicrm/event/search', $urlParams);
220 $url = CRM_Utils_System
::url('civicrm/user', 'reset=1');
224 $url = CRM_Utils_System
::url('civicrm/contact/view',
225 "reset=1&force=1&cid={$this->_contactId}&selectedChild=participant"
230 $url = CRM_Utils_System
::url('civicrm/dashboard', 'force=1');
234 $url = CRM_Utils_System
::url('civicrm/contact/view',
235 "reset=1&force=1&cid={$this->_contactId}&selectedChild=activity"
240 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
245 $urlParams = 'force=1';
246 $urlString = 'civicrm/contact/search/custom';
247 if ($this->_action
== CRM_Core_Action
::UPDATE
) {
248 if ($this->_contactId
) {
249 $urlParams .= '&cid=' . $this->_contactId
;
252 $urlParams .= '&context=fulltext&action=view';
253 $urlString = 'civicrm/contact/view/participant';
256 $urlParams .= "$keyName=$qfKey";
258 $this->assign('searchKey', $qfKey);
259 $url = CRM_Utils_System
::url($urlString, $urlParams);
264 if ($this->_contactId
) {
265 $cid = '&cid=' . $this->_contactId
;
267 $url = CRM_Utils_System
::url('civicrm/event/search',
272 $session = CRM_Core_Session
::singleton();
273 $session->pushUserContext($url);
277 * This function is used for the to show the associated
278 * contribution for the participant
283 function associatedContribution() {
284 if (CRM_Core_Permission
::access('CiviContribute')) {
285 $this->assign('accessContribution', TRUE);
286 $controller = new CRM_Core_Controller_Simple(
287 'CRM_Contribute_Form_Search',
292 $controller->setEmbedded(TRUE);
293 $controller->set('force', 1);
294 $controller->set('cid', $this->_contactId
);
295 $controller->set('participantId', $this->_id
);
296 $controller->set('context', 'contribution');
297 $controller->process();
301 $this->assign('accessContribution', FALSE);