You are here

function state_flow_node_update in State Machine 7.2

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

Implements hook_node_update().

File

modules/state_flow/state_flow.module, line 199
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);
  $options = $state_flow
    ->get_states_options();
  if (!state_flow_skip_workflow($node)) {
    if (!$state_flow
      ->ignore()) {
      if (!empty($node->state_flow_revert_draft) && $state_flow
        ->get_current_state() !== 'draft' && in_array("draft", $options)) {
        $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);
    }
  }
}