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); } }