function webform_civicrm_event_info in Webform CiviCRM Integration 6.2
Same name and namespace in other branches
- 7.2 webform_civicrm_utils.inc \webform_civicrm_event_info()
Fetch info and remaining spaces for events
2 calls to webform_civicrm_event_info()
- _webform_civicrm_participant_validate in ./
webform_civicrm_forms.inc - Validation callback for event registrations.
- _webform_civicrm_webform_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.
File
- ./
webform_civicrm_utils.inc, line 1079 - Webform CiviCRM module's common utility functions. The code in this file is cross-compatible with D6/Civi3 and D7/Civi4 Drupal-version-specific functions belong in webform_civicrm_dx_functions.inc
Code
function webform_civicrm_event_info(&$events) {
if (!empty($events)) {
$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;
}
}
}
}
}