3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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 * called when action is browse
45 public function browse() {
46 $controller = new CRM_Core_Controller_Simple(
47 'CRM_Event_Form_Search',
51 $controller->setEmbedded(TRUE);
53 $controller->set('cid', $this->_contactId
);
54 $controller->set('context', 'participant');
55 $controller->process();
58 if ($this->_contactId
) {
59 $displayName = CRM_Contact_BAO_Contact
::displayName($this->_contactId
);
60 $this->assign('displayName', $displayName);
61 $this->ajaxResponse
['tabCount'] = CRM_Contact_BAO_Contact
::getCountComponent('participant', $this->_contactId
);
62 // Refresh other tabs with related data
63 $this->ajaxResponse
['updateTabs'] = array(
64 '#tab_activity' => CRM_Contact_BAO_Contact
::getCountComponent('activity', $this->_contactId
),
66 if (CRM_Core_Permission
::access('CiviContribute')) {
67 $this->ajaxResponse
['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact
::getCountComponent('contribution', $this->_contactId
);
73 * called when action is view
77 public function 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 * called when action is update or new
98 public function edit() {
99 // set https for offline cc transaction
100 $mode = CRM_Utils_Request
::retrieve('mode', 'String', $this);
101 if ($mode == 'test' ||
$mode == 'live') {
102 CRM_Utils_System
::redirectToSSL();
105 if ($this->_action
!= CRM_Core_Action
::ADD
) {
106 // get associated contributions only on edit/delete
107 $this->associatedContribution();
110 $controller = new CRM_Core_Controller_Simple(
111 'CRM_Event_Form_Participant',
112 'Create Participation',
116 $controller->setEmbedded(TRUE);
117 $controller->set('id', $this->_id
);
118 $controller->set('cid', $this->_contactId
);
120 return $controller->run();
123 public function preProcess() {
124 $context = CRM_Utils_Request
::retrieve('context', 'String', $this);
125 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'browse');
126 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
128 if ($context == 'standalone') {
129 $this->_action
= CRM_Core_Action
::ADD
;
132 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE);
133 $this->assign('contactId', $this->_contactId
);
135 // check logged in url permission
136 CRM_Contact_Page_View
::checkUserPermission($this);
139 $this->assign('action', $this->_action
);
141 if ($this->_permission
== CRM_Core_Permission
::EDIT
&& !CRM_Core_Permission
::check('edit event participants')) {
142 // demote to view since user does not have edit event participants rights
143 $this->_permission
= CRM_Core_Permission
::VIEW
;
144 $this->assign('permission', 'view');
149 * the main function that is called when the page loads, it decides the which action has to be taken for the page.
153 public function run() {
156 // check if we can process credit card registration
157 $this->assign('newCredit', CRM_Core_Config
::isEnabledBackOfficeCreditCardPayments());
159 // Only show credit card registration button if user has CiviContribute permission
160 if (CRM_Core_Permission
::access('CiviContribute')) {
161 $this->assign('accessContribution', TRUE);
164 $this->assign('accessContribution', FALSE);
169 if ($this->_action
& CRM_Core_Action
::VIEW
) {
172 elseif ($this->_action
& (CRM_Core_Action
::UPDATE |
173 CRM_Core_Action
::ADD |
174 CRM_Core_Action
::DELETE
183 return parent
::run();
186 public function setContext() {
187 $context = CRM_Utils_Request
::retrieve('context',
188 'String', $this, FALSE, 'search'
190 $compContext = CRM_Utils_Request
::retrieve('compContext',
194 $searchContext = CRM_Utils_Request
::retrieve('searchContext', 'String', $this);
196 $qfKey = CRM_Utils_Request
::retrieve('key', 'String', $this);
199 if (!CRM_Utils_Rule
::qfKey($qfKey)) {
205 $url = CRM_Utils_System
::url('civicrm/event', 'reset=1');
209 $urlParams = 'force=1';
211 $urlParams .= "&qfKey=$qfKey";
213 $this->assign('searchKey', $qfKey);
215 if ($compContext == 'advanced') {
216 $url = CRM_Utils_System
::url('civicrm/contact/search/advanced', $urlParams);
218 elseif ($searchContext) {
219 $url = CRM_Utils_System
::url("civicrm/$searchContext/search", $urlParams);
222 $url = CRM_Utils_System
::url('civicrm/event/search', $urlParams);
227 $url = CRM_Utils_System
::url('civicrm/user', 'reset=1');
231 $url = CRM_Utils_System
::url('civicrm/contact/view',
232 "reset=1&force=1&cid={$this->_contactId}&selectedChild=participant"
237 $url = CRM_Utils_System
::url('civicrm/dashboard', 'force=1');
241 $url = CRM_Utils_System
::url('civicrm/contact/view',
242 "reset=1&force=1&cid={$this->_contactId}&selectedChild=activity"
247 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
252 $urlParams = 'force=1';
253 $urlString = 'civicrm/contact/search/custom';
254 if ($this->_action
== CRM_Core_Action
::UPDATE
) {
255 if ($this->_contactId
) {
256 $urlParams .= '&cid=' . $this->_contactId
;
259 $urlParams .= '&context=fulltext&action=view';
260 $urlString = 'civicrm/contact/view/participant';
263 $urlParams .= "$keyName=$qfKey";
265 $this->assign('searchKey', $qfKey);
266 $url = CRM_Utils_System
::url($urlString, $urlParams);
271 if ($this->_contactId
) {
272 $cid = '&cid=' . $this->_contactId
;
274 $url = CRM_Utils_System
::url('civicrm/event/search',
279 $session = CRM_Core_Session
::singleton();
280 $session->pushUserContext($url);
284 * used for the to show the associated
285 * contribution for the participant
289 public function associatedContribution() {
290 if (CRM_Core_Permission
::access('CiviContribute')) {
291 $this->assign('accessContribution', TRUE);
292 $controller = new CRM_Core_Controller_Simple(
293 'CRM_Contribute_Form_Search',
298 $controller->setEmbedded(TRUE);
299 $controller->set('force', 1);
300 $controller->set('cid', $this->_contactId
);
301 $controller->set('participantId', $this->_id
);
302 $controller->set('context', 'contribution');
303 $controller->process();
307 $this->assign('accessContribution', FALSE);