node_example_access

Versions
4.6 – 5
node_example_access($op, $node)
6 – 7
node_example_access($op, $node, $account)

Implementation of hook_access().

Node modules may implement node_access() to determine the operations users may perform on nodes. This example uses a very common access pattern.

Code

developer/examples/node_example.module, line 70

<?php
function node_example_access($op, $node, $account) {
  if ($op == 'create') {
    return user_access('create example content', $account);
  }

  if ($op == 'update') {
    if (user_access('edit any example content', $account) || (user_access('edit own example content', $account) && ($account->uid == $node->uid))) {
      return TRUE;
    }
  }

  if ($op == 'delete') {
    if (user_access('delete any example content', $account) || (user_access('delete own example content', $account) && ($account->uid == $node->uid))) {
      return TRUE;
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.