diff --git a/workbench_moderation.module b/workbench_moderation.module index 74d10d8..d23faf9 100644 --- a/workbench_moderation.module +++ b/workbench_moderation.module @@ -675,13 +675,28 @@ function workbench_moderation_node_update($node) { return; } - // Set default moderation state values. + // Set moderation state values. if (!isset($node->workbench_moderation_state_current)) { - $node->workbench_moderation_state_current = ($node->status ? workbench_moderation_state_published() : workbench_moderation_state_none()); - }; + $node->workbench_moderation_state_current = $node->original->workbench_moderation['current']->state ? $node->original->workbench_moderation['current']->state : workbench_moderation_state_none(); + } if (!isset($node->workbench_moderation_state_new)) { - $node->workbench_moderation_state_new = variable_get('workbench_moderation_default_state_' . $node->type, workbench_moderation_state_none()); - }; + // Moving from published to unpublished. + if ($node->status === NODE_NOT_PUBLISHED && $node->original->status === NODE_PUBLISHED) { + $node->workbench_moderation_state_new = variable_get('workbench_moderation_default_state_' . $node->type, workbench_moderation_state_none()); + } + // Moving from unpublished to published. + elseif ($node->status === NODE_PUBLISHED && $node->original->status === NODE_NOT_PUBLISHED) { + $node->workbench_moderation_state_new = workbench_moderation_state_published(); + } + else { + if (isset($node->original->workbench_moderation['published']) && $node->original->workbench_moderation['published']->state) { + $node->workbench_moderation_state_new = $node->original->workbench_moderation['published']->state; + } + else { + $node->workbench_moderation_state_new = variable_get('workbench_moderation_default_state_' . $node->type, workbench_moderation_state_none()); + } + } + } // If this is a new node, give it some information about 'my revision'. if (!isset($node->workbench_moderation)) {