Hey,

I'm not too sure if this is more a bug or a feature request but here goes. My clients have come across an issue with the Revisioning module where they are given the message "You are not authorized to access this page" when they try to publish a revision that has already been published. I know you must be thinking that it's not really possible to do so unless you explicitly alter the url to try to but this event occurs because we have workflow emails sent out to moderators of content on our site. If 2 moderators open emails at the same time, one publishes the content and then the other tries to publish it they see the message I mentioned above.

My proposed solution is to redirect the user back to the revision view page with a drupal_set_message saying "This revision has already been published" or something to that effect.

The only problem is that I'm not really too sure about where to alter this (or I would've attached a patch). Currently I can see the most logical place would be in either _revisioning_node_revision_access or _revisioning_operation_appropriate but since the "publish revisions" op gets run through these functions on the view page it is a bit more complex than I first thought.

Can you recommend a way of changing this?

Cheers,
Adam

Comments

John Pitcairn’s picture

Sub. I've seen this happen too, I have users that love to bookmark the publish-confirm url and return to publish later.

RdeBoer’s picture

Assigned: Unassigned » RdeBoer

@Zombienaute
I see what you're saying. The use-case makes sense.
Unfortunately as you found yourself the desired behaviour doesn't map well to Drupal core's way of doing things. I will have a look at the Revisioning source and see what can be done.
Rik

RdeBoer’s picture

Hi Zombienaute, John Pitcairn,

This is not pretty, but may get the job done as a quick and dirty....

In file revisioning.module, function _revisioning_operation_appropriate(), replace the code between case 'publish revisions:' and break; by:

    case 'publish revisions':
      if (!$node->revision_moderation && !user_access('administer nodes')) {
        return FALSE;
      }
      if (!($node->is_pending || ($node->is_current && !$node->status))) {
        static $redirected;
        if (!isset($redirected) && arg(4) == 'publish') {
            drupal_set_message(t("This revision has already been published."), 'warning');
            $redirected = TRUE;
            drupal_goto('/node/'. $node->nid .'/revisions');
        }
        return FALSE;
      }
      break;

Let us know how you go...
Rik

RdeBoer’s picture

Actually, the above treats already published revisions and archive revisions in the same way.
So you may want to keep the message very generic or taylor it to the specific case using the $node->is_current property.

Replace the drupal_set_message(...) call by something like this:

   .....
    if ($node->is_current) {
      drupal_set_message(t("Cannot publsih. This revision has already been published."), 'warning');
    }
    else {
      drupal_set_message(t("Cannot publish. This revision has already been archived."), 'warning');
    }
    ....
acbramley’s picture

Hey RdeBoer,

Cheers! Just need to change

drupal_goto('/node/'. $node->nid .'/revisions');

to

drupal_goto('node/'. $node->nid .'/revisions');
RdeBoer’s picture

Status: Active » Fixed

Cool. I may clean up the code and incorporate your suggestion in the next version.
Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.