protected function wf_crm_webform_base::loadEvents in Webform CiviCRM Integration 7.4
Same name and namespace in other branches
- 7.5 includes/wf_crm_webform_base.inc \wf_crm_webform_base::loadEvents()
Fetch info and remaining spaces for events
Parameters
$events: Array of event info to fill (reference)
2 calls to wf_crm_webform_base::loadEvents()
- wf_crm_webform_postprocess::validateParticipants in includes/
wf_crm_webform_postprocess.inc - Validate event participants and add line items
- wf_crm_webform_preprocess::populateEvents in includes/
wf_crm_webform_preprocess.inc - Check if events are open to registration and take appropriate action
File
- includes/
wf_crm_webform_base.inc, line 624
Class
- wf_crm_webform_base
- Class wf_crm_webform_base
Code
protected function loadEvents() {
if (!empty($this->events)) {
$now = time();
// Fetch event info
$dao = CRM_Core_DAO::executeQuery('SELECT id, title, start_date, end_date, event_type_id, max_participants, financial_type_id
FROM civicrm_event WHERE id IN (' . implode(',', array_keys($this->events)) . ')');
while ($dao
->fetch()) {
$this->events[$dao->id]['title'] = $dao->title;
$this->events[$dao->id]['start_date'] = $dao->start_date;
$this->events[$dao->id]['end_date'] = $dao->end_date;
$this->events[$dao->id]['event_type_id'] = $dao->event_type_id;
$this->events[$dao->id]['financial_type_id'] = $dao->financial_type_id;
$this->events[$dao->id]['full'] = FALSE;
$this->events[$dao->id]['ended'] = $dao->end_date && strtotime($dao->end_date) < $now;
if ($this->events[$dao->id]['max_participants'] = $dao->max_participants) {
$remaining = CRM_Event_BAO_Participant::eventFull($dao->id, TRUE, FALSE);
if (is_string($remaining)) {
$this->events[$dao->id]['full'] = TRUE;
$this->events[$dao->id]['remaining'] = 0;
$this->events[$dao->id]['full_message'] = $remaining;
}
else {
$this->events[$dao->id]['remaining'] = $remaining ? $remaining : $dao->max_participants;
}
}
}
$dao
->free();
}
}