You are here

Example: Node Access in Examples for Developers 6

Same name and namespace in other branches
  1. 7 node_access_example/node_access_example.module \node_access_example

Examples of node access restriction. (drupal 6)

This is an example illustrating how to restrict access to nodes based on some criterion associated with the user.

This example module will simply set a single flag on a node: 'private'. If the flag is set, only users with the 'view private content' flag can see the node, and all users with 'edit private content' can edit (but not delete) the node.

Additionally we will ensure that the node author can always view, edit, and delete the node by providing an additional access realm that grants privileges to the node's author.

Database definition:


  CREATE TABLE node_access_example (
    nid int(10) unsigned NOT NULL default '0' PRIMARY KEY,
    private int,
    KEY `node_example_nid` (nid)
  )

This example is part of the Examples for Developers Project which you can download and experiment with here: http://drupal.org/project/examples

Parent topics

File

node_access_example/node_access_example.module, line 28
This is an example illustrating how to restrict access to nodes based on some criterion associated with the user.

Functions

Constants

Namesort descending Location Description
NODE_ACCESS_EXAMPLE_GRANT_ALL node_access_example/node_access_example.module Here we define a constant for our node access grant ID, for the example realm. This ID could be any integer, but here we choose 23, because it is this author's favorite number.