You are here

function view_unpublished_node_grants in view_unpublished 7

Same name and namespace in other branches
  1. 8 view_unpublished.module \view_unpublished_node_grants()

Implements hook_node_grants().

File

./view_unpublished.module, line 68
Main functions and hook implementations of the View Unpublished module.

Code

function view_unpublished_node_grants($account, $op) {
  $grants = array();
  if ($op == 'view') {
    if (user_access('view own unpublished content', $account)) {
      $grants['view_unpublished_author'] = array(
        $account->uid,
      );
    }
    if (user_access('view any unpublished content', $account)) {
      $grants['view_unpublished_content'] = array(
        1,
      );
      return $grants;
    }
    foreach (node_permissions_get_configured_types() as $type) {
      if (user_access("view any unpublished {$type} content", $account)) {
        $grants['view_unpublished_' . $type . '_content'] = array(
          1,
        );
      }
    }
  }
  return $grants;
}