You are here

function commons_events_get_raw_attendee_count in Drupal Commons 7.3

Helper function go get the raw number of attendees.

2 calls to commons_events_get_raw_attendee_count()
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/commons_events.module, line 670

Code

function commons_events_get_raw_attendee_count($node) {
  $attendee_count = 0;
  $query = db_select('registration', 'r')
    ->fields('r', array(
    'count',
  ))
    ->condition('entity_id', $node->nid)
    ->condition('entity_type', 'node')
    ->execute();

  // Add up all of the attendees going to the event.
  foreach ($query as $record) {
    $attendee_count += $record->count;
  }
  return $attendee_count;
}