You are here

function trash_flag_node_access in Trash Flag 7

Implements hook_node_access().

Allows users to view trash directly, either via trashbin or view all perm.

File

./trash_flag.module, line 352

Code

function trash_flag_node_access($node, $op, $account) {

  // Assumption is if being directly called, likely a direct node page view.
  if ($op == 'view' && ($flag = flag_load('trash')) && $flag
    ->is_flagged($node->nid)) {
    $access = og_user_access_entity('administer group', 'node', $node, $account);
    if (!is_null($access)) {
      if (og_user_access_entity("view trash bin", 'node', $node, $account)) {
        return NODE_ACCESS_ALLOW;
      }
    }
    return user_access("view trash content", $account) || user_access("view trash bin", $account) ? NODE_ACCESS_ALLOW : NODE_ACCESS_DENY;
  }
}