Currently the node module either globally shows the revisions tab and revisions for all nodes or none at all.

What makes more sense to me is if the user can edit a node, then they should be able to see the revisions. If they don't have access to edit the node, then don't show the revisions. I was able to do that on D5 http://drupal.org/node/134113, but I can't figure out how to do it for D6.

Can anyone help?

Comments

gpk’s picture

1. To avoid messing with core I'd suggested using a custom module perhaps called "myrevisions" to do this. All you need is a .info file and a fairly small .module file. http://drupal.org/node/206753 has probably rather more info than you need.

2. In D6 you can use http://api.drupal.org/api/function/hook_menu_alter/6 to modify the menu system entries for node revisions. They are originally defined in http://api.drupal.org/api/function/node_menu/6 - look for the entries for revisions. Probably you want to change the entries for 'node/%node/revisions' and 'node/%node/revisions/%/view' to use a different access callback (myrevisions_access) instead of http://api.drupal.org/api/function/_node_revision_access/6.

3. Example, untested code to do this, in myrevisions.module:

function myrevisions_menu_alter(&$items) {
  // Change the access callback for the main node revisions listing page and for viewing a particular node revision.
  $items['node/%node/revisions']['access callback'] = 'myrevisions_access';
  $items['node/%node/revisions/%/view']['access callback'] = 'myrevisions_access';
}

4. For the record, note that a given user may not have edit permission on all revisions of a node because the input format for some may be one that the user is not allowed to use ... for your purposes it may be sufficient just to use the current revision when checking if a user can view a particular revision.

5. The $node object passed to myrevisions_access will be the particular node revision requested or else the current revision if on the listing page. $op will be as in http://api.drupal.org/api/function/_node_revision_access.

6. The bulk of your work will be in getting the access check right - fortunately I don't think you have to get to the bottom of Drupal's sophisticated menu system http://drupal.org/node/102338.

HTH,

gpk
----
www.alexoria.co.uk