You are here

function registration_waitlist_registration_status_alter in Entity Registration 8

Same name and namespace in other branches
  1. 8.2 modules/registration_waitlist/registration_waitlist.module \registration_waitlist_registration_status_alter()
  2. 7.2 modules/registration_waitlist/registration_waitlist.module \registration_waitlist_registration_status_alter()
  3. 7 modules/registration_waitlist/registration_waitlist.module \registration_waitlist_registration_status_alter()

Implements hook_registration_status_alter().

File

modules/registration_waitlist/registration_waitlist.module, line 60
Entity Registration waitlist functionality

Code

function registration_waitlist_registration_status_alter(&$status, &$context) {
  $entity_type = $context['entity_type'];
  $entity_id = $context['entity_id'];
  $settings = registration_entity_settings($entity_type, $entity_id);
  $capacity = $settings['capacity'];

  // Not unlimited capacity
  if ($capacity) {

    // We only want to check if the wait list is active when the only status error relates to capacity
    $capacity_error = FALSE;
    if (count($context['errors']) == 1) {
      $error = reset($context['errors']);
      $capacity_error = $error == t('insufficient spaces remaining') ? TRUE : FALSE;
    }

    // Capacity error, return true if the wait list is enabled.
    if ($capacity_error && registration_waitlist_is_active($entity_type, $entity_id, $context['errors'])) {
      $status = TRUE;
    }
  }
}