From 32d2b2b40fb2c2eac11755fd25397d8727f7fe3d Mon Sep 17 00:00:00 2001 From: Megan Watson Date: Tue, 7 Oct 2008 15:40:13 +0000 Subject: [PATCH] KTS-3682 "Deleting older versions of a document also delete the current content" Fixed. Added a check on the storage path to prevent the current content being deleted. --- lib/documentmanagement/documentutil.inc.php | 9 ++++++++- templates/ktcore/document/metadata_history.smarty | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php index 92690b3..c1d2e8a 100644 --- a/lib/documentmanagement/documentutil.inc.php +++ b/lib/documentmanagement/documentutil.inc.php @@ -1312,10 +1312,17 @@ $sourceDocument->getName(), $oContentVersion = KTDocumentContentVersion::get($iContentId); if (PEAR::isError($oContentVersion) || ($oContentVersion == false)) { - DBUtil::rollback(); return PEAR::raiseError(_kt('Invalid document content version object.')); } + // Check that the document content is not the same as the current content version + $sDocStoragePath = $oDocument->getStoragePath(); + $sVersionStoragePath = $oContentVersion->getStoragePath(); + + if($sDocStoragePath == $sVersionStoragePath){ + return PEAR::raiseError(_kt("Can't delete version: content is the same as the current document content.")); + } + DBUtil::startTransaction(); // now delete the document version diff --git a/templates/ktcore/document/metadata_history.smarty b/templates/ktcore/document/metadata_history.smarty index 1bceca5..502e4ac 100644 --- a/templates/ktcore/document/metadata_history.smarty +++ b/templates/ktcore/document/metadata_history.smarty @@ -69,14 +69,14 @@ {$oVersion->getVersionCreated()} {if $showdelete} - {if ($document->getMetadataVersion() != $oVersion->getMetadataVersion())} + {if ($document->getMetadataVersion() != $oVersion->getMetadataVersion() & $document->getStoragePath() != $oVersion->getStoragePath())} {if ($oVersion->getMetadataStatusID() == VERSION_DELETED)} {i18n}Version deleted{/i18n} {else} {i18n}delete version{/i18n} {/if} {else} -   + — {/if} {/if} -- libgit2 0.21.4