You are here

function registration_has_room in Entity Registration 7.2

Same name and namespace in other branches
  1. 8.2 registration.module \registration_has_room()
  2. 8 registration.module \registration_has_room()
  3. 7 registration.module \registration_has_room()

Determines if a host entity has spaces remaining.

Parameters

string $entity_type: The host entity type.

int $entity_id: The host entity ID.

int $spaces: (optional) Used if validating a new registration. The number of spaces attempting to fill.

int $registration_id: The registration ID. Used to exclude specified registration from count.

Return value

bool

See also

registration_status()

4 calls to registration_has_room()
RegistrationStandardTestCase::testRegistrationForm in tests/registration.test
Tests for the registration add/edit form.
registration_form in includes/registration.forms.inc
Form callback: create or edit a registration.
registration_form_validate in includes/registration.forms.inc
Validation callback for registration_form().
registration_status in ./registration.module
Check if new registrations are permitted for a host entity.

File

./registration.module, line 833

Code

function registration_has_room($entity_type, $entity_id, $spaces = 1, $registration_id = NULL, $reset = FALSE) {
  $settings = registration_entity_settings($entity_type, $entity_id, $reset);
  $capacity = $settings['capacity'];
  if ($capacity) {
    $count = registration_event_count($entity_type, $entity_id, $registration_id, $reset) + $spaces;
    if ($capacity - $count < 0) {
      return FALSE;
    }
  }
  return TRUE;
}