function revisioning_menu_alter in Revisioning 7
Same name and namespace in other branches
- 8 revisioning.module \revisioning_menu_alter()
- 6.4 revisioning.module \revisioning_menu_alter()
- 6 revisioning.module \revisioning_menu_alter()
- 6.3 revisioning.module \revisioning_menu_alter()
Implements hook_menu_alter().
Modify menu items defined in other modules (in particular the Node module).
File
- ./
revisioning.module, line 293 - Allows content to be updated and reviewed before submitting it for publication, while the current live revision remains unchanged and publicly visible until the changes have been reviewed and found fit for publication by a moderator.
Code
function revisioning_menu_alter(&$items) {
// Change to access callbacks for existing node paths so that we properly
// control revision-related operation.
// Some also have their page callbacks altered, e.g to load the latest
// rather than the current revision of a node.
// Can't change node load function to, say nid_load(), as we'll run into
// trouble elsewhere, e.g. menu_get_object(), due to the fact that the
// prefix, e.g. '%nid', is meant to be a type name, i.e. '%node'.
//
// Alter the 3 primary node page tabs: View tab, Edit tab, Revisions tab ...
$items['node/%node']['access callback'] = '_revisioning_view_edit_access_callback';
$items['node/%node']['access arguments'] = array(
'view',
1,
);
$items['node/%node']['page callback'] = '_revisioning_view';
$items['node/%node']['page arguments'] = array(
1,
);
// This is the MENU_DEFAULT_LOCAL_TASK, so inherits the above.
$items['node/%node/view']['title callback'] = '_revisioning_title_for_tab';
$items['node/%node/view']['title arguments'] = array(
1,
'view',
);
$items['node/%node/view']['weight'] = -10;
$items['node/%node/edit']['access callback'] = '_revisioning_view_edit_access_callback';
$items['node/%node/edit']['access arguments'] = array(
'edit',
1,
);
$items['node/%node/edit']['page callback'] = '_revisioning_edit';
$items['node/%node/edit']['page arguments'] = array(
1,
);
$items['node/%node/edit']['title callback'] = '_revisioning_title_for_tab';
$items['node/%node/edit']['title arguments'] = array(
1,
'edit',
);
// 'Revisions' tab remains, but points to new page callback, allowing users
// to pick the revision to view, edit, publish, revert, unpublish, delete.
// Need to override _node_revision_access() call back as it disallows access
// to the 'Revisions' tab when there's only one revision, which will prevent
// users from getting to the publish/unpublish links.
$items['node/%node/revisions']['access callback'] = '_revisioning_access_node_revision';
$items['node/%node/revisions']['access arguments'] = array(
'view revision list',
1,
);
$items['node/%node/revisions']['page callback'] = 'revisioning_node_overview';
$items['node/%node/revisions']['page arguments'] = array(
1,
);
$items['node/%node/revisions']['title callback'] = '_revisioning_title_for_tab';
$items['node/%node/revisions']['title arguments'] = array(
1,
'revisions',
);
// Remove the node.module links as we defined our own versions, using %vid
unset($items['node/%node/revisions/%/view']);
unset($items['node/%node/revisions/%/revert']);
unset($items['node/%node/revisions/%/delete']);
if (module_exists('diff')) {
// If Diff module is enabled, make sure it uses correct access callback.
$items['node/%node/revisions/view']['access callback'] = '_revisioning_access_node_revision';
$items['node/%node/revisions/view']['access arguments'] = array(
'view revisions',
1,
);
}
}