function workbench_moderation_node_presave in Workbench Moderation 7
Same name and namespace in other branches
- 7.2 workbench_moderation.module \workbench_moderation_node_presave()
Implements hook_node_presave().
Ensure that a node in moderation has the proper publication status. We set $node->status = 0 (unpublished) if this is a new node which has not been marked as published, or if the node has no published revision.
File
- ./
workbench_moderation.module, line 667 - Content moderation for Workbench.
Code
function workbench_moderation_node_presave($node) {
global $user;
if (isset($node->workbench_moderation_state_new)) {
// If the new moderation state is published, set the node status to
// published.
if ($node->workbench_moderation_state_new == workbench_moderation_state_published()) {
$node->status = 1;
}
else {
$node->status = 0;
}
}
// Preserve the changed timestamp of the revision when updating live revision.
if (!empty($node->workbench_moderation['updating_live_revision'])) {
$node->timestamp = $node->workbench_moderation['my_revision']->stamp;
$node->changed = $node->workbench_moderation['my_revision']->stamp;
}
}