summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-03-10 19:02:06 +0000
committerDries Buytaert <dries@buytaert.net>2006-03-10 19:02:06 +0000
commit28c0c6197a7004256673b8894abe050d404691c2 (patch)
treebf11121a8c713f3befbe775ef3917d184185da61 /includes
parentf5fff25e6fdfccf7eb9ff1e1d2b4500b532546ff (diff)
downloadbrdo-28c0c6197a7004256673b8894abe050d404691c2.tar.gz
brdo-28c0c6197a7004256673b8894abe050d404691c2.tar.bz2
- Patch #52092 by wtanaka, dopry and moshe: fixed regression with hook_file_download.
Diffstat (limited to 'includes')
-rw-r--r--includes/file.inc31
1 files changed, 16 insertions, 15 deletions
diff --git a/includes/file.inc b/includes/file.inc
index 15d5b376f..60d176892 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -565,27 +565,28 @@ function file_transfer($source, $headers) {
/**
* Call modules that implement hook_file_download() to find out if a file is
- * accessible for a given user. If a module returns an array of headers, the
- * download will start. If a module denies it, drupal_access_denied() will be
- * called. If no module responds then drupal_not_found() will be called.
+ * accessible and what headers it should be transferred with. If a module
+ * returns -1 drupal_access_denied() will be returned. If one or more modules
+ * returned headers the download will start with the returned headers. If no
+ * modules respond drupal_not_found() will be returned.
*/
+
function file_download() {
- $file = $_GET['file'];
- if (file_exists(file_create_path($file))) {
- $list = module_list();
- foreach ($list as $module) {
- $headers = module_invoke($module, 'file_download', $file);
- if (is_array($headers)) {
- file_transfer($file, $headers);
- }
- elseif ($headers == -1) {
- drupal_access_denied();
- }
+ $filepath = $_GET['file'];
+
+ if (file_exists(file_create_path($filepath))) {
+ $headers = module_invoke_all('file_download', $filepath);
+ if (in_array(-1, $headers)) {
+ return drupal_access_denied();
+ }
+ if (count($headers)) {
+ file_transfer($filepath, $headers);
}
}
- drupal_not_found();
+ return drupal_not_found();
}
+
/**
* Finds all files that match a given mask in a given
* directory.