Commit 540994aea6ff584861bc1637dd1399b3dd8ae834

Authored by michael
1 parent 2ac2253b

add code to save old versions


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1545 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/checkInDocumentBL.php
@@ -60,15 +60,12 @@ if (checkSession()) { @@ -60,15 +60,12 @@ if (checkSession()) {
60 // make sure the user actually selected a file first 60 // make sure the user actually selected a file first
61 if (strlen($_FILES['fFile']['name']) > 0) { 61 if (strlen($_FILES['fFile']['name']) > 0) {
62 62
63 - // backup the original document  
64 - $sBackupPath = $oDocument->getPath() . ".bk"; 63 + // save the original document
  64 + $sBackupPath = $oDocument->getPath() . "-" . $oDocument->getMajorVersionNumber() . "." . $oDocument->getMinorVersionNumber();
65 copy($oDocument->getPath(), $sBackupPath); 65 copy($oDocument->getPath(), $sBackupPath);
66 66
67 // update the document with the uploaded one 67 // update the document with the uploaded one
68 if (PhysicalDocumentManager::uploadPhysicalDocument($oDocument, $fFolderID, "", $_FILES['fFile']['tmp_name'])) { 68 if (PhysicalDocumentManager::uploadPhysicalDocument($oDocument, $fFolderID, "", $_FILES['fFile']['tmp_name'])) {
69 - // remove the backup  
70 - unlink($sBackupPath);  
71 -  
72 // now update the database 69 // now update the database
73 // overwrite size 70 // overwrite size
74 $oDocument->setFileSize($_FILES['fFile']['size']); 71 $oDocument->setFileSize($_FILES['fFile']['size']);
@@ -112,6 +109,8 @@ if (checkSession()) { @@ -112,6 +109,8 @@ if (checkSession()) {
112 } else { 109 } else {
113 // reinstate the backup 110 // reinstate the backup
114 copy($sBackupPath, $oDocument->getPath()); 111 copy($sBackupPath, $oDocument->getPath());
  112 + // remove the backup
  113 + unlink($sBackupPath);
115 $oPatternCustom->setHtml(renderErrorPage("An error occurred while storing the new file on the filesystem")); 114 $oPatternCustom->setHtml(renderErrorPage("An error occurred while storing the new file on the filesystem"));
116 } 115 }
117 } else { 116 } else {