function wf_crm_event_info in Webform CiviCRM Integration 7.3
Fetch info and remaining spaces for events
Parameters
$events: Array of event info to fill (reference)
2 calls to wf_crm_event_info()
- _wf_crm_frontend_form_alter in ./
webform_civicrm_forms.inc - Alter front-end of webforms: Called by hook_form_alter() when rendering a civicrm-enabled webform Add custom prefix. Display messages. Block users who should not have access. Set webform default values.
- _wf_crm_participant_validate in ./
webform_civicrm_forms.inc - Validation callback for event registrations.
File
- ./
webform_civicrm_utils.inc, line 1451 - Webform CiviCRM module's common utility functions.
Code
function wf_crm_event_info(&$events) {
if (!empty($events)) {
require_once 'CRM/Event/BAO/Participant.php';
$now = time();
// Fetch event info
$dao =& CRM_Core_DAO::executeQuery('SELECT id, title, end_date, max_participants
FROM civicrm_event WHERE id IN (' . implode(',', array_keys($events)) . ')');
while ($dao
->fetch()) {
$events[$dao->id]['title'] = $dao->title;
$events[$dao->id]['end_date'] = $dao->end_date;
$events[$dao->id]['full'] = FALSE;
$events[$dao->id]['ended'] = $dao->end_date && strtotime($dao->end_date) < $now;
if ($events[$dao->id]['max_participants'] = $dao->max_participants) {
$remaining = CRM_Event_BAO_Participant::eventFull($dao->id, TRUE, FALSE);
if (is_string($remaining)) {
$events[$dao->id]['full'] = TRUE;
$events[$dao->id]['remaining'] = 0;
$events[$dao->id]['full_message'] = $remaining;
}
else {
$events[$dao->id]['remaining'] = $remaining ? $remaining : $dao->max_participants;
}
}
}
$dao
->free();
}
}