Commit 32d2b2b40fb2c2eac11755fd25397d8727f7fe3d
1 parent
d3800552
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. Committed by: Megan Watson Reviewed by: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@9492 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
10 additions
and
3 deletions
lib/documentmanagement/documentutil.inc.php
| @@ -1312,10 +1312,17 @@ $sourceDocument->getName(), | @@ -1312,10 +1312,17 @@ $sourceDocument->getName(), | ||
| 1312 | $oContentVersion = KTDocumentContentVersion::get($iContentId); | 1312 | $oContentVersion = KTDocumentContentVersion::get($iContentId); |
| 1313 | 1313 | ||
| 1314 | if (PEAR::isError($oContentVersion) || ($oContentVersion == false)) { | 1314 | if (PEAR::isError($oContentVersion) || ($oContentVersion == false)) { |
| 1315 | - DBUtil::rollback(); | ||
| 1316 | return PEAR::raiseError(_kt('Invalid document content version object.')); | 1315 | return PEAR::raiseError(_kt('Invalid document content version object.')); |
| 1317 | } | 1316 | } |
| 1318 | 1317 | ||
| 1318 | + // Check that the document content is not the same as the current content version | ||
| 1319 | + $sDocStoragePath = $oDocument->getStoragePath(); | ||
| 1320 | + $sVersionStoragePath = $oContentVersion->getStoragePath(); | ||
| 1321 | + | ||
| 1322 | + if($sDocStoragePath == $sVersionStoragePath){ | ||
| 1323 | + return PEAR::raiseError(_kt("Can't delete version: content is the same as the current document content.")); | ||
| 1324 | + } | ||
| 1325 | + | ||
| 1319 | DBUtil::startTransaction(); | 1326 | DBUtil::startTransaction(); |
| 1320 | 1327 | ||
| 1321 | // now delete the document version | 1328 | // now delete the document version |
templates/ktcore/document/metadata_history.smarty
| @@ -69,14 +69,14 @@ | @@ -69,14 +69,14 @@ | ||
| 69 | <td class="versiondate">{$oVersion->getVersionCreated()}</td> | 69 | <td class="versiondate">{$oVersion->getVersionCreated()}</td> |
| 70 | {if $showdelete} | 70 | {if $showdelete} |
| 71 | <td class="deleteversion"> | 71 | <td class="deleteversion"> |
| 72 | - {if ($document->getMetadataVersion() != $oVersion->getMetadataVersion())} | 72 | + {if ($document->getMetadataVersion() != $oVersion->getMetadataVersion() & $document->getStoragePath() != $oVersion->getStoragePath())} |
| 73 | {if ($oVersion->getMetadataStatusID() == VERSION_DELETED)} | 73 | {if ($oVersion->getMetadataStatusID() == VERSION_DELETED)} |
| 74 | <strong>{i18n}Version deleted{/i18n}</strong> | 74 | <strong>{i18n}Version deleted{/i18n}</strong> |
| 75 | {else} | 75 | {else} |
| 76 | <a href="{addQS}action=confirmdeleteVersion&fDocumentId={$document->getId()}&version={$oVersion->getCurrentMetadataVersionId()}{/addQS}">{i18n}delete version{/i18n}</a> | 76 | <a href="{addQS}action=confirmdeleteVersion&fDocumentId={$document->getId()}&version={$oVersion->getCurrentMetadataVersionId()}{/addQS}">{i18n}delete version{/i18n}</a> |
| 77 | {/if} | 77 | {/if} |
| 78 | {else} | 78 | {else} |
| 79 | - | 79 | + — |
| 80 | {/if} | 80 | {/if} |
| 81 | </td> | 81 | </td> |
| 82 | {/if} | 82 | {/if} |