You are here

function state_flow_node_edit_page_override in State Machine 7.3

Overrides the node/%/edit page to ensure the proper revision is shown.

Parameters

$node: The node being acted upon.

Return value

A node editing form.

1 string reference to 'state_flow_node_edit_page_override'
state_flow_menu_alter in modules/state_flow/state_flow.module
Implements hook_menu_alter().

File

modules/state_flow/state_flow.module, line 149
An implementation of node revision workflow for Drupal based on the State Machine system.

Code

function state_flow_node_edit_page_override($node) {

  // Check to see if this is an existing node.
  if (isset($node->nid)) {

    // Load the node moderation data.
    $machine = state_flow_entity_load_state_machine($node, 'node');
    $active_revision_id = $machine
      ->get_active_revision();
    if (!empty($active_revision_id)) {

      // We ONLY edit the active revision.
      $active_revision = node_load($node->nid, $machine->object->active_revision_id);
      if (!empty($active_revision)) {
        $node = $active_revision;
      }
      else {
        watchdog('state_flow', 'Node @title @nid has corrupted {state_flow_states} rows.', array(
          '@title' => $node->title,
          '@nid' => $node->nid,
        ), WATCHDOG_ERROR);
        drupal_set_message(t('Workflow data is corrupted, report this incident to the site administrators.'), 'error');
      }
    }
  }

  // Ensure we have the editing code.
  module_load_include('inc', 'node', 'node.pages');
  return node_page_edit($node);
}