3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 class CRM_Event_Page_Tab
extends CRM_Core_Page
{
21 public $_permission = NULL;
22 public $_contactId = NULL;
25 * called when action is browse.
27 public function browse() {
28 $controller = new CRM_Core_Controller_Simple(
29 'CRM_Event_Form_Search',
33 $controller->setEmbedded(TRUE);
35 $controller->set('cid', $this->_contactId
);
36 $controller->set('context', 'participant');
37 $controller->process();
40 if ($this->_contactId
) {
41 $displayName = CRM_Contact_BAO_Contact
::displayName($this->_contactId
);
42 $this->assign('displayName', $displayName);
43 $this->ajaxResponse
['tabCount'] = CRM_Contact_BAO_Contact
::getCountComponent('participant', $this->_contactId
);
44 // Refresh other tabs with related data
45 $this->ajaxResponse
['updateTabs'] = [
46 '#tab_activity' => CRM_Contact_BAO_Contact
::getCountComponent('activity', $this->_contactId
),
48 if (CRM_Core_Permission
::access('CiviContribute')) {
49 $this->ajaxResponse
['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact
::getCountComponent('contribution', $this->_contactId
);
55 * called when action is view.
59 public function view() {
60 // build associated contributions
61 $this->associatedContribution();
63 $controller = new CRM_Core_Controller_Simple(
64 'CRM_Event_Form_ParticipantView',
65 ts('View Participant'),
68 $controller->setEmbedded(TRUE);
69 $controller->set('id', $this->_id
);
70 $controller->set('cid', $this->_contactId
);
72 return $controller->run();
76 * called when action is update or new.
80 public function edit() {
81 // set https for offline cc transaction
82 $mode = CRM_Utils_Request
::retrieve('mode', 'Alphanumeric', $this);
83 if ($mode == 'test' ||
$mode == 'live') {
84 CRM_Utils_System
::redirectToSSL();
87 if ($this->_action
!= CRM_Core_Action
::ADD
) {
88 // get associated contributions only on edit/delete
89 $this->associatedContribution();
92 $controller = new CRM_Core_Controller_Simple(
93 'CRM_Event_Form_Participant',
94 'Create Participation',
98 $controller->setEmbedded(TRUE);
99 $controller->set('id', $this->_id
);
100 $controller->set('cid', $this->_contactId
);
102 return $controller->run();
105 public function delete() {
106 $controller = new CRM_Core_Controller_Simple(
107 'CRM_Event_Form_Participant',
108 ts('Delete Participant'),
112 $controller->setEmbedded(TRUE);
113 $controller->set('id', $this->_id
);
114 $controller->set('cid', $this->_contactId
);
118 public function preProcess() {
119 $context = CRM_Utils_Request
::retrieve('context', 'Alphanumeric', $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 $this->assign('action', $this->_action
);
136 if ($this->_permission
== CRM_Core_Permission
::EDIT
&& !CRM_Core_Permission
::check('edit event participants')) {
137 // demote to view since user does not have edit event participants rights
138 $this->_permission
= CRM_Core_Permission
::VIEW
;
139 $this->assign('permission', 'view');
144 * the main function that is called when the page loads, it decides the which action has to be taken for the page.
148 public function run() {
151 // check if we can process credit card registration
152 $this->assign('newCredit', CRM_Core_Config
::isEnabledBackOfficeCreditCardPayments());
154 // Only show credit card registration button if user has CiviContribute permission
155 if (CRM_Core_Permission
::access('CiviContribute')) {
156 $this->assign('accessContribution', TRUE);
159 $this->assign('accessContribution', FALSE);
164 if ($this->_action
& CRM_Core_Action
::VIEW
) {
167 elseif ($this->_action
& (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD
)) {
170 elseif ($this->_action
& (CRM_Core_Action
::DELETE | CRM_Core_Action
::DETACH
)) {
177 return parent
::run();
180 public function setContext() {
181 $context = CRM_Utils_Request
::retrieve('context',
182 'String', $this, FALSE, 'search'
184 $compContext = CRM_Utils_Request
::retrieve('compContext',
188 $searchContext = CRM_Utils_Request
::retrieve('searchContext', 'String', $this);
190 $qfKey = CRM_Utils_Request
::retrieve('key', 'String', $this);
193 if (!CRM_Utils_Rule
::qfKey($qfKey)) {
199 $url = CRM_Utils_System
::url('civicrm/event', 'reset=1');
203 $urlParams = 'force=1';
205 $urlParams .= "&qfKey=$qfKey";
207 $this->assign('searchKey', $qfKey);
209 if ($compContext == 'advanced') {
210 $url = CRM_Utils_System
::url('civicrm/contact/search/advanced', $urlParams);
212 elseif ($searchContext) {
213 $url = CRM_Utils_System
::url("civicrm/$searchContext/search", $urlParams);
216 $url = CRM_Utils_System
::url('civicrm/event/search', $urlParams);
221 $url = CRM_Utils_System
::url('civicrm/user', 'reset=1');
225 $url = CRM_Utils_System
::url('civicrm/contact/view',
226 "reset=1&force=1&cid={$this->_contactId}&selectedChild=participant"
231 $url = CRM_Utils_System
::url('civicrm/dashboard', 'force=1');
235 $url = CRM_Utils_System
::url('civicrm/contact/view',
236 "reset=1&force=1&cid={$this->_contactId}&selectedChild=activity"
241 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
246 $urlParams = 'force=1';
247 $urlString = 'civicrm/contact/search/custom';
248 if ($this->_action
== CRM_Core_Action
::UPDATE
) {
249 if ($this->_contactId
) {
250 $urlParams .= '&cid=' . $this->_contactId
;
253 $urlParams .= '&context=fulltext&action=view';
254 $urlString = 'civicrm/contact/view/participant';
257 $urlParams .= "$keyName=$qfKey";
259 $this->assign('searchKey', $qfKey);
260 $url = CRM_Utils_System
::url($urlString, $urlParams);
265 if ($this->_contactId
) {
266 $cid = '&cid=' . $this->_contactId
;
268 $url = CRM_Utils_System
::url('civicrm/event/search',
273 $session = CRM_Core_Session
::singleton();
274 $session->pushUserContext($url);
278 * used for the to show the associated
279 * contribution for the participant
281 public function associatedContribution() {
282 if (CRM_Core_Permission
::access('CiviContribute')) {
283 $this->assign('accessContribution', TRUE);
284 $controller = new CRM_Core_Controller_Simple(
285 'CRM_Contribute_Form_Search',
290 $controller->setEmbedded(TRUE);
291 $controller->set('force', 1);
292 $controller->set('cid', $this->_contactId
);
293 $controller->set('participantId', $this->_id
);
294 $controller->set('context', 'contribution');
295 $controller->process();
299 $this->assign('accessContribution', FALSE);