In order to add quick links on nodes to change the state without having to go into edit, I'm calling workflow_execute_transition via links added to the node from a custom module (i.e. menu item /state/nid/sid calls a custom function which in turn calls workflow_execute_transition). It works great, except that all users seem to be given the author permission by the function (so users that are not actually the author of a node, can change that node's state).

The line producing this behavior is around 466:
if (!workflow_transition_allowed($tid, array_merge(array_keys($user->roles), array('author')))) {

I could be understanding this wrong, but it seems that line always adds the role 'author' to the user. Is there a reason for this? I copied/modified code from earlier on in the module to check if the user actually is the author:

$roles = array();
if (($user->uid == $node->uid && $node->uid > 0) || (arg(0) == 'node' && arg(1) == 'add')) { 
  $roles[] = 'author';
  }

and replaced the previously mentioned line with:
if (!workflow_transition_allowed($tid, array_merge(array_keys($user->roles), $roles))) {

This seems to work great, I'm just wondering if there was a reason for always assigning the author role to user permissions in this function.

Thanks!
Brian

Comments

greggles’s picture

Category: support » bug

Can you provide your change as a patch? This seems like a bug to me. http://drupal.org/patch/create

Also, the code you mentioned to provide quick links seems quite useful. Perhaps you could provide that as well (in another issue, maybe) so that others can build on it and create a generalized module from it.

Bastlynn’s picture

Status: Active » Closed (won't fix)

Hi,

With the release of Drupal 7, Drupal 5 is no longer receiving security updates, reviews, or development from many contributed modules. Since 5 is now considered a depreciated version, you really should seriously look into upgrading to Drupal 6 or 7. The newer versions of Drupal work better, have more support, and will be safer (literally! security patches!) for your website. We are currently working on a new release for Workflow to Drupal 7. In light of that, further support for Drupal 5 issues is infeasible at the moment. Please consider upgrading to Drupal 6 or 7 in the near future - you'll be glad you did.

- Bastlynn