You are here

function registration_register_page in Entity Registration 7.2

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

Page callback: Add a new registration to a host entity.

Parameters

string $entity_type: The host entity type.

object $entity: The host entity.

string $default_state: The default state to display in the state dropdown in the form.

Return value

array A render array

See also

registration_register_access()

registration_menu()

1 string reference to 'registration_register_page'
registration_menu in ./registration.module
Implements hook_menu().

File

./registration.module, line 637

Code

function registration_register_page($entity_type, $entity, $default_state = NULL) {
  list($entity_id) = entity_extract_ids($entity_type, $entity);
  if (registration_status($entity_type, $entity_id)) {
    $registration_type = registration_get_entity_registration_type($entity_type, $entity);
    $registration = entity_get_controller('registration')
      ->create(array(
      'entity_type' => $entity_type,
      'entity_id' => $entity_id,
      'type' => $registration_type,
    ));
    if (user_access("edit {$registration_type} registration state")) {
      $registration->state = $default_state;
    }
    return drupal_get_form('registration_form', $registration);
  }
  else {
    return t('Sorry, registrations are no longer available for %name', array(
      '%name' => entity_label($entity_type, $entity),
    ));
  }
}