For now, only transitions from one state to another (different) one are handled.
The case where a node is re-submitted but staying in the same state escapes the module.

Example :
Say I have two states : 'pending for approval' and 'approved'.
and to profiles : 'writer' and 'reviewer'

Only reviewers can trigger 'pending' => 'approved'
writers _can_ trigger 'approved' => 'pending', but currently they don't _have_ to, on node edition form they have a choice between moving to 'pending' or staying 'approved'.

Of course this is not desired : the edit of an 'approved' node by a writer should force the node to go back to 'pending'.
Meaning, i would like to be able to forbid the 'approved' -> 'approved' transition for 'writers' (on page admin/workflow/edit/(id))

Or maybe there are hardships with these 'unchanged state' transitions that forced you to rule them out of the scope of your module ?

CommentFileSizeAuthor
#1 workflow_1.patch8.41 KBmattgrayson

Comments

mattgrayson’s picture

StatusFileSize
new8.41 KB

Ironically enough, I created this patch yesterday to do exactly this. My use case was identical to what you described. It's not entirely complete (removing a workflow doesn't delete required state changes from the database) and probably has a bug or two still floating around. I'd never taken a look at the workflow.module code until yesterday. In any case, I'm running the latest cvs and it appears to work just fine after some limited testing.

Apply the patch to workflow.module and create the following table in your Drupal DB:

CREATE TABLE `workflow_role_requires_state_change` (
  `sid` int(11) NOT NULL,
  `role` varchar(255) NOT NULL,
  PRIMARY KEY  (`sid`,`role`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Once that's done, you will see a new section when you edit your workflow called "Require State Change for Role." There will be a column for each of your states with a list of all roles under each column. For your case, you would put a check box next "writer" under the "approved" state. Once you save your changes, the next time a "writer" edits a node, they will be forced to select another state (assuming they can transition from the existing state) - the current state will not be available.

mfredrickson’s picture

Status: Active » Postponed

I'm going to postpone this request until later. There have been several requests for loopback transitions and I'll probably look to meet them in the 5.0-dev branch.

moshe weitzman’s picture

Status: Postponed » Active
RobRoy’s picture

Status: Active » Closed (duplicate)

Duplicate of http://drupal.org/node/86451. Can someone carry that torch? It was RTBC IMO back then, but it probably needs a re-roll. ;)

RobRoy’s picture

I guess mine is a dupe since it came after, but I didn't see this issue when it was postponed. I'm leaving it as is, but if my patch blows, we can vice-versa it.