function og_context_handler_comment

7.x-2.x og_context.module og_context_handler_comment()

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

1 string reference to 'og_context_handler_comment'

File

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

Code

function og_context_handler_comment() {
  $item = menu_get_item();
  // 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]);
  }
  // Use the comment ID.
  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);
}