You are here

function state_flow_node_update in State Machine 7

Same name and namespace in other branches
  1. 6 modules/state_flow/state_flow.module \state_flow_node_update()
  2. 7.2 modules/state_flow/state_flow.module \state_flow_node_update()

Implements hook_node_update().

File

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

Code

function state_flow_node_update($node) {
  global $user;
  $state_flow = state_flow_load_state_machine($node);

  //Check to see if we should go through workflow
  if (empty($node->stateflow_skip_workflow)) {
    if (!empty($node->state_flow_revert_draft) && $state_flow
      ->get_current_state() !== 'draft') {
      $state_flow
        ->fire_event('to draft');
    }
    else {
      $state_flow
        ->persist();
      if (!empty($node->revision)) {
        $state_flow
          ->write_history($user->uid);
      }
    }
    state_flow_prevent_live_revision($node);
  }
}