You are here

function private_node_grants in Private 7.2

Same name and namespace in other branches
  1. 5 private.module \private_node_grants()
  2. 6 private.module \private_node_grants()
  3. 7 private.module \private_node_grants()

Implements hook_node_grants().

Tell the node access system what GIDs the user belongs to for each realm.

File

./private.module, line 66
A tremendously simple access control module -- it allows users to mark individual nodes as private; users with 'access private content' perms can read these nodes, while others cannot.

Code

function private_node_grants($account, $op) {
  $grants = array();
  if ($op == 'view') {
    if ($account->uid != 0) {

      // Grant to the author for own content.
      $grants['private_author'] = array(
        $account->uid,
      );
    }

    // Grant for private content.
    if (user_access('access private content', $account)) {
      $grants['private_view'] = array(
        PRIVATE_GRANT_ALL,
      );
    }
  }
  return $grants;
}