function private_file_download in Private 6
Same name and namespace in other branches
- 5 private.module \private_file_download()
Implementation of hook_file_download().
File
- ./
private.module, line 207 - A tremendously simple access control module -- it allows users to mark individual nodes as private; users with 'access private content' perms can read these nodes, while others cannot.
Code
function private_file_download($file) {
$file = file_create_path($file);
$result = db_query("SELECT f.* FROM {files} f WHERE filepath = '%s'", $file);
if ($file = db_fetch_object($result)) {
$node = node_load($file->nid);
if ($node->private == 1) {
if (node_access('view', $node) == FALSE) {
return -1;
}
}
}
}