3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
35 class CRM_Event_Page_Tab
extends CRM_Core_Page
{
37 public $_permission = NULL;
38 public $_contactId = NULL;
41 * called when action is browse.
43 public function browse() {
44 $controller = new CRM_Core_Controller_Simple(
45 'CRM_Event_Form_Search',
49 $controller->setEmbedded(TRUE);
51 $controller->set('cid', $this->_contactId
);
52 $controller->set('context', 'participant');
53 $controller->process();
56 if ($this->_contactId
) {
57 $displayName = CRM_Contact_BAO_Contact
::displayName($this->_contactId
);
58 $this->assign('displayName', $displayName);
59 $this->ajaxResponse
['tabCount'] = CRM_Contact_BAO_Contact
::getCountComponent('participant', $this->_contactId
);
60 // Refresh other tabs with related data
61 $this->ajaxResponse
['updateTabs'] = array(
62 '#tab_activity' => CRM_Contact_BAO_Contact
::getCountComponent('activity', $this->_contactId
),
64 if (CRM_Core_Permission
::access('CiviContribute')) {
65 $this->ajaxResponse
['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact
::getCountComponent('contribution', $this->_contactId
);
71 * called when action is view.
75 public function view() {
76 // build associated contributions
77 $this->associatedContribution();
79 $controller = new CRM_Core_Controller_Simple(
80 'CRM_Event_Form_ParticipantView',
81 ts('View Participant'),
84 $controller->setEmbedded(TRUE);
85 $controller->set('id', $this->_id
);
86 $controller->set('cid', $this->_contactId
);
88 return $controller->run();
92 * called when action is update or new.
96 public function edit() {
97 // set https for offline cc transaction
98 $mode = CRM_Utils_Request
::retrieve('mode', 'String', $this);
99 if ($mode == 'test' ||
$mode == 'live') {
100 CRM_Utils_System
::redirectToSSL();
103 if ($this->_action
!= CRM_Core_Action
::ADD
) {
104 // get associated contributions only on edit/delete
105 $this->associatedContribution();
108 $controller = new CRM_Core_Controller_Simple(
109 'CRM_Event_Form_Participant',
110 'Create Participation',
114 $controller->setEmbedded(TRUE);
115 $controller->set('id', $this->_id
);
116 $controller->set('cid', $this->_contactId
);
118 return $controller->run();
121 public function preProcess() {
122 $context = CRM_Utils_Request
::retrieve('context', 'String', $this);
123 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'browse');
124 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
126 if ($context == 'standalone') {
127 $this->_action
= CRM_Core_Action
::ADD
;
130 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE);
131 $this->assign('contactId', $this->_contactId
);
133 // check logged in url permission
134 CRM_Contact_Page_View
::checkUserPermission($this);
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 * the main function that is called when the page loads, it decides the which action has to be taken for the page.
151 public function run() {
154 // check if we can process credit card registration
155 $this->assign('newCredit', CRM_Core_Config
::isEnabledBackOfficeCreditCardPayments());
157 // Only show credit card registration button if user has CiviContribute permission
158 if (CRM_Core_Permission
::access('CiviContribute')) {
159 $this->assign('accessContribution', TRUE);
162 $this->assign('accessContribution', FALSE);
167 if ($this->_action
& CRM_Core_Action
::VIEW
) {
170 elseif ($this->_action
& (CRM_Core_Action
::UPDATE |
171 CRM_Core_Action
::ADD |
172 CRM_Core_Action
::DELETE
181 return parent
::run();
184 public function setContext() {
185 $context = CRM_Utils_Request
::retrieve('context',
186 'String', $this, FALSE, 'search'
188 $compContext = CRM_Utils_Request
::retrieve('compContext',
192 $searchContext = CRM_Utils_Request
::retrieve('searchContext', 'String', $this);
194 $qfKey = CRM_Utils_Request
::retrieve('key', 'String', $this);
197 if (!CRM_Utils_Rule
::qfKey($qfKey)) {
203 $url = CRM_Utils_System
::url('civicrm/event', 'reset=1');
207 $urlParams = 'force=1';
209 $urlParams .= "&qfKey=$qfKey";
211 $this->assign('searchKey', $qfKey);
213 if ($compContext == 'advanced') {
214 $url = CRM_Utils_System
::url('civicrm/contact/search/advanced', $urlParams);
216 elseif ($searchContext) {
217 $url = CRM_Utils_System
::url("civicrm/$searchContext/search", $urlParams);
220 $url = CRM_Utils_System
::url('civicrm/event/search', $urlParams);
225 $url = CRM_Utils_System
::url('civicrm/user', 'reset=1');
229 $url = CRM_Utils_System
::url('civicrm/contact/view',
230 "reset=1&force=1&cid={$this->_contactId}&selectedChild=participant"
235 $url = CRM_Utils_System
::url('civicrm/dashboard', 'force=1');
239 $url = CRM_Utils_System
::url('civicrm/contact/view',
240 "reset=1&force=1&cid={$this->_contactId}&selectedChild=activity"
245 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
250 $urlParams = 'force=1';
251 $urlString = 'civicrm/contact/search/custom';
252 if ($this->_action
== CRM_Core_Action
::UPDATE
) {
253 if ($this->_contactId
) {
254 $urlParams .= '&cid=' . $this->_contactId
;
257 $urlParams .= '&context=fulltext&action=view';
258 $urlString = 'civicrm/contact/view/participant';
261 $urlParams .= "$keyName=$qfKey";
263 $this->assign('searchKey', $qfKey);
264 $url = CRM_Utils_System
::url($urlString, $urlParams);
269 if ($this->_contactId
) {
270 $cid = '&cid=' . $this->_contactId
;
272 $url = CRM_Utils_System
::url('civicrm/event/search',
277 $session = CRM_Core_Session
::singleton();
278 $session->pushUserContext($url);
282 * used for the to show the associated
283 * contribution for the participant
285 public function associatedContribution() {
286 if (CRM_Core_Permission
::access('CiviContribute')) {
287 $this->assign('accessContribution', TRUE);
288 $controller = new CRM_Core_Controller_Simple(
289 'CRM_Contribute_Form_Search',
294 $controller->setEmbedded(TRUE);
295 $controller->set('force', 1);
296 $controller->set('cid', $this->_contactId
);
297 $controller->set('participantId', $this->_id
);
298 $controller->set('context', 'contribution');
299 $controller->process();
303 $this->assign('accessContribution', FALSE);