function comment_perm_edit_access in Comment Permissions 7
Same name and namespace in other branches
- 6 comment_perm.module \comment_perm_edit_access()
- 7.2 comment_perm.module \comment_perm_edit_access()
Can the current user edit comments?
2 calls to comment_perm_edit_access()
- comment_perm_comment_view_alter in ./
comment_perm.module - comment_perm_form_alter in ./
comment_perm.module - Implementation of hook_form_alter().
File
- ./
comment_perm.module, line 249 - Module to control commenting permissions by role and by node type.
Code
function comment_perm_edit_access($node) {
if (is_numeric($node)) {
$node = node_load($node);
}
// get node types managed by comment_perm
$types = variable_get('comment_perm_node_types', array());
if ($types[$node->type]) {
// allow comment administrators to edit any comment
if (user_access('administer comments')) {
return TRUE;
}
// get assigned permissions for this user's role
if (user_access($node->type . ': edit own comments on ' . $node->type . ' content')) {
return TRUE;
}
// comment_perm controlled node types default to no permissions
return FALSE;
}
// non-comment_perm controlled node types default to whatever permission Drupal gives them.
return TRUE;
}