You are here

function protected_node_file_download in Protected Node 5

Same name and namespace in other branches
  1. 6 protected_node.module \protected_node_file_download()
  2. 7 protected_node.module \protected_node_file_download()
  3. 1.0.x protected_node.module \protected_node_file_download()

Implementation of hook_file_download(). @link http://api.drupal.org/api/function/hook_file_download/5

File

./protected_node.module, line 227

Code

function protected_node_file_download($file) {
  global $user;
  $db_file = db_result(db_query('SELECT n.nid FROM {files} f, {protected_nodes} pn, {node} n WHERE pn.nid = f.nid AND f.nid = n.nid AND f.filename = \'%s\'', $file));
  if (db_error() || $db_file === FALSE || $user->uid == $db_file || $_SESSION['_protected_node']['passwords'][$db_file] || user_access('bypass password protection')) {
    return array();
  }
  else {
    return -1;
  }
}