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:

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

Comments

realityloop’s picture

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

add1sun’s picture

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.

pgillis’s picture

I am interested in the "Unpublish the latest revision of a node" piece of this. I have a workflow with my own interface and need an action to get at the unplublish functionality.

I will work on my local implementation, ultimately I would like this to be part of the revisions module out of the box, so I will submit a patch. If there is a better way for me to help out, let me know.

pgillis’s picture

StatusFileSize
new3.02 KB

I have attached a patch that implements an "Unplublish revision" action. I need functionality to complete the integration of workflow and revisions. Without it, I couldn't figure out how to unpublish a node from within the workflow.

kribby’s picture

So how would a total newb implement this in D6? (: I understand the process of adding a rule per http://drupal.org/node/172152, but I just want a button that shows up for the user with permissions.

pgillis’s picture

Status: Needs work » Closed (won't fix)

Have moved away from implementation that required the patch...so I would not push for inclusion due to a very similar action being available directly with revisioning_unpublish_node...my mistake.

pgillis’s picture

Status: Closed (won't fix) » Closed (fixed)