function space_og::router in Spaces 7.3
Same name and namespace in other branches
- 6.3 spaces_og/plugins/space_og.inc \space_og::router()
- 7 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 134
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', $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_group_content_type('node', $node->type)) {
if (!empty($node->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE])) {
foreach ($node->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE] as $item) {
$gids[] = $item['gid'];
}
}
// 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->og->gid, $gids)) {
return;
}
// Otherwise route
$gid = reset($gids);
if ($gid) {
spaces_load('og', og_load($gid)->etid)
->activate();
}
return;
}
}
break;
}
}