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
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

AttachmentSize
revision_moderation_actions.patch907 bytes

#1

realityloop - April 15, 2008 - 06:40
Status:needs review» reviewed & tested by the community

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

add1sun - December 22, 2008 - 02:14
Version:4.7.x-1.x-dev» 6.x-1.x-dev
Status:reviewed & tested by the community» needs work

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.

 
 

Drupal is a registered trademark of Dries Buytaert.