You are here

function spaces_router in Spaces 6

Same name and namespace in other branches
  1. 5.2 spaces.module \spaces_router()
  2. 5 spaces.module \spaces_router()
  3. 6.3 spaces.module \spaces_router()
  4. 6.2 spaces.module \spaces_router()
  5. 7.3 spaces.module \spaces_router()
  6. 7 spaces.module \spaces_router()

Wrapper around implementations of $space->router. Provides additional intelligence, including a global killswitch and routing when no spaces are active.

Parameters

$op: The current "hook" or "hook op" identifier for the $space->router to act on.

$object: Optional object to pass to the $space->router.

4 calls to spaces_router()
spaces_form_alter in ./spaces.module
Implementation of hook_form_alter().
spaces_init in ./spaces.module
Implementation of hook_init().
spaces_nodeapi in ./spaces.module
Implementation of hook_nodeapi().
spaces_user in ./spaces.module
Implementation of hook_user().

File

./spaces.module, line 1244

Code

function spaces_router($op, $object = NULL) {

  // Check global killswitch
  if (spaces_router_get()) {
    $access = true;
    $types = spaces_types();

    // Run the router for the active space
    if ($space = spaces_get_space()) {
      $access = $access && $space
        ->router($op, $object);
      unset($types[$space->type]);
    }

    // Run each non-active space type's router
    foreach ($types as $type => $info) {
      $access = $access && call_user_func(array(
        $info['class'],
        'router',
      ), $op, $object, FALSE);
    }
    if (!$access && !user_access('administer spaces')) {

      // We use a menu callback here rather than drupal_access_denied()
      // because spaces_router() is called at times from hook_init().
      // Using drupal_access_denied() can terminate the page request before
      // bootstrap completes, leading to all sorts of havoc.
      menu_set_active_item('spaces-access-denied');
    }
  }
}