function og_menu_block in Organic Groups Menu (OG Menu) 6.2
Same name and namespace in other branches
- 6 og_menu.module \og_menu_block()
Implementation of hook_block().
File
- ./
og_menu.module, line 139 - Integrates Menu with Organic Groups. Lots of menu forms duplication in OG context.
Code
function og_menu_block($op = 'list', $delta = 0, $edit = array()) {
if ($op == 'list') {
$blocks = array(
0 => array(
'info' => t('OG Menu : single'),
'cache' => BLOCK_NO_CACHE,
),
1 => array(
'info' => t('OG Menu : multiple'),
'cache' => BLOCK_NO_CACHE,
),
);
return $blocks;
}
else {
if ($op == 'view' && $delta == 0) {
$group = og_get_group_context();
$menus = og_menu_get_group_menus(array(
$group->nid,
));
$menu = array_shift($menus);
return array(
'subject' => check_plain($menu['title']),
'content' => menu_tree($menu['menu_name']),
);
}
else {
if ($op == 'view' && $delta == 1) {
// Get all groups associated with the current node
$node = menu_get_object();
$gids = array();
if ($node) {
if (og_is_group_post_type($node->type)) {
$gids = $node->og_groups;
}
else {
if (og_is_group_type($node->type)) {
$gids = array(
$node->nid,
);
}
}
}
// If no group was found, fallback to the regular og_get_group_context
// function. Unfortunately, this function only returns one group.
if (empty($gids)) {
$group = og_get_group_context();
$gids = array(
$group->nid,
);
}
$menus = og_menu_get_group_menus($gids);
foreach ($menus as $menu) {
$block = new stdClass();
$block->module = 'og_menu';
$block->delta = $delta . '-' . $menu['menu_name'];
$block->subject = check_plain($menu['title']);
$block->content = menu_tree($menu['menu_name']);
$content .= theme('block', $block);
}
return array(
'content' => $content,
'multiple' => TRUE,
);
}
}
}
}