You are here

function space_og::router in Spaces 7

Same name and namespace in other branches
  1. 6.3 spaces_og/plugins/space_og.inc \space_og::router()
  2. 7.3 spaces_og/plugins/space_og.inc \space_og::router()

Implementation of space->router().

Overrides space_type::router

File

spaces_og/plugins/space_og.inc, line 118

Class

space_og
Organic groups integration for Spaces.

Code

function router($op, $object = NULL, $is_active = TRUE) {
  global $user;
  switch ($op) {
    case 'init':
      return;
    case 'node':
      $node = $object;
      $form = !isset($node->nid) || isset($node->date) ? TRUE : FALSE;

      // Group node
      if (og_is_group_type($node->type)) {

        // Don't make new groups from within a group space.
        if (!isset($node->nid) && $this->active) {
          $this
            ->deactivate();
          return;
        }
        else {
          if (isset($node->nid) && (!$this->active || $this->active && $this->id != $node->nid) && ($space = spaces_load('og', $node->nid))) {
            $space
              ->activate();
            return;
          }
        }
      }
      else {
        if (!og_is_omitted_type($node->type) && !empty($node->og_groups)) {

          // If the node belongs to the current active group space, or we're in an allowable other space type, pass thru
          if ($this->active && in_array($this->id, $node->og_groups)) {
            return;
          }

          // Otherwise route
          reset($node->og_groups);
          spaces_load('og', current($node->og_groups))
            ->activate();
          return;
        }
      }
      break;
  }
}