From 79e2c38d233a72c01677a812cd5ac64def64cfee Mon Sep 17 00:00:00 2001 From: Neil Blakey-Milner Date: Fri, 27 Jan 2006 12:53:16 +0000 Subject: [PATCH] When downloading a particular version of a document, record that version as the version number in the transaction. --- lib/documentmanagement/DocumentTransaction.inc | 2 +- lib/storage/ondiskpathstoragemanager.inc.php | 1 + plugins/ktcore/KTDocumentActions.php | 13 ++++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) 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); } } -- libgit2 0.21.4