function theme_commons_events_attending_event in Drupal Commons 7.3
Theme callback to display that a user is attending an event.
2 theme calls to theme_commons_events_attending_event()
- commons_events_entity_view_alter in modules/
commons/ commons_events/ commons_events.module - Implements hook_entity_view_alter().
- commons_events_tokens in modules/
commons/ commons_events/ commons_events.module - Implements hook_tokens().
File
- modules/
commons/ commons_events/ includes/ commons_events.theme.inc, line 10 - Commons Events theme functions.
Code
function theme_commons_events_attending_event($variables = array()) {
global $user;
$event = $variables['event'];
if (!$event->nid) {
return '';
}
$attendee_count = isset($variables['attendee_count']) ? $variables['attendee_count'] : 0;
$registration_type = registration_get_entity_registration_type('node', $event);
$registration = entity_get_controller('registration')
->create(array(
'entity_type' => 'node',
'entity_id' => $event->nid,
'type' => $registration_type,
'author_uid' => $user->uid,
));
if (!function_exists('commons_events_attend_event_form') || !function_exists('commons_events_cancel_event_form')) {
module_load_include('inc', 'commons_events', 'includes/commons_events.forms');
}
if (!registration_is_registered($registration, NULL, $user->uid) && registration_access('create', $registration, $user, $registration->type) && registration_status('node', $event->nid, TRUE)) {
return drupal_get_form('commons_events_attend_event_form_' . $event->nid, $event, $registration, $attendee_count);
}
elseif (registration_is_registered($registration, NULL, $user->uid) && registration_access('delete', $registration, $user, $registration->type)) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'registration')
->propertyCondition('user_uid', $user->uid)
->propertyCondition('entity_id', $event->nid)
->propertyCondition('entity_type', 'node');
$result = $query
->execute();
return drupal_get_form('commons_events_cancel_event_form_' . $event->nid, $event, $result['registration']);
}
return "";
}