function shoutbox_group_get_group in Shoutbox 6.2
Same name and namespace in other branches
- 7.2 shoutbox_group/shoutbox_group.module \shoutbox_group_get_group()
- 7 shoutbox_group/shoutbox_group.module \shoutbox_group_get_group()
Determined by og_get_group_context for the block, or URL arg's for the page
Return value
The group currently in context, otherwise FALSE
3 calls to shoutbox_group_get_group()
- shoutbox_group_init in shoutbox_group/
shoutbox_group.module - Implementation of hook_init().
- shoutbox_group_shoutbox in shoutbox_group/
shoutbox_group.module - Implementation of hook_shoutbox()
- _shoutbox_group_alter_form in shoutbox_group/
shoutbox_group.module - Alter the shoutbox add form Add the group ID to the shout form (if one)
File
- shoutbox_group/
shoutbox_group.module, line 213
Code
function shoutbox_group_get_group() {
static $group = FALSE;
// Retrieve the group if we haven't yet already
if (!$group) {
// First check og context for block view
if ($group = og_get_group_context()) {
return $group;
}
else {
if (arg(0) == 'shoutbox' && arg(1) == 'group' && is_numeric(arg(2))) {
// Check that arg(2) is a real group (already cleared as numeric value)
if ($node = node_load(arg(2))) {
// Make sure it's a group
if (og_is_group_type($node->type)) {
$group = $node;
}
}
}
else {
if (arg(0) == 'shout' && is_numeric(arg(1))) {
// Load the shout
if ($shout = shoutbox_load(arg(1))) {
// See if this is a group shout
if ($shout->module == 'shoutbox_group') {
// Determine the group
if ($gid = db_result(db_query("SELECT nid FROM {shoutbox_groups} WHERE shout_id = %d", $shout->shout_id))) {
// Load the group
if ($node = node_load($gid)) {
// Make sure it's really a group
if (og_is_group_type($node->type)) {
$group = $node;
}
}
}
}
}
}
}
}
}
return $group;
}