3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Event_Page_ParticipantListing_Simple
extends CRM_Core_Page
{
21 protected $_participantListingType;
23 protected $_eventTitle;
27 public function preProcess() {
28 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Integer', $this, TRUE);
30 // retrieve Event Title and include it in page title
31 $this->_eventTitle
= CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event',
35 CRM_Utils_System
::setTitle(ts('%1 - Participants', [1 => $this->_eventTitle
]));
37 // we do not want to display recently viewed contacts since this is potentially a public page
38 $this->assign('displayRecent', FALSE);
44 public function run() {
49 INNER JOIN civicrm_participant ON ( civicrm_contact.id = civicrm_participant.contact_id
50 AND civicrm_contact.is_deleted = 0 )
51 INNER JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id
52 LEFT JOIN civicrm_email ON ( civicrm_contact.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1 )
56 WHERE civicrm_event.id = %1
57 AND civicrm_participant.is_test = 0
58 AND civicrm_participant.status_id IN ( 1, 2 )";
59 $params = [1 => [$this->_id
, 'Integer']];
60 $this->pager($fromClause, $whereClause, $params);
61 $orderBy = $this->orderBy();
63 list($offset, $rowCount) = $this->_pager
->getOffsetAndRowCount();
66 SELECT civicrm_contact.id as contact_id ,
67 civicrm_contact.display_name as name ,
68 civicrm_contact.sort_name as sort_name ,
69 civicrm_participant.id as participant_id,
70 civicrm_email.email as email
74 LIMIT $offset, $rowCount";
77 $object = CRM_Core_DAO
::executeQuery($query, $params);
78 while ($object->fetch()) {
80 'id' => $object->contact_id
,
81 'participantID' => $object->participant_id
,
82 'name' => $object->name
,
83 'email' => $object->email
,
87 $this->assign_by_ref('rows', $rows);
95 * @param array $whereParams
97 public function pager($fromClause, $whereClause, $whereParams) {
101 $params['status'] = ts('Group') . ' %%StatusMessage%%';
102 $params['csvString'] = NULL;
103 $params['buttonTop'] = 'PagerTopButton';
104 $params['buttonBottom'] = 'PagerBottomButton';
105 $params['rowCount'] = $this->get(CRM_Utils_Pager
::PAGE_ROWCOUNT
);
106 if (!$params['rowCount']) {
107 $params['rowCount'] = CRM_Utils_Pager
::ROWCOUNT
;
111 SELECT count( civicrm_contact.id )
116 $params['total'] = CRM_Core_DAO
::singleValueQuery($query, $whereParams);
117 $this->_pager
= new CRM_Utils_Pager($params);
118 $this->assign_by_ref('pager', $this->_pager
);
124 public function orderBy() {
125 static $headers = NULL;
129 'name' => ts('Name'),
130 'sort' => 'civicrm_contact.sort_name',
131 'direction' => CRM_Utils_Sort
::ASCENDING
,
133 if ($this->_participantListingType
== 'Name and Email') {
135 'name' => ts('Email'),
136 'sort' => 'civicrm_email.email',
137 'direction' => CRM_Utils_Sort
::DONTCARE
,
142 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
143 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
144 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
147 $sort = new CRM_Utils_Sort($headers, $sortID);
148 $this->assign_by_ref('headers', $headers);
149 $this->assign_by_ref('sort', $sort);
150 $this->set(CRM_Utils_Sort
::SORT_ID
,
151 $sort->getCurrentSortID()
153 $this->set(CRM_Utils_Sort
::SORT_DIRECTION
,
154 $sort->getCurrentSortDirection()
157 return $sort->orderBy();