function workflow_node_previous_state in Workflow 7
Same name and namespace in other branches
- 8 workflow.module \workflow_node_previous_state()
- 7.2 workflow.module \workflow_node_previous_state()
2 calls to workflow_node_previous_state()
- _workflow_rules_workflow_check_previous_state in workflow_rules/
workflow_rules.rules.inc - Condition implementation: check previous state.
- _workflow_rules_workflow_check_transition in workflow_rules/
workflow_rules.rules.inc - Condition implementation: check state transition.
File
- ./
workflow.module, line 513 - Support workflows made up of arbitrary states.
Code
function workflow_node_previous_state($node) {
$sid = FALSE;
// There is no nid when creating a node.
if (!empty($node->nid)) {
$sids = array();
$sid = -1;
$last_history = workflow_get_recent_node_history($node->nid);
$sid = !$last_history ? FALSE : $last_history->old_sid;
}
if (!$sid && !empty($node->type)) {
// No current state. Use creation state.
$entity_type = 'node';
if ($workflow = workflow_get_workflows_by_type($node->type, $entity_type)) {
$sid = $workflow
->getCreationSid();
}
}
return $sid;
}