Issue #1169564 by FreekyMage, jhodgdon: Fixed hook_file_download() - sample function body not updated for d7/8.

merge-requests/26/head
webchick 2011-07-03 11:04:28 -07:00
parent 5e4bcf7b87
commit c448440ce8
1 changed files with 7 additions and 8 deletions

View File

@ -2687,22 +2687,21 @@ function hook_file_delete($file) {
* NULL. * NULL.
* *
* @see file_download() * @see file_download()
* @see upload_file_download()
*/ */
function hook_file_download($uri) { function hook_file_download($uri) {
// Check if the file is controlled by the current module. // Check if the file is controlled by the current module.
if (!file_prepare_directory($uri)) { if (!file_prepare_directory($uri)) {
$uri = FALSE; $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)); if (strpos(file_uri_target($uri), variable_get('user_picture_path', 'pictures') . '/picture-') === 0) {
foreach ($result as $file) { if (!user_access('access user profiles')) {
if (!user_access('view uploaded files')) { // Access to the file is denied.
return -1; return -1;
} }
return array( else {
'Content-Type' => $file->filemime, $info = image_get_info($uri);
'Content-Length' => $file->filesize, return array('Content-Type' => $info['mime_type']);
); }
} }
} }