In this tutorial we're going to describe how to integrate Workflow, Revisioning and Taxonomy Access in a site. This is an extension of Revisioning with state-based content access control, the only difference is that this tutorial will have some screenshots to guide you through.

Workflow

In a News site, you'll probably need this kind of Workflow:

Workflow explanation

Also, you probably want to control authors so they only post content in certain sections of your site like this:

Roles

Modules

You'll need the following modules:
Revisioning
Module Grants
Smart Pages (comes inside Smart Menus)
Taxonomy Access
Workflow
Rules
Trigger (core)
PHP Filter (core)

Roles

The first thing you'll need to do is create 4 roles:

1.Author
2.Moderator
3.Sports
4.Politics

Content Type

You have to change some settings in your content type, for this example, I have a custom one: Object.

Content Type Settings

Revisioning Settings

Next, set the following options in Revisioning

Revisioning Settings

Workflow

Now start to setup a new Workflow. In this example we'll use the following states as we mentioned before:

  1. in draft
  2. in review
  3. live

Configure Workflow until you have something like this:

Actions and Trigger

You need to publish the node every time a node goes from 'in review' to 'live', to do this, go to admin/build/trigger/workflow, then go to 'Trigger: When content type moves from in review to live” and add:

Publish the most recent pending revision

Rules

Now here is a tricky part. You can actually not use this. By default, once you publish a node, it will have the state 'live', if you edit that node, revisioning will create a new revision, but since Workflows are attached to the node, and not to the revision, you'll probably want the node to remain published but also move it to 'in draft' so the workflow starts again.

