function comment_og_node_view_alter in Comment OG 7
Implements hook_node_view_alter().
File
- ./
comment_og.module, line 75 - Provides comment integration for Organic Groups.
Code
function comment_og_node_view_alter(&$build) {
// Remove comment link and form for non-members.
$node = $build['#node'];
$group = og_context();
if ($group) {
if (!empty($group->gid)) {
// Using og_user_access directly since comment_og_access takes in a
// comment object or cid.
if (!og_user_access($group->gid, "post comment_node_" . $node->type)) {
unset($build['links']['comment']['#links']['comment-add']);
$build['links']['comment']['#links']['comment_forbidden'] = array(
'title' => theme('comment_post_forbidden', array(
'node' => $node,
)),
'html' => TRUE,
);
$build['comments']['comment_form'] = array();
}
}
}
}