function og_set_group_context in Organic groups 6.2
Same name and namespace in other branches
- 5.8 og.module \og_set_group_context()
- 5 og.module \og_set_group_context()
- 5.2 og.module \og_set_group_context()
- 5.3 og.module \og_set_group_context()
- 5.7 og.module \og_set_group_context()
- 6 og.module \og_set_group_context()
API function to set the group context for the current request.
Includes theme and language if they are configured for the group. Modules may set this as needed.
This context is originally set during og_determine_context().
Parameters
$node: The group node object that should be set as the context. You can use og_determine_context_get_group() to assist you with finding the appropriate group node.
$clear: Clear the group context.
Return value
The group node object if set.
6 calls to og_set_group_context()
- og_clear_group_context in ./
og.module - API function; Clear the group context for the current request.
- og_get_group_context in ./
og.module - API function for getting the group context (if any) for the current request.
- og_init in ./
og.module - Implementation of hook_init().
- og_views_handler_argument_og_group_nid::query in modules/
og_views/ includes/ og_views_handler_argument_og_group_nid.inc - og_views_handler_argument_og_uid_nid::query in modules/
og_views/ includes/ og_views_handler_argument_og_uid_nid.inc
File
- ./
og.module, line 797 - Code for the Organic Groups module.
Code
function og_set_group_context($node = NULL, $clear = FALSE) {
static $stored_group_node;
if ($clear) {
$stored_group_node = NULL;
}
if (!empty($node) && og_is_group_type($node->type)) {
$stored_group_node = $node;
og_set_theme($node);
// When setting the language, avoid doing so if we are on a node page
// and the language of the node is different to the language of the
// group. This covers the case when the site doesn't have a prefix for
// the default language, particularly if the same node is posted in
// multiple groups.
$current_node = menu_get_object();
if (!$current_node || !og_is_group_type($current_node->type) && $current_node->language == $node->og_language) {
og_set_language($node);
}
}
return !empty($stored_group_node) ? $stored_group_node : NULL;
}