You are here

function _revisioning_load_op in Revisioning 6.4

Same name and namespace in other branches
  1. 8 revisioning.module \_revisioning_load_op()
  2. 6.3 revisioning.module \_revisioning_load_op()
  3. 7 revisioning.module \_revisioning_load_op()
4 calls to _revisioning_load_op()
_revisioning_edit in ./revisioning.module
Callback for the primary Edit tab.
_revisioning_title_for_tab in ./revisioning.module
Callback for the primary View and Edit tabs.
_revisioning_view in ./revisioning.module
Menu callback for the primary View tab.
_revisioning_view_edit_access_callback in ./revisioning.module
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…

File

./revisioning.module, line 709
Allows the creation and modification of pre-published as well as live content while the current revision remains unchanged and publicly visible until the changes have been reviewed by a moderator.

Code

function _revisioning_load_op($node, $op, $check_access = FALSE) {
  if ($node->revision_moderation) {
    $view_mode = (int) variable_get('revisioning_view_callback', REVISIONING_LOAD_CURRENT);
    $edit_mode = (int) variable_get('revisioning_edit_callback', REVISIONING_LOAD_CURRENT);
    $load_op = $op == 'edit' ? $edit_mode : $view_mode;
    if ($load_op == REVISIONING_LOAD_LATEST) {

      // Site is configured to load latest revision, but we'll only do this if
      // the latest isn't loaded already and the user has the permission to do so.
      $latest_vid = revisioning_get_latest_revision_id($node->nid);
      if ($latest_vid != $node->current_revision_id) {
        if (!$check_access) {
          return REVISIONING_LOAD_LATEST;
        }
        $original_vid = $node->vid;
        $node->vid = $latest_vid;
        $node->is_current = node_tools_revision_is_current($node);
        $revision_op = $op == 'view' ? 'view revisions' : 'edit revisions';
        $access = _revisioning_node_revision_access($revision_op, $node);

        // Restore $node (even though called by value), so that it remains consistent
        $node->vid = $original_vid;
        $node->is_current = node_tools_revision_is_current($node);
        if ($access) {
          return REVISIONING_LOAD_LATEST;
        }
      }
    }
  }
  return REVISIONING_LOAD_CURRENT;
}