You can solve this in two different ways, you can force your users to move the node to the state 'in draft' before they can create a new revision (you'll have to modify permissions and workflows) and start editing, or you can do this automatically.

Doing it automatically means that when a user edits a node that is in the state 'live', automatically the system will create a new revision and move the node (remember workflows works on nodes, not revisions) to the state 'in draft'. From there, the workflow starts all over again.

The reason you can't do this with Trigger, is because Trigger doesn't know in what state is the node, for that, you'll need to use Rules. Rules is very powerful since you can use PHP with it, and you'll need to use it to check the current state of the node and only trigger that rule when this condition is met. If you use actions and triggers, and setup a new Trigger so when content is updated the system moves that node to “in draft” you'll end up with a broken workflow, since every time an author moves the node from 'in draft' to 'in review', or from 'in review' to 'live', Trigger will change the state to 'in draft' no matter what.

Create a new rule, give it a name like “When updating existing content, change Workflow to In-Draft”. Select the Event: “After updating existing content”.

You have to add conditions and actions, (If and Do). Add a condition “PHP: Execute custom PHP code” (If you can't is because you haven't enabled the PHP Filter module yet).

Now in PHP Code enter the following without the <? php tags

return $node->_workflow == 4;

Note: The number 4 means 'Live' in my site. You might need to adjust this number to your needs. You can find out what number is by going to admin/build/workflow and then click 'edit' next to your 'live' state, you'll have a URL like this one: admin/build/workflow/state/1/4 . The last number (4) is the number you have to enter in the PHP code.

Now you need to add a 'Do' or an Action, add “Workflow: Change workflow state of content to new state”. Change the Target state to 'in draft' and remove the selection mark from 'Force transition'. If you do not remove the selection mark, the Rule is just not going to work.

Permissions

You need to have the following permissions. Note: Only the significant parts are shown. Note: in my case I was using 'object' as my content type and I was using features so you'll probably need to go to the 'node module' section of the permissions page. Note: Some of the 'Module grants' permissions might need a review.

Role: author
Role: author
Role: author
Role: author
Role: author

Role: moderator
Role: moderator
Role: moderator
Role: moderator
Role: moderator

Role: politics
This role has no permissions at all. We'll use it with Taxonomy Access

Role: sports
This role has no permissions at all. We'll use it with Taxonomy Access

Taxonomy Access

I have two Vocabularies in my site, “Category” and “Tags”, even though you'll only add permissions to the 'Category” vocabulary you'll also need to add permissions to any other vocabulary that you might have.

One more thing before you open the screenshots, every time you add the 'default' permissions as you'll see in the images, you have to select the 'children' box.

Author and Moderator doesn't need any permissions.

Authenticated Users Role
Anonymous Users Role
Sports Role
Politics Role

Final Note

If you find any error in the screenshots please help us improve this.

Comments

Monzer Emam’s picture

Thanks for great tutorial.

But there is one issue in the described configuration that is ALL contents after the moderator move them to 'live' state a now state automatically created which is 'in draft'.

So in any view all contents will be listed as 'in draft' even if the author aren't planning to change them.

Is there any idea that the draft state only created if the author clicks edit only.

lelizondo’s picture

When I wrote the tutorial that didn't seem like a big issue; but then users started to use it and it is a huge issue that I had to change. Unfortunately I just couldn't do what you're asking, but I didn't try every option, I ended up leaving everything 'live' and if the author wants to edit the node, first he/she needs to change the state from 'live' to 'draft'.

Maybe a hook_nodeapi($op = "update") could work here, I don't know.

Luis

Monzer Emam’s picture

I think best way is if workflow module enforce the user for one of his allowed transitions only.
For ex in your tutorial if author can do "live->in draft" or "live->in review" transitions so if he clicks edit on a content in "live" state then he can only save it in either "in draft" or "in review" state

What you think?

NonProfit’s picture

This tutorial looks wonderful, thanks.

One of the required modules is "Smart Pages" which I am not able to find. Is this a module bundled with another?

Thanks!

-NP

lelizondo’s picture

Yes, it is inside Smart Menus http://drupal.org/project/smart_menus :)

Luis

Jean Gionet’s picture

hi, great tutorial!
I just have 1 problem. When a post/page/story is in either Draft of Review stage, both my authors and moderators can't VIEW the node (to preview). They can both EDIT and change the workflow status. Any workarounds for this? I've checked all my permissions and settings and they all seem to be OK.

Thanks!
-JG

A Day In The Life

amourow’s picture

I did setup everything as the tutorial advised, and every step works great.

This Rule Setting was supposed to be activated, if author update an "live" content.
However, the Rule for change workflow state from "live" to "in draft" on the event "After updating existing content" is applied every time as moderator changing state from "in review" to "live".

The rule seems triggered by "updating" the states, and then check the updated state id which fit the "live".
It means the weight of "trigger" is higher than the "rule", and at the end, the workflow won't stay in "live" state.

I did check every step, but the problem is still the same.
Is there any case similar? or something I missed?

amourow’s picture

I solve the problem.
I change the "IF" syntax of the rule from

return $node->_workflow == 4;

into

return $node_unchanged->_workflow == 4;

This works with Rule 6.x-1.4, I don't know if the problem happens with different version.

giorgio79’s picture

I replaced Workflow with a simple CCK select list, and assigned Rules when the value changes. Also built nice Views around this.

I was also able to control which role sees which values, by adding a php snippet in the Allowed Values CCK php field

  global $user;

  // Check to see if $user has the administrator role, and enable Live state.
  if ($user->uid == 1)
return array(1 => "Draft",2 => "Ready for Quality Check", 3 => "Needs Work",4 => "Live");
else
return array(1 => "Draft",2 => "Ready for Quality Check", 3 => "Needs Work");

arkjoseph’s picture

Thanks for your snippet, works great!. one issue i seem to be having now, is that my views exposed filter now only sees the 2nd set of values offered in the 'else' statement.

any ideas?

kearon’s picture

Hi,
I am trying to implement this in Drupal 7 - I think I've almost got it - despite a few modules not being available in D7 - maybe I haven't we'll see.
I would really appreciate an update of this tutorial for D7.
Also, I'm trying to implement a slightly different scenario:
All registered users can submit content - they submit to different sections.
Section editors can only moderate content submitted to their section.

If anyone is able to guide me in this, I'd be very grateful. Getting myself a bit spun all around with this.
Thanks,

delacosta456’s picture

Hi i am completely confuse.
Revisionning has State
Workflow also has State

Where to se the publish button ?