You are here

function sheetnode_node_access in Sheetnode 7

Same name and namespace in other branches
  1. 7.2 sheetnode.module \sheetnode_node_access()

Implements hook_node_access().

File

./sheetnode.module, line 60
Module file for the sheetnode module.

Code

function sheetnode_node_access($op, $node, $account) {
  if (is_string($node)) {
    if ($node != 'sheetnode') {
      return NODE_ACCESS_IGNORE;
    }
  }
  if ($op == 'create') {
    return user_access('create sheetnode', $account) ? NODE_ACCESS_ALLOW : NODE_ACCESS_DENY;
  }
  if ($op == 'update') {
    return user_access('edit any sheetnode', $account) || user_access('edit own sheetnode', $account) && $account->uid == $node->uid ? NODE_ACCESS_ALLOW : NODE_ACCESS_DENY;
  }
  if ($op == 'delete') {
    return user_access('delete any sheetnode', $account) || user_access('delete own sheetnode', $account) && $account->uid == $node->uid ? NODE_ACCESS_ALLOW : NODE_ACCESS_DENY;
  }
}