Merge pull request #24153 from agileware/CIVICRM-2025
[civicrm-core.git] / CRM / Event / Page / ParticipantListing.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17class CRM_Event_Page_ParticipantListing extends CRM_Core_Page {
18
19 protected $_id;
20
21 protected $_participantListingID;
22
23 protected $_eventTitle;
24
25 protected $_pager;
353ffa53 26
00be9182 27 public function preProcess() {
6a488035
TO
28 $this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this, TRUE);
29
61e912da 30 // ensure that there is a participant type for this
6a488035
TO
31 $this->_participantListingID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
32 $this->_id,
33 'participant_listing_id'
34 );
35 if (!$this->_participantListingID) {
beb414cc 36 CRM_Core_Error::statusBounce(ts('The Participant Listing feature is not currently enabled for this event.'));
6a488035
TO
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
f2ac86d1 50 /**
51 * Run listing page.
52 *
53 * @throws \Exception
54 */
00be9182 55 public function run() {
6a488035
TO
56 $this->preProcess();
57
58 // get the class name from the participantListingID
676159c9 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 )
6a488035 65 );
6a488035 66 if ($className == 'CRM_Event_Page_ParticipantListing') {
79e11805 67 CRM_Core_Error::statusBounce(ts("Participant listing code file cannot be '%1'",
353ffa53
TO
68 array(1 => $className)
69 ));
6a488035
TO
70 }
71
72 $classFile = str_replace('_',
353ffa53
TO
73 DIRECTORY_SEPARATOR,
74 $className
75 ) . '.php';
0479b4c8 76 $error = include_once $classFile;
6a488035 77 if ($error == FALSE) {
61e912da 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]));
6a488035
TO
79 }
80
4d5c2eb5 81 $participantListingClass = new $className();
6a488035
TO
82
83 $participantListingClass->preProcess();
84 $participantListingClass->run();
85 }
96025800 86
6a488035 87}