From 7fc02b01a8f1424e90da179ad55d67fe75d90408 Mon Sep 17 00:00:00 2001 From: bshuttle Date: Mon, 11 Sep 2006 11:54:41 +0000 Subject: [PATCH] fix for KTS-1127 *on IE, Windows* --- config/config.ini | 5 +++++ lib/storage/ondiskhashedstoragemanager.inc.php | 13 ++++++++++--- plugins/ktcore/KTDocumentActions.php | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/config/config.ini b/config/config.ini index b004b85..d374493 100644 --- a/config/config.ini +++ b/config/config.ini @@ -96,6 +96,11 @@ automaticRefresh = default ; use a condensed admin ui condensedAdminUI = default +; allow "open" from downloads. Changing this to "true" will prevent (most) +; browsers from giving users the "open" option. +; fakeMimetype = false +fakeMimetype = default + [i18n] ; Default language for the interface defaultLanguage = en diff --git a/lib/storage/ondiskhashedstoragemanager.inc.php b/lib/storage/ondiskhashedstoragemanager.inc.php index 3f7a176..bde1b2d 100644 --- a/lib/storage/ondiskhashedstoragemanager.inc.php +++ b/lib/storage/ondiskhashedstoragemanager.inc.php @@ -129,14 +129,21 @@ class KTOnDiskHashedStorageManager extends KTStorageManager { return; } - function download($oDocument) { + function download($oDocument, $bIsCheckout = false) { //get the path to the document on the server $oConfig =& KTConfig::getSingleton(); $sPath = sprintf("%s/%s", $oConfig->get('urls/documentRoot'), $this->getPath($oDocument)); + $mimetype = KTMime::getMimeTypeName($oDocument->getMimeTypeID()); + + if ($bIsCheckout && $oConfig->get('ui/fakeMimetype' ,false)) { + $mimetype = 'application/x-download'; + // note this does not work for "image" types in some browsers + // go web. + } + if (file_exists($sPath)) { //set the correct headers - header("Content-Type: " . - KTMime::getMimeTypeName($oDocument->getMimeTypeID())); + header("Content-Type: " . $mimetype); header("Content-Length: ". $oDocument->getFileSize()); header("Content-Disposition: attachment; filename=\"" . $oDocument->getFileName() . "\""); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); diff --git a/plugins/ktcore/KTDocumentActions.php b/plugins/ktcore/KTDocumentActions.php index c0c3139..ee9545d 100644 --- a/plugins/ktcore/KTDocumentActions.php +++ b/plugins/ktcore/KTDocumentActions.php @@ -371,7 +371,7 @@ class KTDocumentCheckOutAction extends KTDocumentAction { $oStorage =& KTStorageManagerUtil::getSingleton(); - $oStorage->download($this->oDocument); + $oStorage->download($this->oDocument, true); exit(0); } } -- libgit2 0.21.4