function private_nodeapi in Private 6
Same name and namespace in other branches
- 5 private.module \private_nodeapi()
Implementation of hook_nodeapi().
- "delete", "insert", and "update":
The module must track the access status of the node.
File
- ./
private.module, line 185 - 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_nodeapi(&$node, $op, $arg = 0) {
switch ($op) {
case 'load':
$result = db_fetch_object(db_query('SELECT * FROM {private} WHERE nid = %d', $node->nid));
$node->private = $result->private;
break;
case 'delete':
db_query('DELETE FROM {private} WHERE nid = %d', $node->nid);
break;
case 'insert':
case 'update':
db_query('UPDATE {private} SET private = %d WHERE nid = %d', $node->private, $node->nid);
if (!db_affected_rows()) {
db_query('INSERT INTO {private} (nid, private) VALUES (%d, %d)', $node->nid, $node->private);
}
break;
}
}