Index: workflow.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/workflow/workflow.module,v retrieving revision 1.83.2.13 diff -u -p -r1.83.2.13 workflow.module --- workflow.module 3 Mar 2010 18:17:02 -0000 1.83.2.13 +++ workflow.module 6 Jan 2011 20:13:06 -0000 + /* + * Determine authors of a given node. + */ +function workflow_get_authors($node) { + $authors = !empty($node->uid) ? array($node->uid => $node->uid) : array(); + drupal_alter('workflow_authors', $authors, $node); + + if (is_array($authors)) { + return $authors; + } + else { + return array(); + } +} /** * Menu access control callback. Determine access to Workflow tab. */ @@ -118,10 +132,10 @@ function workflow_node_tab_access($node return FALSE; } $roles = array_keys($user->roles); - if ($node->uid == $user->uid) { + if (in_array($user->uid, workflow_get_authors($node))) { $roles = array_merge(array('author'), $roles); } - $workflow = db_fetch_object(db_query("SELECT * FROM {workflows} WHERE wid = %d", $wid)); + $workflow = db_fetch_object(db_query("SELECT tab_roles FROM {workflows} WHERE wid = %d", $wid)); $allowed_roles = $workflow->tab_roles ? explode(',', $workflow->tab_roles) : array(); if (user_access('administer nodes') || array_intersect($roles, $allowed_roles)) { @@ -705,7 +719,7 @@ function workflow_field_choices($node) { $current_sid = workflow_node_current_state($node); // If user is node author or this is a new page, give the authorship role. - if (($user->uid == $node->uid && $node->uid > 0) || (arg(0) == 'node' && arg(1) == 'add')) { + if ((in_array($user->uid, workflow_get_authors($node))) || (arg(0) == 'node' && arg(1) == 'add')) { $roles += array('author' => 'author'); } if ($user->uid == 1) { Index: workflow_access.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/workflow/workflow_access.module,v retrieving revision 1.6 diff -u -p -r1.6 workflow_access.module --- workflow_access.module 18 Aug 2008 03:04:13 -0000 1.6 +++ workflow_access.module 6 Jan 2011 20:13:06 -0000 @@ -26,19 +26,34 @@ function workflow_access_node_grants($ac */ function workflow_access_node_access_records($node) { $grants = array(); - $sid = db_result(db_query("SELECT sid FROM {workflow_node} WHERE nid = %d", $node->nid)); + + $sid = workflow_node_current_state($node); // We have state information about this node, so get permissions for this state. if (is_numeric($sid)) { - $result = db_query('SELECT * FROM {workflow_access} WHERE sid = %d', $sid); + $authors = workflow_get_authors($node); + $result = db_query('SELECT rid, grant_view, grant_update, grant_delete FROM {workflow_access} WHERE sid = %d', $sid); while ($grant = db_fetch_object($result)) { - $grants[] = array( - 'realm' => ($grant->rid == -1) ? 'workflow_access_owner' : 'workflow_access', - 'gid' => ($grant->rid == -1) ? $node->uid : $grant->rid, - 'grant_view' => $grant->grant_view, - 'grant_update' => $grant->grant_update, - 'grant_delete' => $grant->grant_delete - ); + if ($grant->rid == -1) { + foreach($authors as $uid) { + $grants[] = array( + 'realm' => 'workflow_access_owner', + 'gid' => $uid, + 'grant_view' => $grant->grant_view, + 'grant_update' => $grant->grant_update, + 'grant_delete' => $grant->grant_delete + ); + } + } + else { + $grants[] = array( + 'realm' => 'workflow_access', + 'gid' => $grant->rid, + 'grant_view' => $grant->grant_view, + 'grant_update' => $grant->grant_update, + 'grant_delete' => $grant->grant_delete + ); + } } }