Skip to content
Snippets Groups Projects
Commit c448440c authored by Angie Byron's avatar Angie Byron
Browse files

Issue #1169564 by FreekyMage, jhodgdon: Fixed hook_file_download() - sample...

Issue #1169564 by FreekyMage, jhodgdon: Fixed hook_file_download() - sample function body not updated for d7/8.
parent 5e4bcf7b
No related branches found
No related tags found
No related merge requests found
......@@ -2687,22 +2687,21 @@ function hook_file_delete($file) {
* NULL.
*
* @see file_download()
* @see upload_file_download()
*/
function hook_file_download($uri) {
// Check if the file is controlled by the current module.
if (!file_prepare_directory($uri)) {
$uri = FALSE;
}
$result = db_query("SELECT f.* FROM {file_managed} f INNER JOIN {upload} u ON f.fid = u.fid WHERE uri = :uri", array('uri' => $uri));
foreach ($result as $file) {
if (!user_access('view uploaded files')) {
if (strpos(file_uri_target($uri), variable_get('user_picture_path', 'pictures') . '/picture-') === 0) {
if (!user_access('access user profiles')) {
// Access to the file is denied.
return -1;
}
return array(
'Content-Type' => $file->filemime,
'Content-Length' => $file->filesize,
);
else {
$info = image_get_info($uri);
return array('Content-Type' => $info['mime_type']);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment