You are here

function og_context_handler_comment in Organic groups 7.2

Context handler; Get groups from parent of comment being added to it.

1 string reference to 'og_context_handler_comment'
og_context_og_context_negotiation_info in og_context/og_context.module
Implements hook_og_context_negotiation_info().

File

og_context/og_context.module, line 596
Get a group from a viewed page.

Code

function og_context_handler_comment() {
  $item = menu_get_item();

  // User has no access to the menu item.
  if (!$item) {
    return;
  }

  // Check if we are in comment/reply/%nid. No need to load the comment.
  if (isset($item['original_map'][2]) && is_numeric($item['original_map'][2])) {
    $node = node_load($item['original_map'][2]);
  }
  elseif (isset($item['original_map'][1]) && is_numeric($item['original_map'][1])) {
    $cid = $item['original_map'][1];
    if (!($comment = comment_load($cid))) {
      return;
    }
    $node = node_load($comment->nid);
  }
  else {
    return;
  }
  return og_context_handler_node($node);
}