diff --git workflow.module workflow.module index 34b07d8..354ff32 100644 --- workflow.module +++ workflow.module @@ -107,6 +107,19 @@ function workflow_menu() { return $items; } + /* + * 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,7 +131,7 @@ function workflow_node_tab_access($node = NULL) { 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)); @@ -705,7 +718,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) { diff --git workflow_access.module workflow_access.module index 16d86ab..4d67536 100644 --- workflow_access.module +++ workflow_access.module @@ -32,15 +32,29 @@ function workflow_access_node_access_records($node) { // We have state information about this node, so get permissions for this state. if (is_numeric($sid)) { + $authors = workflow_get_authors($node); $result = db_query('SELECT * 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 + ); + } + } }