You are here

function _revisioning_view_edit_access_callback in Revisioning 7

Same name and namespace in other branches
  1. 8 revisioning.module \_revisioning_view_edit_access_callback()
  2. 6.4 revisioning.module \_revisioning_view_edit_access_callback()
  3. 6.3 revisioning.module \_revisioning_view_edit_access_callback()

Access callback function.

Access callback for 'node/%', 'node/%/view' and 'node/%/edit' links that may appear anywhere on the site. At the time that this function is called the CURRENT revision will already have been loaded by the system. However depending on the value of the 'revisioning_view_callback' and 'revisioning_edit_callback' variables (as set on the admin/config/content/revisioning page), this may not be the desired revision. If these variables state that the LATEST revision should be loaded, we need to check at this point whether the user has permission to view this revision.

The 'View current' and/or 'Edit current' tabs are suppressed when the current revision is already displayed via one of the Revisions subtabs. The 'View latest' and/or 'Edit latest' tabs are suppressed when the latest revision is already displayed via one of the Revisions subtabs.

Parameters

string $op: must be one of 'view' or 'edit'

object $node: the node object

Return value

bool FALSE if access to the desired revision is denied

1 string reference to '_revisioning_view_edit_access_callback'
revisioning_menu_alter in ./revisioning.module
Implements hook_menu_alter().

File

./revisioning.module, line 1025
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_view_edit_access_callback($op, $node) {
  $load_op = _revisioning_load_op($node, $op);
  $vid = arg(3);
  if (!empty($node->revision_moderation) && is_numeric($vid)) {

    // The View, Edit primary tabs are requested indirectly, in the context of
    // the secondary tabs under Revisions, e.g. node/%/revisions/%
    if ($load_op == REVISIONING_LOAD_CURRENT && $vid == $node->current_revision_id) {

      // Suppress 'View current' and 'Edit current' tabs when viewing current.
      return FALSE;
    }
    if ($load_op == REVISIONING_LOAD_LATEST && $vid == revisioning_get_latest_revision_id($node->nid)) {

      // Suppress 'View latest' and 'Edit latest' tabs when viewing latest.
      return FALSE;
    }
  }
  if ($load_op == REVISIONING_LOAD_LATEST) {

    // _revisioning_load_op has already checked permission to view latest.
    return TRUE;
  }
  $revision_op = $op == 'view' ? 'view current' : 'edit current';
  return _revisioning_access_node_revision($revision_op, $node);
}