Publish pending revision action
ronan - May 15, 2007 - 17:11
| Project: | Revision Moderation |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Jump to:
Description
Great module looks like this one is going to play a prominent role in my future sites.
Here is an action which publishes the latest pending revision. I created it to help integrate this module with Workflow/Actions. Others might find it useful too.
This patch should apply to the latest version of revision_moderation_actions.inc or the following function can be added anywhere in that file:
<?php
/**
* Revert to latest pending revision.
*/
function action_revision_moderation_publish_pending($op, $edit = array(), &$node) {
switch ($op) {
case 'metadata':
return array(
'description' => t('Publish (revert to) the latest pending revision.'),
'type' => t('Node'),
'batchable' => false,
'configurable' => false,
);
break;
case 'do':
if ($revisions = revision_moderation_get_node_pending_revisions($node->nid)) {
// get the last revision
$latest = array_shift( $revisions );
revision_moderation_publish($node->nid, $latest->vid);
}
break;
}
}
?>I have tested it with Drupal 4.7, Revision Moderation 4.7.x-1.0 and the latest releases of Workflow and Action for 4.7 and it seems to work well.
Hope this is helpful
Ronan
Gorton Studios - http://www.gortonstudios.com
| Attachment | Size |
|---|---|
| revision_moderation_actions.patch | 907 bytes |

#1
Thanks for this.. exactly what I'm after!
Worked for me with 5.x-1.0 of Revision Moderation and 5.x-1.0 of Actions
If you find this thread also check out the improved version of this code that does the publish step as well:
http://drupal.org/node/171029#comment-598502
#2
Both #171029: revision edition getting problem... and #247225: Add actions for "Publish the latest revision of a node." and "Unpublish the latest revision of a node." marked duplicates of this issue since this is the earliest. Both of those issues have patches as well. This needs to be brought up to D6 and then backported to D5. D4.7 isn't supported any longer.