You are here

function workflow_transition in Workflow 7

Same name and namespace in other branches
  1. 5.2 workflow.module \workflow_transition()
  2. 6.2 workflow.module \workflow_transition()
  3. 6 workflow.module \workflow_transition()
  4. 7.2 workflow.deprecated.inc \workflow_transition()

Validate target state and either execute a transition immediately or schedule a transition to be executed later by cron.

@deprecated: workflow_transition --> WorkflowDefaultWidget::submit()

Parameters

object $node:

string $sid: An integer; the target state ID.

string $false: Allows bypassing permissions, primarily for Rules.

array $field: The field structure for the operation.

5 calls to workflow_transition()
workflow_comment_update in ./workflow.node.inc
Implements hook_comment_update().
workflow_node_insert in ./workflow.node.inc
Implements hook_node_insert().
workflow_node_update in ./workflow.node.inc
Implements hook_node_update().
workflow_tab_form_submit in ./workflow.pages.inc
Submit handler for the form on the workflow tab.
_workflow_rules_node_set_state in workflow_rules/workflow_rules.rules.inc
Action implementation: set current state, ignoring current user permission.

File

./workflow.module, line 254
Support workflows made up of arbitrary states.

Code

function workflow_transition($entity, $new_sid, $force = FALSE, $field = array()) {
  $entity_type = 'node';

  // Entity support is in workflow_transition --> WorkflowDefaultWidget::submit()
  $widget = new WorkflowDefaultWidget($field, $instance = array(), $entity_type, $entity);
  $form = array();
  $form_state = array();
  $items = array();
  $items[0]['workflow'] = (array) $entity;
  $items[0]['workflow']['workflow_options'] = $new_sid;
  $widget
    ->submit($form, $form_state, $items, $force);
}