You are here

function module_grants_menu_alter in Module Grants 6.3

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

Implementation of hook_menu_alter().

Modify menu items defined in other modules, in particular the node module.

File

./module_grants.module, line 99
Module to apply access grants to pre-published content just as they are to published content and to make multiple content access modules work together in the expected way.

Code

function module_grants_menu_alter(&$items) {

  // As module_grants_node_access() fixes the problem of grants not being
  // checked when a node isn't published, all node access menu links are
  // altered to use function module_grants_node_access().
  // For normal view/edit/delete operations module_grant_node_access() is
  // called directly, for the revision-specific operations the function is
  // called via module_grants_node_revision_access().
  // ---- Node-related access callbacks
  $items['node/%node']['access callback'] = 'module_grants_node_access';
  $items['node/%node']['access arguments'] = array(
    'view',
    1,
  );

  // [#828262]
  $items['node/%node/view']['access callback'] = 'module_grants_node_access';
  $items['node/%node/view']['access arguments'] = array(
    'view',
    1,
  );

  // @todo see http://drupal.org/node/756100
  $items['node/%node/edit']['access callback'] = 'module_grants_node_access';

  // Need to override delete because node.module's node_delete() calls
  // node_access() directly when module_grants_node_access() should be used.
  $items['node/%node/delete']['page arguments'] = array(
    'module_grants_node_delete_confirm',
    1,
  );
  $items['node/%node/delete']['access callback'] = 'module_grants_node_access';
  $items['node/%node/delete']['module'] = 'module_grants';
  $items['node/%node/delete']['file'] = 'module_grants.pages.inc';
  $items['node/%node/delete']['file path'] = drupal_get_path('module', 'module_grants');

  // ---- Revision-related access callbacks
  $items['node/%node/revisions']['access callback'] = 'module_grants_node_revision_access';
  $items['node/%node/revisions']['access arguments'] = array(
    'view revision list',
    1,
  );

  // Point /%node/revisions/%/view page to same callback as /%node/view (see
  // node.module) for a consistent view of current, pending, archived revisions
  $items['node/%node/revisions/%/view']['page callback'] = 'node_page_view';
  $items['node/%node/revisions/%/view']['access callback'] = 'module_grants_node_revision_access';
  $items['node/%node/revisions/%/view']['access arguments'] = array(
    'view revisions',
    1,
  );
  $items['node/%node/revisions/%/delete']['access callback'] = 'module_grants_node_revision_access';
  $items['node/%node/revisions/%/delete']['access arguments'] = array(
    'delete revisions',
    1,
  );
  $items['node/%node/revisions/%/revert']['access callback'] = 'module_grants_node_revision_access';
  $items['node/%node/revisions/%/revert']['access arguments'] = array(
    'revert revisions',
    1,
  );
  if (isset($items['node/%node/translate'])) {

    // [#766504]
    $items['node/%node/translate']['access callback'] = '_module_grants_translation_tab_access';
  }
}