function node_access_example_nodeapi

Implementation of hook_nodeapi().

The module must track the access status of the node.

Related topics

File

node_access_example/node_access_example.module, line 213

Code

function node_access_example_nodeapi(&$node, $op, $arg = 0) {
    switch ($op) {
        case 'load':
            $node->private = db_result(db_query('SELECT private FROM {node_access_example} WHERE nid = %d', $node->nid));
            break;
        case 'insert':
            db_query('INSERT INTO {node_access_example} (nid, private) VALUES (%d, %d)', $node->nid, $node->private);
            break;
        case 'update':
            db_query('UPDATE {node_access_example} SET private = %d WHERE nid = %d', $node->private, $node->nid);
            break;
        case 'delete':
            db_query('DELETE FROM {node_access_example} WHERE nid = %d', $node->nid);
            break;
    }
}