You are here

function workflow_node_current_state in Workflow 6

Same name and namespace in other branches
  1. 8 workflow.module \workflow_node_current_state()
  2. 5.2 workflow.module \workflow_node_current_state()
  3. 5 workflow.module \workflow_node_current_state()
  4. 6.2 workflow.module \workflow_node_current_state()
  5. 7.2 workflow.module \workflow_node_current_state()
  6. 7 workflow.module \workflow_node_current_state()

Get the current state of a given node.

Parameters

$node: The node to check.

Return value

The ID of the current state.

7 calls to workflow_node_current_state()
workflow_execute_transition in ./workflow.module
Execute a transition (change state of a node).
workflow_field_choices in ./workflow.module
Get the states current user can move to for a given node.
workflow_form_alter in ./workflow.module
Implementation of hook_form_alter().
workflow_nodeapi in ./workflow.module
Implementation of hook_nodeapi().
workflow_rules_check_state in workflow_rules/workflow_rules.module
Condition implementation: check state.

... See full list

File

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

Code

function workflow_node_current_state($node) {
  $sid = FALSE;

  // There is no nid when creating a node.
  if (!empty($node->nid)) {
    $sid = db_result(db_query('SELECT sid FROM {workflow_node} WHERE nid = %d', $node->nid));
  }
  if (!$sid && !empty($node->type)) {

    // No current state. Use creation state.
    $wid = workflow_get_workflow_for_type($node->type);
    $sid = _workflow_creation_state($wid);
  }
  return $sid;
}