From 4797222c13e31d49ef389d4cdb2ca30290d341db Mon Sep 17 00:00:00 2001 From: Gerhard Killesreiter Date: Wed, 29 Mar 2006 06:49:25 +0000 Subject: #55520, upload.module does not display previews for when private files are enabled, patch by dopry. --- modules/upload.module | 9 +++++++++ modules/upload/upload.module | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 'modules') diff --git a/modules/upload.module b/modules/upload.module index 000c5ae15..d55afb6b2 100644 --- a/modules/upload.module +++ b/modules/upload.module @@ -79,6 +79,15 @@ function upload_menu($may_cache) { if ($_SESSION['file_previews']) { foreach ($_SESSION['file_previews'] as $fid => $file) { $filename = file_create_filename($file->filename, file_create_path()); + if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) { + // strip file_directory_path() from filepath + // to hide relative paths in url. see file_create_url + if (strpos($filename, file_directory_path()) !== false) { + $filename = trim(substr($filename, strlen(file_directory_path())), '\\/'); + } + $filename = 'system/files/' . $filename; + } + $items[] = array( 'path' => $filename, 'title' => t('file download'), 'callback' => 'upload_download', diff --git a/modules/upload/upload.module b/modules/upload/upload.module index 000c5ae15..d55afb6b2 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -79,6 +79,15 @@ function upload_menu($may_cache) { if ($_SESSION['file_previews']) { foreach ($_SESSION['file_previews'] as $fid => $file) { $filename = file_create_filename($file->filename, file_create_path()); + if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) { + // strip file_directory_path() from filepath + // to hide relative paths in url. see file_create_url + if (strpos($filename, file_directory_path()) !== false) { + $filename = trim(substr($filename, strlen(file_directory_path())), '\\/'); + } + $filename = 'system/files/' . $filename; + } + $items[] = array( 'path' => $filename, 'title' => t('file download'), 'callback' => 'upload_download', -- cgit v1.2.3