function comment_perm_comment_view_alter in Comment Permissions 7.2
Same name and namespace in other branches
- 7 comment_perm.module \comment_perm_comment_view_alter()
Implements hook_comment_view_alter().
File
- ./
comment_perm.module, line 105 - Control commenting permissions by role and by node type.
Code
function comment_perm_comment_view_alter(&$build) {
$node = $build['#node'];
if (!comment_perm_active_type($node->type)) {
return;
}
if (!comment_perm_edit_access($node) && !comment_perm_administer_access($node)) {
if (isset($build['links']['comment']['#links']['comment-edit'])) {
unset($build['links']['comment']['#links']['comment-edit']);
}
}
if (!comment_perm_post_access($node) && !comment_perm_administer_access($node)) {
if (isset($build['links']['comment']['#links']['comment-reply'])) {
unset($build['links']['comment']['#links']['comment-reply']);
}
}
if (!comment_perm_administer_access($node)) {
if (isset($build['links']['comment']['#links']['comment-approve'])) {
unset($build['links']['comment']['#links']['comment-approve']);
}
if (isset($build['links']['comment']['#links']['comment-delete'])) {
unset($build['links']['comment']['#links']['comment-delete']);
}
}
}