Commit 039f02fe9b225a52f2bb826dd1215701c1bdbdba
1 parent
780f7418
added restore deleted documents admin pages
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2134 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
156 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/restoreDeletedDocumentBL.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +require_once("../../../../../config/dmsDefaults.php"); | ||
| 4 | +require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | ||
| 5 | +require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc"); | ||
| 6 | +require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc"); | ||
| 7 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc"); | ||
| 8 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | ||
| 9 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); | ||
| 10 | +require_once("$default->uiDirectory/documentmanagement/documentUI.inc"); | ||
| 11 | +require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | ||
| 12 | +require_once("restoreDeletedDocumentsUI.inc"); | ||
| 13 | +require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * $Id$ | ||
| 17 | + * | ||
| 18 | + * Business logic for restoring deleted documents. | ||
| 19 | + * | ||
| 20 | + * Licensed under the GNU GPL. For full terms see the file DOCS/COPYING. | ||
| 21 | + * | ||
| 22 | + * @version $Revision$ | ||
| 23 | + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | ||
| 24 | + * @package presentation.lookAndFeel.knowledgeTree.administration.documentmanagement | ||
| 25 | + */ | ||
| 26 | + | ||
| 27 | +if (checkSession()) { | ||
| 28 | + global $default; | ||
| 29 | + | ||
| 30 | + $oContent = new PatternCustom(); | ||
| 31 | + | ||
| 32 | + if ($fDocumentID && $fFolderID) { | ||
| 33 | + if (isset($fForMove)) { | ||
| 34 | + if ($fConfirmed) { | ||
| 35 | + $oDocument = Document::get($fDocumentID); | ||
| 36 | + $oFolder = Folder::get($fFolderID); | ||
| 37 | + if ($oDocument && $oFolder) { | ||
| 38 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 39 | + // restore the document | ||
| 40 | + $oDocument->setStatusID(LIVE); | ||
| 41 | + $oDocument->setFolderID($oFolder->getID()); | ||
| 42 | + | ||
| 43 | + // first try moving the document on the filesystem | ||
| 44 | + if (PhysicalDocumentManager::restore($oDocument)) { | ||
| 45 | + // now update the db | ||
| 46 | + if ($oDocument->update(true)) { | ||
| 47 | + // display confirmation page | ||
| 48 | + $oContent->setHtml(renderStatusPage($oDocument)); | ||
| 49 | + } else { | ||
| 50 | + $default->log->error("restoreDeletedDocumentBL.php couldn't update db for " . arrayToString($oDocument)); | ||
| 51 | + // TODO: display error | ||
| 52 | + $oContent->setHtml(renderErrorPage("The document could not be restored. Please try again later")); | ||
| 53 | + } | ||
| 54 | + } else { | ||
| 55 | + $default->log->error("restoreDeletedDocumentBL.php filesystem restore failed for " . arrayToString($oDocument)); | ||
| 56 | + // TODO: display error | ||
| 57 | + $oContent->setHtml(renderErrorPage("The document could not be restored. Please try again later")); | ||
| 58 | + } | ||
| 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", ""); | ||
| 64 | + } | ||
| 65 | + } else { | ||
| 66 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 67 | + $oContent->setHtml(renderConfirmationPage($fDocumentID, $fFolderID)); | ||
| 68 | + } | ||
| 69 | + } else { | ||
| 70 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 71 | + // display browse page | ||
| 72 | + $oContent->setHtml(renderFolderBrowsePage($fDocumentID, $fFolderID)); | ||
| 73 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID"); | ||
| 74 | + } | ||
| 75 | + } else { | ||
| 76 | + // no document | ||
| 77 | + $default->log->error("restoreDeletedDocumentBL.php no document ID supplied"); | ||
| 78 | + // TODO: redirect to list page with error | ||
| 79 | + controllerRedirect("deletedDocuments", ""); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + $main->setCentralPayload($oContent); | ||
| 83 | + if ($main->getFormAction() == "") { | ||
| 84 | + $main->setFormAction($_SERVER["PHP_SELF"]); | ||
| 85 | + } | ||
| 86 | + $main->render(); | ||
| 87 | +} | ||
| 88 | +?> | ||
| 0 | \ No newline at end of file | 89 | \ No newline at end of file |
presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/restoreDeletedDocumentsUI.inc
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * $Id$ | ||
| 5 | + * | ||
| 6 | + * This page holds all presentation code for expunging documents pages. | ||
| 7 | + * | ||
| 8 | + * Licensed under the GNU GPL. For full terms see the file DOCS/COPYING. | ||
| 9 | + * | ||
| 10 | + * @version $Revision$ | ||
| 11 | + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | ||
| 12 | + * @package presentation.lookAndFeel.knowledgeTree.administration.documentmanagement | ||
| 13 | + */ | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * Displays the status of expunged documents | ||
| 17 | + */ | ||
| 18 | +function renderStatusPage($oDocument) { | ||
| 19 | + global $default; | ||
| 20 | + | ||
| 21 | + $sToRender = renderHeading("Restore Deleted Document Status"); | ||
| 22 | + $sToRender .= "<table>"; | ||
| 23 | + $sToRender .= "<tr><td>The document <strong>" . $oDocument->getName() . "</strong> was successfully restored:</td></tr>\n"; | ||
| 24 | + $sToRender .= "<tr><td>" . generateControllerLink("viewDocument", "fDocumentID=" . $oDocument->getID(), $oDocument->getDisplayPath(true)) . "\n"; | ||
| 25 | + $sToRender .= "<tr/><tr/>"; | ||
| 26 | + | ||
| 27 | + $sToRender .= "<tr><td>" . generateControllerLink("deletedDocuments", "", "<img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\"></td></tr>"); | ||
| 28 | + $sToRender .= "</table>"; | ||
| 29 | + return $sToRender; | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +/** | ||
| 33 | + * Gives the user a last chance to bail out before restoring the document | ||
| 34 | + */ | ||
| 35 | +function renderConfirmationPage($iDocumentID, $iFolderID) { | ||
| 36 | + global $default; | ||
| 37 | + $sToRender = renderHeading("Restore Deleted Document"); | ||
| 38 | + $sToRender .= "<table>\n"; | ||
| 39 | + $sToRender .= "<tr>\n<td>Are you sure you want to restore deleted document <strong>" . Document::getDocumentName($iDocumentID) . "</strong></td></tr>"; | ||
| 40 | + $sToRender .= "<tr><td>to folder <strong>" . Folder::getFolderDisplayPath($iFolderID) . "</strong>?</td></tr>\n"; | ||
| 41 | + $sToRender .= "</tr><tr/><tr/>\n"; | ||
| 42 | + $sToRender .= "<tr><td>" . generateControllerLink("restoreDeletedDocument", "fDocumentID=$iDocumentID&fFolderID=$iFolderID&fForMove=1&fConfirmed=1", "<img src=\"$default->graphicsUrl/widgets/restore.gif\" border=\"0\"/>") . " "; | ||
| 43 | + $sToRender .= generateControllerLink("restoreDeletedDocument", "fDocumentID=$iDocumentID&fFolderID=$iFolderID", "<img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/>") . "</td></tr>\n"; | ||
| 44 | + $sToRender .= "</table>\n"; | ||
| 45 | + return $sToRender; | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +/** | ||
| 49 | + * Displays the folder browse page | ||
| 50 | + */ | ||
| 51 | +function renderFolderBrowsePage($iDocumentID, $iFolderID) { | ||
| 52 | + global $default; | ||
| 53 | + $sToRender = renderHeading("Restore Deleted Document"); | ||
| 54 | + $sToRender .= "<table>\n"; | ||
| 55 | + $sToRender .= "<tr>\n"; | ||
| 56 | + $sToRender .= "<td>" . renderFolderPath($iFolderID, "/control.php?action=restoreDeletedDocument&fDocumentID=$iDocumentID") . "</td>\n"; | ||
| 57 | + $sToRender .= "</tr>\n"; | ||
| 58 | + $sToRender .= "</table>\n"; | ||
| 59 | + $sToRender .= "<table width=\"100%\">\n"; | ||
| 60 | + $sToRender .= "<tr>\n"; | ||
| 61 | + $sToRender .= "<td>" . renderFolderList($iFolderID, "control.php?action=restoreDeletedDocument&fDocumentID=$iDocumentID") . "</td>\n"; | ||
| 62 | + $sToRender .= "</tr>\n"; | ||
| 63 | + $sToRender .= "<tr><td><table><tr><td colspan=\"3\">Select the folder you would like to restore deleted document <strong>" . Document::getDocumentName($iDocumentID) . "</strong> to.</td></tr>"; | ||
| 64 | + $sToRender .= "<tr/><tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/restorehere.gif\" border=\"0\"/> " . generateControllerLink("deletedDocuments", "", "<img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\">") . "</td></tr></table></td>\n"; | ||
| 65 | + $sToRender .= "</table>\n"; | ||
| 66 | + return $sToRender; | ||
| 67 | +} | ||
| 68 | +?> | ||
| 0 | \ No newline at end of file | 69 | \ No newline at end of file |