function og_determine_context in Organic groups 6
Same name and namespace in other branches
- 6.2 og.module \og_determine_context()
Set group context using the menu system.
Modules may override the custom theme and group context set here.
Return value
A group node object, or NULL if not a group page.
See also
File
- ./
og.module, line 460
Code
function og_determine_context() {
$item = menu_get_item();
$object = menu_get_object();
// Use the menu system to get the path.
$path = $item['path'];
// Check if this is an existing node.
if (!empty($object->nid)) {
$node = $object;
}
elseif (strpos($path, 'node/add') === 0 && !empty($_REQUEST['gids'])) {
// URL pattern: node/add/story?gids[]=1
$gid = intval(current($_REQUEST['gids']));
$node = node_load($gid);
}
elseif ($item['map'][0] == 'og' && !empty($item['map'][2]) || $path == 'comment/reply/%') {
$node = menu_get_object('node', 2);
}
elseif ($path == 'comment/edit' || $path == 'comment/delete') {
// Get the node from the comment object.
$comment = _comment_load($item['page_arguments'][0]);
$node = node_load($comment->nid);
}
if (!empty($node) && ($group_node = og_determine_context_get_group($node))) {
return $group_node;
}
}