function state_flow_node_presave in State Machine 7
Same name and namespace in other branches
- 6 modules/state_flow/state_flow.module \state_flow_node_presave()
- 7.2 modules/state_flow/state_flow.module \state_flow_node_presave()
Implements hook_node_presave().
File
- modules/
state_flow/ state_flow.module, line 142 - An implementation of node revision workflow for Drupal based on the State Machine system.
Code
function state_flow_node_presave($node) {
// If the node is not new and is not marked to be ignored by
// state_flow_promote_node_revision(), then check its current state.
if (!empty($node->nid) && empty($node->state_flow_ignore_state)) {
$state_flow = state_flow_load_state_machine($node);
//Check to see if we should go through workflow
if (empty($node->stateflow_skip_workflow)) {
$state = $state_flow
->get_current_state();
if ($state == 'published') {
// If the node being updated is in the published state, then ensure that
// changes are saved to a new revision.
$node->revision = TRUE;
}
else {
if ($state != 'draft') {
// If the node being updated is not in the draft state, then mark this
// node to be reverted to draft state.
$node->state_flow_revert_draft = TRUE;
}
}
}
else {
if ($node->status) {
$state_flow
->fire_event('publish');
}
}
}
}