You are here

function notifications_content_comment_allow in Notifications 6

Same name and namespace in other branches
  1. 5 notifications_content/notifications_content.module \notifications_content_comment_allow()
  2. 6.4 notifications_content/notifications_content.module \notifications_content_comment_allow()
  3. 6.2 notifications_content/notifications_content.module \notifications_content_comment_allow()
  4. 6.3 notifications_content/notifications_content.module \notifications_content_comment_allow()

Determine whether the specified user may view the specified comment.

Does a user switching and checks for node permissions. Looking for a better way but it seems that all the node_access hooks cant be invokes without this.

1 call to notifications_content_comment_allow()
notifications_content_notifications in notifications_content/notifications_content.module
Implementation of hook_notifications()

File

notifications_content/notifications_content.module, line 829
Subscriptions to content events

Code

function notifications_content_comment_allow($account, $comment) {
  static $access;
  $comment = is_object($comment) ? $comment : db_fetch_object(db_query("SELECT * FROM {comments} WHERE cid = %d", $comment));
  if (!isset($access[$account->uid][$comment->cid])) {
    if (($account->uid == $comment->uid || $comment->status == COMMENT_PUBLISHED) && user_access('access comments', $account) || user_access('administer comments', $account)) {
      $access[$account->uid][$comment->cid] = TRUE;
    }
    else {
      $access[$account->uid][$comment->cid] = FALSE;
    }
  }
  return $access[$account->uid][$comment->cid];
}