You are here

function workflow_field_choices in Workflow 7.2

Same name and namespace in other branches
  1. 5.2 workflow.module \workflow_field_choices()
  2. 5 workflow.module \workflow_field_choices()
  3. 6.2 workflow.module \workflow_field_choices()
  4. 6 workflow.module \workflow_field_choices()
  5. 7 workflow.node.inc \workflow_field_choices()

Get the states current user can move to for a given node.

Parameters

object $node: The node to check.

bool $force: A switch to enable access to all states (e.g., for Rules).

State $state: The predetermined state object (v7.x-1.3: new parameter for Workflow Field).

Return value

array Array of transitions.

Deprecated

workflow_field_choices() --> WorkflowState->getOptions()

File

./workflow.deprecated.inc, line 180
Contains contains per-class functions, that are deprecated.

Code

function workflow_field_choices($node, $force = FALSE, $state = NULL) {
  global $user;

  // Alert: In 7.x-2.4, getOptions() has a new $user parameter.
  $choices = array();
  if (!$node) {

    // If no node is given, no result. (e.g., on a Field settings page.)
    return $choices;
  }
  if ($state) {

    // This is used in Field API. A state object is already passed in.
  }
  else {

    // This is used in Node API.
    $field_name = '';

    // An explicit var is needed.
    $current_sid = workflow_node_current_state($node, 'node', $field_name);
    $state = workflow_state_load_single($current_sid);
  }
  return $state
    ->getOptions('node', $node, '', $user, $force);
}