3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
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', 'Alphanumeric', $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 delete() {
122 $controller = new CRM_Core_Controller_Simple(
123 'CRM_Event_Form_Participant',
124 ts('Delete Participant'),
128 $controller->setEmbedded(TRUE);
129 $controller->set('id', $this->_id
);
130 $controller->set('cid', $this->_contactId
);
134 public function preProcess() {
135 $context = CRM_Utils_Request
::retrieve('context', 'Alphanumeric', $this);
136 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'browse');
137 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
139 if ($context == 'standalone') {
140 $this->_action
= CRM_Core_Action
::ADD
;
143 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE);
144 $this->assign('contactId', $this->_contactId
);
146 // check logged in url permission
147 CRM_Contact_Page_View
::checkUserPermission($this);
150 $this->assign('action', $this->_action
);
152 if ($this->_permission
== CRM_Core_Permission
::EDIT
&& !CRM_Core_Permission
::check('edit event participants')) {
153 // demote to view since user does not have edit event participants rights
154 $this->_permission
= CRM_Core_Permission
::VIEW
;
155 $this->assign('permission', 'view');
160 * the main function that is called when the page loads, it decides the which action has to be taken for the page.
164 public function run() {
167 // check if we can process credit card registration
168 $this->assign('newCredit', CRM_Core_Config
::isEnabledBackOfficeCreditCardPayments());
170 // Only show credit card registration button if user has CiviContribute permission
171 if (CRM_Core_Permission
::access('CiviContribute')) {
172 $this->assign('accessContribution', TRUE);
175 $this->assign('accessContribution', FALSE);
180 if ($this->_action
& CRM_Core_Action
::VIEW
) {
183 elseif ($this->_action
& (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD
)) {
186 elseif ($this->_action
& (CRM_Core_Action
::DELETE | CRM_Core_Action
::DETACH
)) {
193 return parent
::run();
196 public function setContext() {
197 $context = CRM_Utils_Request
::retrieve('context',
198 'String', $this, FALSE, 'search'
200 $compContext = CRM_Utils_Request
::retrieve('compContext',
204 $searchContext = CRM_Utils_Request
::retrieve('searchContext', 'String', $this);
206 $qfKey = CRM_Utils_Request
::retrieve('key', 'String', $this);
209 if (!CRM_Utils_Rule
::qfKey($qfKey)) {
215 $url = CRM_Utils_System
::url('civicrm/event', 'reset=1');
219 $urlParams = 'force=1';
221 $urlParams .= "&qfKey=$qfKey";
223 $this->assign('searchKey', $qfKey);
225 if ($compContext == 'advanced') {
226 $url = CRM_Utils_System
::url('civicrm/contact/search/advanced', $urlParams);
228 elseif ($searchContext) {
229 $url = CRM_Utils_System
::url("civicrm/$searchContext/search", $urlParams);
232 $url = CRM_Utils_System
::url('civicrm/event/search', $urlParams);
237 $url = CRM_Utils_System
::url('civicrm/user', 'reset=1');
241 $url = CRM_Utils_System
::url('civicrm/contact/view',
242 "reset=1&force=1&cid={$this->_contactId}&selectedChild=participant"
247 $url = CRM_Utils_System
::url('civicrm/dashboard', 'force=1');
251 $url = CRM_Utils_System
::url('civicrm/contact/view',
252 "reset=1&force=1&cid={$this->_contactId}&selectedChild=activity"
257 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
262 $urlParams = 'force=1';
263 $urlString = 'civicrm/contact/search/custom';
264 if ($this->_action
== CRM_Core_Action
::UPDATE
) {
265 if ($this->_contactId
) {
266 $urlParams .= '&cid=' . $this->_contactId
;
269 $urlParams .= '&context=fulltext&action=view';
270 $urlString = 'civicrm/contact/view/participant';
273 $urlParams .= "$keyName=$qfKey";
275 $this->assign('searchKey', $qfKey);
276 $url = CRM_Utils_System
::url($urlString, $urlParams);
281 if ($this->_contactId
) {
282 $cid = '&cid=' . $this->_contactId
;
284 $url = CRM_Utils_System
::url('civicrm/event/search',
289 $session = CRM_Core_Session
::singleton();
290 $session->pushUserContext($url);
294 * used for the to show the associated
295 * contribution for the participant
297 public function associatedContribution() {
298 if (CRM_Core_Permission
::access('CiviContribute')) {
299 $this->assign('accessContribution', TRUE);
300 $controller = new CRM_Core_Controller_Simple(
301 'CRM_Contribute_Form_Search',
306 $controller->setEmbedded(TRUE);
307 $controller->set('force', 1);
308 $controller->set('cid', $this->_contactId
);
309 $controller->set('participantId', $this->_id
);
310 $controller->set('context', 'contribution');
311 $controller->process();
315 $this->assign('accessContribution', FALSE);