You are here

function module_grants_node_revision_access in Module Grants 6

Same name and namespace in other branches
  1. 6.4 module_grants.module \module_grants_node_revision_access()
  2. 6.3 module_grants.module \module_grants_node_revision_access()

Menu options dealing with revisions have their revision-specific permission checked before being tested for the associated node-specific operation. Return a boolean indicating whether the current user has the requested permission AND access to the given node (regardless of its published status).

Parameters

$node: Node object for which access right is requested

$permission: The requested permission, as a string eg 'delete revisions'

Return value

TRUE when the current user has access to the supplied node

1 string reference to 'module_grants_node_revision_access'
module_grants_menu_alter in ./module_grants.module
Implementation of hook_menu_alter().

File

./module_grants.module, line 108
Module to enable access control for unpublished content. Also makes sure that modules that operate on access grants behave in the expected way when enabled together.

Code

function module_grants_node_revision_access($revision_permission, $node) {

  // Map revision-permission to node access operation used in grants
  switch ($revision_permission) {
    case 'edit revisions':
      $op = 'update';
      break;
    case 'delete revisions':
      $op = 'delete';
      break;
    default:
      $op = 'view';
      break;
  }
  return user_access($revision_permission) && module_grants_node_access($op, $node);
}