I'm working on a project that requires different workflow permissions for each content types.

For example, we have these roles "article editor", "page editor", "article approver", "page approver", with the actual internal working of WBM (Workbench Moderation), if we have the transition permission from "Draft to Publish" and give it to a "page approver", he will also be able to publish article, which isn't what we want.

One possible solution would be to add the ability to create multiple workflows to WBM (with corresponding permissions), and link each workflows to a Content Type (see related issue).
But this solution is quite complexe and would require many code changes.

As of now I do not need multiple workflows (for my project) as all the content types have the same workflow.
So another solution would be to simply duplicate all the transition permissions for each content types (which is quite simple).
I worked on this solution and found that changing only 3 lines makes it work (it will probably need more, like configuration to enable/disable it for those who doesn't want it, as it creates a lot more permissions).

But I'm here to open a discussion, to know if one of these solutions could/will be implemented in the project and what do you think about it ? (I will may be post the patch for the seconde solution in the next week).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jmarcou created an issue. See original summary.

jmarcou’s picture

FileSize
0 bytes

Tests will fail, as they need to be updated for this solution.

jmarcou’s picture

FileSize
3.4 KB
scookie’s picture

Our organization DOES need different workflows for different content types. Our solution is to create different sets of states for the various workflows, then only enable the appropriate states for each content type. Using your example above:

Here are the states – State label with machine name in parentheses:
Draft (draft_article)
Draft (draft_page)
Published (published_article)
Published (published_page)

Here are the transitions (machine names are in parentheses):
Publish (publish_article): Move from Draft (draft_article) to Published (published_article)
Publish (publish_page): Move from Draft (draft_page) to Published (published_page)

For content type Page, only Draft (draft_page) and Published (published_page) states are enabled.
For content type Article, only Draft (draft_article) and Published (published_article) states are enabled.

Permissions:
Role: article approver – only has permission for the Publish (publish_article) transition
Role: page approver – only has permission for the Publish (publish_page) transition

jmarcou’s picture

That is a solution, but in our case, we have about 30 content types (all with the same workflow), 5 states and 9 transitions, which would result in more than 150 states and 270 transitions. So by just applying my patch, you can automatically apply all your workflow to all content types (considering that all your content types have the same workflow), instead of having to do it manually.

My patch would probably benefit to have a "checkbox option" to enable or disable the "Per content type" workflow, for those who prefer to define their workflows themselves (if the workflows are different, for example).

naveenvalecha’s picture

Version: 8.x-1.0 » 8.x-1.x-dev

patches are tested against dev branch

fawwad.nirvana’s picture

I am using drupal 8.2.5 with workbench moderation 8.x-1.2
i used #3 but there is no check box for content type or no label in permission tab.

ion.macaria’s picture

For me patch is working, thank you @jmarcou.

ion.macaria’s picture

Priority: Normal » Major
Status: Active » Needs review
ion.macaria’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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