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
19 class CRM_Event_Page_ParticipantListing_Simple
extends CRM_Core_Page
{
23 protected $_participantListingType;
25 protected $_eventTitle;
29 public function preProcess() {
30 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Integer', $this, TRUE);
32 // retrieve Event Title and include it in page title
33 $this->_eventTitle
= CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event',
37 CRM_Utils_System
::setTitle(ts('%1 - Participants', [1 => $this->_eventTitle
]));
39 // we do not want to display recently viewed contacts since this is potentially a public page
40 $this->assign('displayRecent', FALSE);
46 public function run() {
51 INNER JOIN civicrm_participant ON ( civicrm_contact.id = civicrm_participant.contact_id
52 AND civicrm_contact.is_deleted = 0 )
53 INNER JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id
54 LEFT JOIN civicrm_email ON ( civicrm_contact.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1 )
58 WHERE civicrm_event.id = %1
59 AND civicrm_participant.is_test = 0
60 AND civicrm_participant.status_id IN ( 1, 2 )";
61 $params = [1 => [$this->_id
, 'Integer']];
62 $this->pager($fromClause, $whereClause, $params);
63 $orderBy = $this->orderBy();
65 list($offset, $rowCount) = $this->_pager
->getOffsetAndRowCount();
68 SELECT civicrm_contact.id as contact_id ,
69 civicrm_contact.display_name as name ,
70 civicrm_contact.sort_name as sort_name ,
71 civicrm_participant.id as participant_id,
72 civicrm_email.email as email
76 LIMIT $offset, $rowCount";
79 $object = CRM_Core_DAO
::executeQuery($query, $params);
80 while ($object->fetch()) {
82 'id' => $object->contact_id
,
83 'participantID' => $object->participant_id
,
84 'name' => $object->name
,
85 'email' => $object->email
,
89 $this->assign_by_ref('rows', $rows);
97 * @param array $whereParams
99 public function pager($fromClause, $whereClause, $whereParams) {
103 $params['status'] = ts('Group') . ' %%StatusMessage%%';
104 $params['csvString'] = NULL;
105 $params['buttonTop'] = 'PagerTopButton';
106 $params['buttonBottom'] = 'PagerBottomButton';
107 $params['rowCount'] = $this->get(CRM_Utils_Pager
::PAGE_ROWCOUNT
);
108 if (!$params['rowCount']) {
109 $params['rowCount'] = CRM_Utils_Pager
::ROWCOUNT
;
113 SELECT count( civicrm_contact.id )
118 $params['total'] = CRM_Core_DAO
::singleValueQuery($query, $whereParams);
119 $this->_pager
= new CRM_Utils_Pager($params);
120 $this->assign_by_ref('pager', $this->_pager
);
126 public function orderBy() {
127 static $headers = NULL;
131 'name' => ts('Name'),
132 'sort' => 'civicrm_contact.sort_name',
133 'direction' => CRM_Utils_Sort
::ASCENDING
,
135 if ($this->_participantListingType
== 'Name and Email') {
137 'name' => ts('Email'),
138 'sort' => 'civicrm_email.email',
139 'direction' => CRM_Utils_Sort
::DONTCARE
,
144 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
145 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
146 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
149 $sort = new CRM_Utils_Sort($headers, $sortID);
150 $this->assign_by_ref('headers', $headers);
151 $this->assign_by_ref('sort', $sort);
152 $this->set(CRM_Utils_Sort
::SORT_ID
,
153 $sort->getCurrentSortID()
155 $this->set(CRM_Utils_Sort
::SORT_DIRECTION
,
156 $sort->getCurrentSortDirection()
159 return $sort->orderBy();