diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2011-07-03 11:04:28 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2011-07-03 11:04:28 -0700 |
commit | c448440ce844666a09fb8c9e287bfe4d293b8fad (patch) | |
tree | 7e88630cac775ca2d7763e5616505c39be5ce93e /modules/system | |
parent | 5e4bcf7b877f8d4ff9ab2ee76fb5ce246ea2f59c (diff) | |
download | brdo-c448440ce844666a09fb8c9e287bfe4d293b8fad.tar.gz brdo-c448440ce844666a09fb8c9e287bfe4d293b8fad.tar.bz2 |
Issue #1169564 by FreekyMage, jhodgdon: Fixed hook_file_download() - sample function body not updated for d7/8.
Diffstat (limited to 'modules/system')
-rw-r--r-- | modules/system/system.api.php | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php index 400538900..8e2e8957e 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -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']); + } } } |