node_access_example.module

Version 1.8 (checked in on 2007/09/09 at 01:27:07 by yched)

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:

<?php

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

?>

Functions

NameDescription
node_access_example_form_alterImplementation of hook_form_alter()
node_access_example_nodeapiImplementation of hook_nodeapi().
node_access_example_node_access_recordsImplementation of hook_node_access_records().
node_access_example_node_grantsImplementation of hook_node_grants().
node_access_example_permImplementation of hook_perm().