Index: view_unpublished.install =================================================================== RCS file: view_unpublished.install diff -N view_unpublished.install --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ view_unpublished.install 21 Oct 2009 06:52:43 -0000 @@ -0,0 +1,7 @@ + $name) { $perms[] = 'view unpublished ' . $type . ' content'; @@ -29,15 +29,17 @@ function view_unpublished_perm() { * Modifies the path node/nid to use our access callback. */ function view_unpublished_menu_alter(&$items) { + $old_access_callback = $items['node/%node']['access callback']; + $items['node/%node']['access callback'] = '_view_unpublished_node_access'; - $items['node/%node']['access arguments'] = array(1); + $items['node/%node']['access arguments'] = array(1, $old_access_callback); } /** * Returns true if the user has 'view all unpublished content' or if * they have the permission corresponding to the node's content type. */ -function _view_unpublished_node_access($node) { +function _view_unpublished_node_access($node, $old_access_callback) { // Only check permissions on nodes that are unpublished. if ($node->status == 0) { if (user_access('view all unpublished content')) { @@ -47,8 +49,14 @@ function _view_unpublished_node_access($ if (user_access('view unpublished ' . $node->type . ' content')) { return TRUE; } + + if(user_access('view own unpublished content')) { + global $user; + if($node->uid == $user->uid) + return TRUE; + } } // If none of the above conditions were satisfied, then use node_access like normal. - return node_access('view', $node); + return $old_access_callback('view', $node); }