You are here

function state_flow_operation_change_helper in State Machine 7.2

Same name and namespace in other branches
  1. 7.3 modules/state_flow/state_flow.module \state_flow_operation_change_helper()
2 calls to state_flow_operation_change_helper()
state_flow_node_revision_operation_change_state in modules/state_flow/state_flow.module
Operation callback to change state of a node
state_flow_node_revision_operation_change_state_batch_process in modules/state_flow/state_flow.module
State Change Mass Update Batch operation

File

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

Code

function state_flow_operation_change_helper($info, $event) {
  global $user;
  $allowed_events = array();
  $node = node_load($info['nid'], $info['vid']);
  $state_machine = state_flow_load_state_machine($node);
  if (!$state_machine
    ->ignore()) {
    $allowed_events = $state_machine
      ->get_available_events();
  }
  if (in_array($event, array_keys($allowed_events))) {
    $state_machine
      ->fire_event($event, $user->uid, 'State changed via Bulk Node Operation');
    return t('@title has been transitioned to @state', array(
      '@title' => $node->title,
      '@state' => $state_machine
        ->get_label_for_current_state(),
    ));
  }
}