diff --git a/lib/documentmanagement/DocumentTransaction.inc b/lib/documentmanagement/DocumentTransaction.inc index 643a264..c684404 100644 --- a/lib/documentmanagement/DocumentTransaction.inc +++ b/lib/documentmanagement/DocumentTransaction.inc @@ -60,7 +60,7 @@ class DocumentTransaction { $this->iDocumentID = $oDocument->getID(); $this->sComment = $sNewComment; $this->sTransactionNS = $sTransactionNS; - $this->sVersion = $oDocument->getMajorVersionNumber() . "." . $oDocument->getMinorVersionNumber(); + $this->sVersion = KTUtil::arrayGet($aOptions, 'version', $oDocument->getMajorVersionNumber() . "." . $oDocument->getMinorVersionNumber()); $oFolder = Folder::get($oDocument->getFolderId()); $this->sFileName = addslashes($oFolder->sFullPath . "/" . $oFolder->getName() . "/" . $oDocument->getName()); diff --git a/lib/storage/ondiskpathstoragemanager.inc.php b/lib/storage/ondiskpathstoragemanager.inc.php index e9619a7..c98a180 100644 --- a/lib/storage/ondiskpathstoragemanager.inc.php +++ b/lib/storage/ondiskpathstoragemanager.inc.php @@ -124,6 +124,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { $oContentVersion = KTDocumentContentVersion::get($iVersionId); $oConfig =& KTConfig::getSingleton(); $sPath = sprintf("%s/%s", $oConfig->get('urls/documentRoot'), $this->getPath($oContentVersion)); + $sVersion = sprintf("%d.%d", $oContentVersion->getMajorVersionNumber(), $oContentVersion->getMinorVersionNumber()); if (file_exists($sPath)) { //set the correct headers header("Content-Type: " . diff --git a/plugins/ktcore/KTDocumentActions.php b/plugins/ktcore/KTDocumentActions.php index bd92476..a308f35 100644 --- a/plugins/ktcore/KTDocumentActions.php +++ b/plugins/ktcore/KTDocumentActions.php @@ -35,14 +35,17 @@ class KTDocumentViewAction extends KTDocumentAction { function do_main() { $oStorage =& KTStorageManagerUtil::getSingleton(); - $oDocumentTransaction = & new DocumentTransaction($this->oDocument, "Document downloaded", 'ktcore.transactions.download'); - $oDocumentTransaction->create(); - $sVersion = KTUtil::arrayGet($_REQUEST, 'version'); - if ($sVersion) { - $oStorage->downloadVersion($this->oDocument, $sVersion); + $aOptions = array(); + $iVersion = KTUtil::arrayGet($_REQUEST, 'version'); + if ($iVersion) { + $oVersion = KTDocumentContentVersion::get($iVersion); + $aOptions['version'] = sprintf("%d.%d", $oVersion->getMajorVersionNumber(), $oVersion->getMinorVersionNumber());; + $oStorage->downloadVersion($this->oDocument, $iVersion); } else { $oStorage->download($this->oDocument); } + $oDocumentTransaction = & new DocumentTransaction($this->oDocument, "Document downloaded", 'ktcore.transactions.download', $aOptions); + $oDocumentTransaction->create(); exit(0); } }