Merge pull request #17458 from eileenmcnaughton/export
[civicrm-core.git] / CRM / Event / Page / ParticipantListing.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 * $Id$
17 *
18 */
19 class CRM_Event_Page_ParticipantListing extends CRM_Core_Page {
20
21 protected $_id;
22
23 protected $_participantListingID;
24
25 protected $_eventTitle;
26
27 protected $_pager;
28
29 public function preProcess() {
30 $this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this, TRUE);
31
32 // ensure that there is a particpant type for this
33 $this->_participantListingID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
34 $this->_id,
35 'participant_listing_id'
36 );
37 if (!$this->_participantListingID) {
38 CRM_Core_Error::statusBounce(ts('The Participant Listing feature is not currently enabled for this event.'));
39 }
40
41 // retrieve Event Title and include it in page title
42 $this->_eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
43 $this->_id,
44 'title'
45 );
46 CRM_Utils_System::setTitle(ts('%1 - Participants', array(1 => $this->_eventTitle)));
47
48 // we do not want to display recently viewed contacts since this is potentially a public page
49 $this->assign('displayRecent', FALSE);
50 }
51
52 /**
53 * Run listing page.
54 *
55 * @throws \Exception
56 */
57 public function run() {
58 $this->preProcess();
59
60 // get the class name from the participantListingID
61 $className = CRM_Utils_Array::value($this->_participantListingID,
62 CRM_Core_PseudoConstant::get(
63 'CRM_Event_BAO_Event',
64 'participant_listing_id',
65 ['keyColumn' => 'value', 'labelColumn' => 'description']
66 )
67 );
68 if ($className == 'CRM_Event_Page_ParticipantListing') {
69 CRM_Core_Error::statusBounce(ts("Participant listing code file cannot be '%1'",
70 array(1 => $className)
71 ));
72 }
73
74 $classFile = str_replace('_',
75 DIRECTORY_SEPARATOR,
76 $className
77 ) . '.php';
78 $error = include_once $classFile;
79 if ($error == FALSE) {
80 CRM_Core_Error::statusBounce('Participant listing code file: ' . $classFile . ' does not exist. Please verify your custom particpant listing settings in CiviCRM administrative panel.');
81 }
82
83 $participantListingClass = new $className();
84
85 $participantListingClass->preProcess();
86 $participantListingClass->run();
87 }
88
89 }