function workflow_node_insert in Workflow 7
Implements hook_node_insert().
This is executed after saving data to the database. We cannot use hook_node_presave, because workflow_execute_transition() needs the nid.
File
- ./
workflow.node.inc, line 91 - Node specific functions, remnants of nodeapi.
Code
function workflow_node_insert($node) {
// Skip if there are no workflows.
if ($workflow = workflow_get_workflows_by_type($node->type)) {
// Normally, the new state is already set.
// If the state is not specified, use first valid state.
// For example, a new node must move from (creation) to some
// initial state.
if (empty($node->workflow)) {
$new_sid = $workflow
->getFirstSid('node', $node);
}
else {
$new_sid = $node->workflow;
}
if ($new_sid) {
workflow_transition($node, $new_sid);
}
}
}