You are here

function comment_perm_edit_access in Comment Permissions 6

Same name and namespace in other branches
  1. 7.2 comment_perm.module \comment_perm_edit_access()
  2. 7 comment_perm.module \comment_perm_edit_access()

Can the current user edit comments?

2 calls to comment_perm_edit_access()
comment_perm_form_alter in ./comment_perm.module
Implementation of hook_form_alter().
comment_perm_preprocess_comment in ./comment_perm.module
Process variables for comment.tpl.php.

File

./comment_perm.module, line 236
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;
}