If I want a simple workflow where role_a submits nodes that go to workflow state queue_a and role_b submits nodes that go to queue_b and role_c moves nodes from queue_a or queue_b to approved I am unable to do that because I'll get an error in workflow config of "Please give the author permission to go from (creation) to at least one state!"

My use case is more complicated, but the base of it is that there is no common workflow state that all my roles can go to on creation. Could that error message be thrown instead only if both of these conditions are met:

1. Author has no permission to go from creation to at least one state (as it is now)
2. There is a role which as create_(content_type) permission which does not have permission to go to creation from at least one state.

Stated another way, if all roles which have permission to create these nodes have a destination state from creation there should be no requirement that Author have a destination state.

Comments

cyu’s picture

Status: Active » Needs review
StatusFileSize
new2.39 KB

I wrote a patch for what I have described.

The potential to create a workflow assigned to a content type, set up permissions (giving all relevant roles (creation) -> a state, but not author), and then apply this workflow to a different content type without adjusting permissions for transitions leaves this open to ending up with a content type with a workflow that has a role who cannot transition from creation to any other state though....any thoughts on that?

cyu’s picture

The situation of a workflow being orphaned in a way that leaves it with a role unable to transition from creation to any other state is not unique to this patch, so I don't think that should prevent it from being applicable. For instance, if you set author to go from (creation) -> state_a and then later delete state_a you will still have a valid workflow, but with the potential to have a role creating nodes that can not be transitioned from creation.

Without this patch, the only workaround I can think to accomplish the workflow described originally is to create a throw-away state that author will be given permission to transition to from creation and then add code to a custom module to form_alter that state out of any forms showing transitions. That seems quite ugly, though.

cyu’s picture

StatusFileSize
new2.77 KB

Realized that any roles with administer nodes should also have permission for (creation) -> at least one state. Attached patch covers this.

If this approach is not usable, are there any other ways to achieve the described workflow? Would a patch be considered which offered a workflow setting for expert mode, where this requirement for an author to transition could be bypassed assuming that the site admin enabling this mode knew enough about creating workflows to not end up leaving roles that could create nodes but not move them out of creation state?

bakr’s picture

StatusFileSize
new127.14 KB

I am creating a new simple work-flow with one state, apart from from the above scenario...

things are failing (see screen shot)

I hope your patch will help me sort out that unnecessary warning message, at least I know where i am going in terms of module usage.

bakr’s picture

I have fixed my own problem as such:


  // Make sure 'author' is checked for (creation) -> [something].
  $creation_id = _workflow_creation_state($wid);
   
  $author_has_permission = TRUE;
  
	// if (isset($form_state['values']['transitions'][$creation_id]) && is_array($form_state['values']['transitions'][$creation_id])) {
	//  foreach ($form_state['values']['transitions'][$creation_id] as $to => $roles) {
	//   
	//	  if ($roles['author']) {
	//     
	//	    $author_has_permission = TRUE;
	//       break;
	//      }
	//  }
    //  }
	
  $state_count = db_result(db_query("SELECT COUNT(sid) FROM {workflow_states} WHERE wid = %d", $wid));
  if (empty($author_has_permission) && $state_count > 1) {
    form_set_error('transitions', t('Please give the author permission to go from %creation to at least one state!',
      array('%creation' => '(creation)')));
  }
}

simply, skip the validation

bakr’s picture

Forget about the hack above.

I got workflow module back working normally after clearing all the workflow states that are disabled in the {workflow_states} table..

Hmmm... some cleanup is affecting operation !!!

Bastlynn’s picture

Status: Needs review » Postponed (maintainer needs more info)

Any chance I can get a patch for this in D7?

bakr’s picture

Status: Postponed (maintainer needs more info) » Needs review

Please review solution described in post #6. it worked for me.

johnv’s picture

I've added this to a meta issue:
#2144747: [META] Flexible transitions

colan’s picture

Issue summary: View changes
Parent issue: » #2144747: [META] Flexible transitions
johnv’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev

Moving all remaining D6 issues to D7.

johnv’s picture

Component: Code » Documentation
Status: Needs review » Postponed

In version 7.x-2.3 and higher, you will find a hook_alter that allows you to change (add, remove) the allowed set of state transitions.
Please see workflow.api.php for that.

For now, I propose that solution. If that doesn't work, or if more people are interested having your request built-in, I'll reconsider your patch (wchich will need rework for D7).

I've moved this issue to 'Documentation', since it might be a good case for the docu.

johnv’s picture

Version: 7.x-2.x-dev » 8.x-1.x-dev
johnv’s picture

Title: Required author permission is limiting » Required author permission is limiting (D9)
johnv’s picture

Title: Required author permission is limiting (D9) » Permissions: Required author permission is limiting (D9)

  • johnv committed 1d04a637 on 2.0.x
    Issue #359834 by cyu, bakr, johnv: Permissions: Required author...
johnv’s picture

Title: Permissions: Required author permission is limiting (D9) » Permissions: Required author permission is limiting
Version: 8.x-1.x-dev » 2.1.3
Status: Postponed » Fixed

This issue has been bugging me for years.
I now have decided to change the error message in WorkflowConfigTransitionRoleForm.php
from 'Please give the author permission to go from %creation to at least one state!'
to 'At least one role must have permission to go from %creation to another state.'

The patch also unifies the usasge of 'Author' vs 'author'.

Status: Fixed » Closed (fixed)

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