Commit f84412e4e67f9a8a9afd4f5c08e3a772e586a784

Authored by michael
1 parent a01303c2

(#2794) added check- does a file with the same name exist in the restore to folder?


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2455 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/restoreDeletedDocumentBL.php
@@ -31,10 +31,10 @@ if (checkSession()) { @@ -31,10 +31,10 @@ if (checkSession()) {
31 31
32 if ($fDocumentID && $fFolderID) { 32 if ($fDocumentID && $fFolderID) {
33 if (isset($fForMove)) { 33 if (isset($fForMove)) {
34 - if ($fConfirmed) {  
35 - $oDocument = Document::get($fDocumentID);  
36 - $oFolder = Folder::get($fFolderID);  
37 - if ($oDocument && $oFolder) { 34 + $oDocument = Document::get($fDocumentID);
  35 + $oFolder = Folder::get($fFolderID);
  36 + if ($oDocument && $oFolder) {
  37 + if ($fConfirmed) {
38 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 38 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
39 // restore the document 39 // restore the document
40 $oDocument->setStatusID(LIVE); 40 $oDocument->setStatusID(LIVE);
@@ -57,14 +57,19 @@ if (checkSession()) { @@ -57,14 +57,19 @@ if (checkSession()) {
57 $oContent->setHtml(renderErrorPage("The document could not be restored. Please try again later")); 57 $oContent->setHtml(renderErrorPage("The document could not be restored. Please try again later"));
58 } 58 }
59 } else { 59 } else {
60 - // no document  
61 - $default->log->error("restoreDeletedDocumentBL.php documentID=$fDocumentID folderID=$fFolderID instantiation failed");  
62 - // TODO: redirect to list page with error  
63 - controllerRedirect("deletedDocuments", ""); 60 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  61 + if (!Document::documentExists($oDocument->getFileName(), $fFolderID)) {
  62 + $oContent->setHtml(renderConfirmationPage($fDocumentID, $fFolderID));
  63 + } else {
  64 + // there is already a document with that filename here
  65 + $oContent->setHtml(statusPage("Restore Deleted Document", "", "A document with this file name (" . $oDocument->getFileName() . ") already exists in that folder.", "restoreDeletedDocument", "fDocumentID=$fDocumentID&fFolderID=$fFolderID"));
  66 + }
64 } 67 }
65 } else { 68 } else {
66 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
67 - $oContent->setHtml(renderConfirmationPage($fDocumentID, $fFolderID)); 69 + // no document
  70 + $default->log->error("restoreDeletedDocumentBL.php documentID=$fDocumentID folderID=$fFolderID instantiation failed");
  71 + // TODO: redirect to list page with error
  72 + controllerRedirect("deletedDocuments", "");
68 } 73 }
69 } else { 74 } else {
70 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 75 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");