function node_gallery_file_download in Node Gallery 6.2
Implementation of hook_file_download().
File
- ./
node_gallery.module, line 749 - Node gallery module file
Code
function node_gallery_file_download($filepath) {
$filepath = file_create_path($filepath);
$result = db_query("SELECT f.*, n.nid FROM {files} f INNER JOIN {node_galleries} n ON f.fid = n.fid WHERE filepath = '%s'", $filepath);
while ($file = db_fetch_object($result)) {
if ($filepath !== $file->filepath) {
// Since some database servers sometimes use a case-insensitive
// comparison by default, double check that the filename is an exact
// match.
continue;
}
if (user_access(NODE_GALLERY_PERM_VIEW_GALLERY)) {
return array(
'Content-Type: ' . $file->filemime,
'Content-Length: ' . $file->filesize,
);
}
else {
return -1;
}
}
}