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