function og_subgroups_context_current_group in Subgroups for Organic groups 6
Determine the current group we're in
4 calls to og_subgroups_context_current_group()
- og_subgroups_context_condition_has_children::execute in modules/
og_subgroups_context/ plugins/ og_subgroups_context_condition_has_children.inc - Execute the plugin
- og_subgroups_context_condition_has_parent::execute in modules/
og_subgroups_context/ plugins/ og_subgroups_context_condition_has_parent.inc - Execute the plugin
- og_subgroups_context_condition_has_siblings::execute in modules/
og_subgroups_context/ plugins/ og_subgroups_context_condition_has_siblings.inc - Execute the plugin
- og_subgroups_context_condition_node_below_og::execute in modules/
og_subgroups_context/ plugins/ og_subgroups_context_condition_node_below_og.inc - Execute the plugin
File
- modules/
og_subgroups_context/ og_subgroups_context.module, line 108
Code
function og_subgroups_context_current_group() {
static $group = FALSE;
// See if we haven't registered a group yet
if (!$group) {
// Attempt to get the group from OG's context
if (!($group = og_get_group_context())) {
// Try to get the nid from the URL
$nid = 0;
if (arg(0) == 'node') {
if (arg(1) == 'add' && arg(2) && isset($_GET['gids'][0])) {
$nid = $_GET['gids'][0];
}
else {
if (is_numeric(arg(1))) {
$nid = arg(1);
}
}
}
else {
if (arg(0) == 'og') {
if ((arg(1) == 'users' || arg(1) == 'manage') && is_numeric(arg(2))) {
$nid = arg(2);
}
}
}
// See if we have registered an nid to test
if ($nid) {
// Attempt to load the node
if ($node = node_load($nid)) {
// See if this is a group type
if (og_is_group_type($node->type)) {
// Set this node as our group
$group = $node;
}
}
}
}
}
return $group;
}