function comment_upload_file_download in Comment Upload 5
Same name and namespace in other branches
- 6 comment_upload.module \comment_upload_file_download()
Enable downloads via private downloads setting.
Users must be able to view the parent node and have the 'view uploaded files' permission. Implementation of hook_file_download.
File
- ./
comment_upload.module, line 331
Code
function comment_upload_file_download($file) {
$file = file_create_path($file);
$result = db_query("SELECT f.* FROM {comment_upload_files} f WHERE filepath = '%s'", $file);
if ($file = db_fetch_object($result)) {
if (user_access('view uploaded files')) {
$node = node_load($file->nid);
if (node_access('view', $node)) {
$name = mime_header_encode($file->filename);
$type = mime_header_encode($file->filemime);
return array(
'Content-Type: ' . $type,
'Content-Length: ' . $file->filesize,
'Expires: 0',
'Pragma: cache',
'Cache-Control: private',
);
}
else {
return -1;
}
}
else {
return -1;
}
}
}