You are here

function hook_user_node_access in Module Grants 6.3

Called from module_grants_node_revision_access() this hook allows contributed modules to either deny access to the supplied node or to state which node operation the user must be allowed to execute to access the node via the supplied revision operation.

If implemented this function should return either FALSE (meaning deny access to the node for this revision_op) or a required node operation (ie. 'view', 'update', 'delete'). This node operation is passed to module_grants_node_access(), which returns a boolean indicating whether access is granted or not. The Revisioning module takes advantage of this hook to combine its revision-related user permissions with proper access control, as provided by Module Grants.

Parameters

$revision_op:

$node:

Return value

either FALSE or the node operation required to access the node, i.e. 'view', 'update' or 'delete'

1 invocation of hook_user_node_access()
module_grants_node_access in ./module_grants.module
Similar to node_access() in node.module but ANDs rather than ORs grants together on a per module base to create more natural behaviour. Also makes sure that published and unpublished content are treated in the same way, i.e. that grants are checked in…

File

./module_grants.api.php, line 34
Hooks provided by the Module Grants module.

Code

function hook_user_node_access($revision_op, $node) {
  switch ($revision_op) {
    case 'view revision list':
      return user_access('view revisions') ? 'view' : FALSE;
    case 'edit revisions':
      return user_access('edit revisions') ? 'update' : FALSE;
  }
  return 'view';
}