function comment_perm_node_view_alter in Comment Permissions 7
Same name and namespace in other branches
- 7.2 comment_perm.module \comment_perm_node_view_alter()
Implementation of hook_node_view_alter().
File
- ./
comment_perm.module, line 98 - Module to control commenting permissions by role and by node type.
Code
function comment_perm_node_view_alter(&$build) {
$types = variable_get('comment_perm_node_types', array());
$form_id_types = array();
if (is_array($types)) {
foreach ($types as $type) {
if ($build['#bundle'] == $type) {
if (!comment_perm_access($build['#node'])) {
unset($build['comments']['comment_form']);
unset($build['links']['comment']['#links']['comment-add']);
if (variable_get('comment_perm_hide_comments', 0)) {
unset($build['comments']);
unset($build['links']['comment']);
}
}
return;
}
}
}
}