Commit 467f07adf92ad5f15eb3af574e3c517f89dfd907
1 parent
0ad1d2ef
Merged in...
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/STABLE/branches/3.5.4-Release-Branch@9495 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 | 1312 | $oContentVersion = KTDocumentContentVersion::get($iContentId); |
| 1313 | 1313 | |
| 1314 | 1314 | if (PEAR::isError($oContentVersion) || ($oContentVersion == false)) { |
| 1315 | - DBUtil::rollback(); | |
| 1316 | 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 | 1326 | DBUtil::startTransaction(); |
| 1320 | 1327 | |
| 1321 | 1328 | // now delete the document version | ... | ... |
templates/ktcore/document/metadata_history.smarty
| ... | ... | @@ -69,14 +69,14 @@ |
| 69 | 69 | <td class="versiondate">{$oVersion->getVersionCreated()}</td> |
| 70 | 70 | {if $showdelete} |
| 71 | 71 | <td class="deleteversion"> |
| 72 | - {if ($document->getMetadataVersion() != $oVersion->getMetadataVersion())} | |
| 72 | + {if ($document->getMetadataVersion() != $oVersion->getMetadataVersion() & $document->getStoragePath() != $oVersion->getStoragePath())} | |
| 73 | 73 | {if ($oVersion->getMetadataStatusID() == VERSION_DELETED)} |
| 74 | 74 | <strong>{i18n}Version deleted{/i18n}</strong> |
| 75 | 75 | {else} |
| 76 | 76 | <a href="{addQS}action=confirmdeleteVersion&fDocumentId={$document->getId()}&version={$oVersion->getCurrentMetadataVersionId()}{/addQS}">{i18n}delete version{/i18n}</a> |
| 77 | 77 | {/if} |
| 78 | 78 | {else} |
| 79 | - | |
| 79 | + — | |
| 80 | 80 | {/if} |
| 81 | 81 | </td> |
| 82 | 82 | {/if} | ... | ... |