You are here

function _view_unpublished_node_access in view_unpublished 6

Returns true if the user has 'view all unpublished content' or if they have the permission corresponding to the node's content type.

1 string reference to '_view_unpublished_node_access'
view_unpublished_menu_alter in ./view_unpublished.module
Implementation of hook_menu_alter().

File

./view_unpublished.module, line 41
Allow users to view all unpublished nodes, or unpublished nodes of a specific type.

Code

function _view_unpublished_node_access($node, $old_access_callback, $old_access_arguments) {

  // Only check permissions on nodes that are unpublished.
  if ($node->status == 0) {
    if (user_access('view all unpublished content')) {
      return TRUE;
    }
    if (user_access('view unpublished ' . $node->type . ' content')) {
      return TRUE;
    }
  }

  // If none of the above conditions were satisfied, then use the original callback.
  // Find where the node object should be
  foreach ($old_access_arguments as $k => $v) {
    if ($v == 1) {
      $old_access_arguments[$k] = $node;
    }
  }
  return call_user_func_array($old_access_callback, $old_access_arguments);
}