Angie,

I would have asked you about this on your contact page, but you seem to prefer the issue queue, so here goes...

I'm setting up a workflow for a client, and plan to use your revision moderation module. This is the first time I've used it. The client wants to ensure that users who can edit nodes are not the same users who can publish nodes to the public. I'm setting up two roles to do the job, 'editor' and 'publisher'.

But you've set up revision moderation so that is introduces no new permissions. Instead it allows users to publish a given revision if they have 'administer nodes' or ('view revisions' and 'update content type') permissions. In both of these cases, the user is allowed to edit the node, and therefore unacceptable to my client. I need my 'publisher' role to be able to view revisions and publish one, but not to edit the content.

So, I'd like to introduce a way for a user who cannot edit the node to be able to publish a given revision. I can think of two options,

1) add a permission 'publish revision' to the revision moderation module.

2) add a 'publish revision' action to revision_moderation_action.inc. I'm new to actions as well, so I'm not sure yet whether this will give the user sufficient control over which revision is being published.

My questions for you are, first, would you accept a patch along these lines? And second, can you suggest the best approach?

Thanks, -Dave

CommentFileSizeAuthor
#3 171029.diff1.04 KBDave Cohen

Comments

toemaz’s picture

You have already one supporter for this feature. I would propose you try to create a patch and let it review. You want it anyway, do you? So, it's always easier to review a patch, than no patch at all. Thx!

Dave Cohen’s picture

I'm putting together a scheme using workflow, actions and revision moderation modules. When it's all working well, I'll submit a formal patch here. Currently, I'm experimenting with using an action to publish the latest revision of a node. It's working so far. I've added this code to revision_moderation_actions.inc.

/**
 * Implementation of a Drupal action.  Makes the latest revision of a
 * node the active one.
 */
function action_revision_moderation_publish_latest($op, $edit = array(), &$node) {
  switch ($op) {
    case 'metadata':
      return array(
        'description' => t('Make the latest node revision the active revision'),
        'type' => t('Node'),
        'batchable' => true,
        'configurable' => false,
      );
      break;
    case 'do':
	  // determine latest revision
	  $latest_vid = db_result(db_query("SELECT MAX(vid) FROM {node_revisions} nr WHERE nr.nid=%d GROUP BY nr.nid", $node->nid));
	  revision_moderation_publish($node->nid, $latest_vid);
      break;
  }  
}
Dave Cohen’s picture

Status: Active » Needs review
StatusFileSize
new1.04 KB

Here is a formal patch proposal. Apply to revision_moderation_actions.inc.

The idea is to use revision moderation in conjunction with workflow and actions. With proper configuration, I'm able to give a user access to the workflow tab, but not the node edit form. The workflow state change triggers this action, so the user can publish but not edit the node. I think its a useful action, even if your situation is less complicated than mine.

Anyone interested in using workflow and revision moderation together should visit http://drupal.org/node/171210, review and +1 that patch!

This work is sponsored by Medem.com.

Dave Cohen’s picture

There is also a problem with using the "Publish node" action when revision moderation is enabled. So I modified my action to both make the latest revision active and publish the node. I also moved the code to a custom module, so sorry I don't have a proper patch. I think an action like this would make a nice addition to Revision Moderation.

/**
 * Implementation of a Drupal action.  Makes the latest revision of a
 * node the active one.  And ensures the node is published.
 * 
 */
function action_custom_workflow_publish_latest($op, $edit = array(), &$node) {
  switch ($op) {
    case 'metadata':
      return array(
        'description' => t('Publish the latest revision of a node.'),
        'type' => t('Custom Workflow'),
        'batchable' => FALSE,
        'configurable' => FALSE,
      );
      break;
    case 'do':
      // Determine latest revision.
      $latest_vid = db_result(db_query("SELECT MAX(vid) FROM {node_revisions} nr WHERE nr.nid=%d GROUP BY nr.nid", $node->nid));
      $message = t("Publishing revision %vid of !link",
                   array('%vid' => $latest_vid,
                         '!link' => l($node->title, "node/$node->nid")));
      drupal_set_message($message);
      watchdog('custom_workflow', $message);
      db_query("UPDATE {node} SET vid = %d, status = 1 WHERE nid = %d",
               $latest_vid, $node->nid);
      break;
  }  
}

Also, a quick plug for my blog entry about this topic: http://www.dave-cohen.com/node/1732

add1sun’s picture

Status: Needs review » Closed (duplicate)
rams_yandapalli’s picture

Title: Allow a user to publish, but not edit, a revision » revision edition getting problem...

I am having problem with revision moderation module..once i goes to edit revision option the content is going to publish..i am not getting why it happens?? can you guys help...pls