function _nodehierarchyaccess_update_node_access in Node Hierarchy 6.2
Same name and namespace in other branches
- 6.3 nodehierarchyaccess/nodehierarchyaccess.module \_nodehierarchyaccess_update_node_access()
3 calls to _nodehierarchyaccess_update_node_access()
- nodehierarchyaccess_nodeapi in nodehierarchyaccess/
nodehierarchyaccess.module - Implementation of hook_nodeapi().
- _nodehierarchyaccess_copy_parent_grants in nodehierarchyaccess/
nodehierarchyaccess.module - Copy a node's parent's grants to the given node.
- _nodehierarchyaccess_set_descendant_grants in nodehierarchyaccess/
nodehierarchyaccess.module - Set the given grants for the children nodes
File
- nodehierarchyaccess/
nodehierarchyaccess.module, line 134 - A module to integrate nodehierarchy and nodeaccess.
Code
function _nodehierarchyaccess_update_node_access($node, $grants, $run_node_access = FALSE) {
// node_access_write_grants is used when running against nodes that aren't
// being invoked with nodeapi (the nodeaccess_grant_form or updating
// children nodes)
if ($run_node_access === TRUE) {
foreach (array(
'uid',
'rid',
) as $type) {
$realm = 'nodeaccess_' . $type;
node_access_write_grants($node, $grants, $realm);
}
}
// Delete all the grants for that nid in the nodeaccess table (used by
// the "nodeaccess" module)
db_query("DELETE FROM {nodeaccess} WHERE nid = %d", $node->nid);
foreach ($grants as $grant) {
if (in_array($grant['realm'], array(
'nodeaccess_rid',
'nodeaccess_uid',
))) {
db_query("INSERT INTO {nodeaccess} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", $node->nid, $grant['gid'], $grant['realm'], $grant['grant_view'], $grant['grant_update'], $grant['grant_delete']);
}
}
}