One issue that I've come across is the lack of ability to define permissions at a state level. Namely, it would be nice to control what roles can edit the content at a given state. There is an issue similar to this already:

http://drupal.org/node/1219988

One simple approach that comes to mind would be to add additional permissions to check under workbench moderation. So either before or after the "Moderate all content from..." permissions, we could have "Edit all content in [state]" permissions. My only concern with this approach would be the potential permission sprawl if there are too many states.

I'll play around with this and see if I can get a patch together that demonstrates the concept.

Comments

reujwils’s picture

StatusFileSize
new1.68 KB

Here is a first crack at adding the permissions described above. Let me know if there is anything missing from this.

Thanks!

stevector’s picture

Hi reujwils,

I see the problem you are trying to solve. There a lot of similar use cases that could be solved by add more permissions based on content type, state, etc. However we are trying to avoid making changes that will explode the number of permissions this module generates.

I recommend looking at the work muriqui is doing/discussing here: #1108502: Allow modules to alter the list of possible next states

The Conditional Roles module he is writing might be going after the same use case. http://drupal.org/project/conditional_roles

If you need this functionality immediately for a project, I recommend putting the approach used in your patch into a custom module.

reujwils’s picture

Yeah, that does look like some interesting work he is doing over there.

I am working on this for a project atm, so I thought I'd mention it and see what you all think. Thanks for the input, and I'll just include this as part of the code in my module.

Thanks for the feedback.

stevector’s picture

Status: Active » Closed (works as designed)
Bevan’s picture

StatusFileSize
new1.54 KB

This version of the patch from #1 has the same logic but has style and documentation enhancements. It might be useful for anyone reviewing the patch and wanting to use it while things like conditional roles and access control kit are still maturing.

tregismoreira’s picture

Issue summary: View changes

Patch #5 works sweetly.

The Workbench State Access module seems to try to solve the same problem, but it implements a hook_menu_alter() with a custom access callback, instead of implements hook_node_access() (like this patch) which seems to be more appropriate in this case.

It would be great to have a release with this patch applied.

tregismoreira’s picture

Any news about this patch? It would be great to have it in a release.

stefan.r’s picture

Status: Closed (works as designed) » Needs review

@tregismoreira the maintainer of the module explained in #2 why this is unlikely to go into Workbench Access.

This patch will probably have to be turned into a contrib module, or get accepted into the Workbench State Access module instead.

stefan.r’s picture

Status: Needs review » Closed (works as designed)

The last submitted patch, 1: set-permissions-by-state_1296216.patch, failed testing.

Status: Closed (works as designed) » Needs work

The last submitted patch, 5: 1296216-5_set_permissions_by_state.patch, failed testing.

tregismoreira’s picture

Status: Needs work » Closed (works as designed)

OK, here's the contrib module based on @Bevan's patch: https://www.drupal.org/project/workbench_moderation_state_access.

Mhammad Attar’s picture

I added a sandbox module that add permissions by @content_type in @state in all operations(View|Edit|Delete)
https://www.drupal.org/sandbox/mhammadattar/2789129