*
*/
public function listParticipations() {
- $controller = new CRM_Core_Controller_Simple(
- 'CRM_Event_Form_Search',
- ts('Events'),
- NULL,
- FALSE, FALSE, TRUE, FALSE
- );
- $controller->setEmbedded(TRUE);
- $controller->reset();
- $controller->set('context', 'user');
- $controller->set('cid', $this->_contactId);
- $controller->set('force', 1);
- $controller->process();
- $controller->run();
+ $event_rows = [];
+
+ $participants = \Civi\Api4\Participant::get(FALSE)
+ ->addSelect('id', 'contact_id', 'status_id:name', 'status_id:label', 'event.id', 'event.title', 'event.start_date', 'event.end_date')
+ ->addWhere('contact_id', '=', $this->_contactId)
+ ->addOrderBy('event.start_date', 'DESC')
+ ->execute()
+ ->indexBy('id');
+
+ // Flatten the results in the format expected by the template
+ foreach ($participants as $p) {
+ $p['participant_id'] = $p['id'];
+ $p['status'] = $p['status_id:name'];
+ $p['participant_status'] = $p['status_id:label'];
+ $p['event_id'] = $p['event.id'];
+ $p['event_title'] = $p['event.title'];
+ $p['event_start_date'] = $p['event.start_date'];
+ $p['event_end_date'] = $p['event.end_date'];
+
+ $event_rows[] = $p;
+ }
+
+ $this->assign('event_rows', $event_rows);
}
/**