You are here

function commons_events_cancel_event_form in Drupal Commons 7.3

Form to cancel a registration for an event.

3 string references to 'commons_events_cancel_event_form'
commons_events_forms in modules/commons/commons_events/commons_events.module
Implements hook_forms().
commons_origins_preprocess_form_content in themes/commons/commons_origins/template.php
Implements hook_preprocess_form_content().
theme_commons_events_attending_event in modules/commons/commons_events/includes/commons_events.theme.inc
Theme callback to display that a user is attending an event.

File

modules/commons/commons_events/includes/commons_events.forms.inc, line 112
Commons Events form declarations.

Code

function commons_events_cancel_event_form($form, &$form_state, $event, $registrations) {
  $form_state['event'] = $event;
  $form['#attributes'] = array(
    'class' => array(
      'commons-events-form-float',
    ),
  );
  $form['#attached']['css'] = array(
    drupal_get_path('module', 'commons_events') . '/css/commons_events.css',
  );
  $form['registration'] = array(
    '#type' => 'value',
    '#value' => $registrations,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Cancel'),
  );
  $form['submit']['#attributes']['class'][] = 'commons-events-button';
  $attendee_count = 0;
  foreach ($registrations as $registration) {
    $attendee_count += registration_event_count('node', $event->nid, $registration->registration_id);
  }

  // Remove registrant from count.
  $attendee_count--;
  if ($attendee_count > 1) {

    // Single attending message.
    $markup = t('You are attending with @guests', array(
      '@guests' => format_plural($attendee_count, '1 guest', '@count guests'),
    ));
  }
  else {
    $markup = t('You are attending.');
  }
  $form['attending'] = array(
    '#theme_wrappers' => array(
      'container',
    ),
    '#attributes' => array(
      'class' => array(
        'commons-event-status',
      ),
    ),
    '#markup' => $markup,
  );
  return $form;
}