Commit b16d90efee6d1d9d1d403b665b5dbf642444a899
1 parent
5c83ea96
added document restoration request pages
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2084 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
159 additions
and
2 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/archiveSettingsUI.inc
presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/requestDocumentRestoreBL.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/archiving/ArchiveRestorationRequest.inc"); | |
| 6 | +require_once("$default->fileSystemRoot/lib/email/Email.inc"); | |
| 7 | +require_once("$default->fileSystemRoot/lib/users/User.inc"); | |
| 8 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc"); | |
| 9 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | |
| 10 | +require_once("restoreArchivedDocumentUI.inc"); | |
| 11 | +require_once("$default->uiDirectory/documentmanagement/documentUI.inc"); | |
| 12 | +require_once("$default->fileSystemRoot/presentation/Html.inc"); | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * $Id$ | |
| 16 | + * | |
| 17 | + * Business logic for requesting the restoration of an archived document. | |
| 18 | + * | |
| 19 | + * Licensed under the GNU GPL. For full terms see the file DOCS/COPYING. | |
| 20 | + * | |
| 21 | + * @version $Revision$ | |
| 22 | + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | |
| 23 | + * @package presentation.lookAndFeel.knowledgeTree.documentmanagement.archiving | |
| 24 | + */ | |
| 25 | + | |
| 26 | +if (checkSession()) { | |
| 27 | + global $default; | |
| 28 | + | |
| 29 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 30 | + | |
| 31 | + // instantiate my content pattern | |
| 32 | + $oContent = new PatternCustom(); | |
| 33 | + | |
| 34 | + if ($fDocumentID) { | |
| 35 | + // instantiate the document | |
| 36 | + $oDocument = Document::get($fDocumentID); | |
| 37 | + if ($oDocument) { | |
| 38 | + | |
| 39 | + // lookup the unit admin | |
| 40 | + $oUnitAdminUser = getUnitAdminUser(); | |
| 41 | + | |
| 42 | + // create the request | |
| 43 | + $oRestoreRequest = new ArchiveRestorationRequest($fDocumentID, $_SESSION["userID"], $oUnitAdminUser->getID()); | |
| 44 | + if ($oRestoreRequest->create()) { | |
| 45 | + // FIXME: refactor notification | |
| 46 | + // send the email requesting the restoration of an archived document | |
| 47 | + $oUser = User::get($_SESSION["userID"]); | |
| 48 | + | |
| 49 | + $sBody = $oUnitAdmin->getName() . ",<br><br> The user " . $oUser->getName() . " has requested that document "; | |
| 50 | + $sBody .= "'" . generateControllerLink("viewDocument", "fDocumentID=" . $oDocument->getID(), $oDocument->getName()) . "'"; | |
| 51 | + $sBody .= " be restored from the archive."; | |
| 52 | + $oEmail = & new Email(); | |
| 53 | + $oEmail->send($oUnitAdmin->getEmail(), "Archived Document Restoration Request", $sBody); | |
| 54 | + | |
| 55 | + // display a confirmation message | |
| 56 | + $oContent->setHtml(renderRequestSuccessPage($oDocument)); | |
| 57 | + } else { | |
| 58 | + // error creating the request | |
| 59 | + $oContent->setHtml(renderRequestFailurePage($oDocument)); | |
| 60 | + } | |
| 61 | + } else { | |
| 62 | + // error retrieving document | |
| 63 | + $default->log->error("requestDocumentRestoreBL.php there was an error retrieving document id=$fDocumentID from the db"); | |
| 64 | + // TODO: generic error page | |
| 65 | + } | |
| 66 | + | |
| 67 | + } else { | |
| 68 | + // display the select archiving type page | |
| 69 | + $oContent->setHtml(renderAddArchiveSettingsPage(null)); | |
| 70 | + } | |
| 71 | + | |
| 72 | + // build the page | |
| 73 | + $main->setCentralPayload($oContent); | |
| 74 | + $main->setFormAction($_SERVER['PHP_SELF']); | |
| 75 | + $main->setHasRequiredFields(true); | |
| 76 | + $main->render(); | |
| 77 | +} | |
| 78 | +?> | |
| 0 | 79 | \ No newline at end of file | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/restoreArchivedDocumentUI.inc
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * $Id$ | |
| 5 | + * | |
| 6 | + * This page holds all presentation code for requesting the restoration of archived documents | |
| 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.news | |
| 13 | + */ | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * Displays the page that allows an administrator to restore an archived document | |
| 17 | + */ | |
| 18 | +function getRestoreArchivedDocumentPage($oDocument) { | |
| 19 | + global $default; | |
| 20 | + | |
| 21 | + $sToRender = renderHeading("Restore Archived Document") . renderDocumentPath($oDocument) . "\n<br>\n"; | |
| 22 | + | |
| 23 | + $sToRender .= "<table>\n"; | |
| 24 | + $sToRender .= "\t<tr>\n\t\t<td>Please click 'Restore' to restore this archived document.</td>\n\t</tr>\n"; | |
| 25 | + $sToRender .= "\t<tr><td><input type=\"hidden\" name=\"fDocumentIDs[]\" value=\"" . $oDocument->getID() . "\"/></td></tr>\n"; | |
| 26 | + $sToRender .= "\t<tr>\n"; | |
| 27 | + $sToRender .= "\t\t<td><a href=\"" . generateControllerUrl("archivedDocuments", "fConfirm=1&fDocumentIDs[]=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/restore.gif\" border=\"0\" /></a>"; | |
| 28 | + $sToRender .= "<a href=\"$default->rootUrl/control.php?action=browse&fFolderID=" . $oDocument->getFolderID() . "\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\" /></a></td>\n"; | |
| 29 | + $sToRender .= "\t</tr>"; | |
| 30 | + $sToRender .= "</table>\n"; | |
| 31 | + | |
| 32 | + return $sToRender; | |
| 33 | +} | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * Displays the page that allows a user to request the restoration of an archived document | |
| 37 | + */ | |
| 38 | +function getRequestRestoreDocumentPage($oDocument) { | |
| 39 | + global $default; | |
| 40 | + | |
| 41 | + $sToRender = renderHeading("Request Archived Document Restoration") . renderDocumentPath($oDocument) . "\n<br>\n"; | |
| 42 | + | |
| 43 | + $sToRender .= "<table>\n"; | |
| 44 | + $sToRender .= "\t<tr>\n\t\t<td>To request that the document be unarchived, please click the 'Restore' button.</td>\n\t</tr>\n"; | |
| 45 | + $sToRender .= "\t<tr><td><input type=\"hidden\" name=\"fDocumentIDs[]\" value=\"" . $oDocument->getID() . "\"/></td></tr>\n"; | |
| 46 | + $sToRender .= "\t<tr>\n"; | |
| 47 | + $sToRender .= "\t\t<td><a href=\"" . generateControllerUrl("requestDocumentRestore", "&fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/restore.gif\" border=\"0\" /></a>"; | |
| 48 | + $sToRender .= "<a href=\"$default->rootUrl/control.php?action=browse&fFolderID=" . $oDocument->getFolderID() . "\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\" /></a></td>\n"; | |
| 49 | + $sToRender .= "\t</tr>"; | |
| 50 | + $sToRender .= "</table>\n"; | |
| 51 | + | |
| 52 | + return $sToRender; | |
| 53 | +} | |
| 54 | + | |
| 55 | +/** | |
| 56 | + * Displays the page that allows an administrator to restore an archived document | |
| 57 | + */ | |
| 58 | +function renderRequestSuccessPage($oDocument) { | |
| 59 | + global $default; | |
| 60 | + | |
| 61 | + $sToRender = renderHeading("Restore Archived Document"); | |
| 62 | + $sToRender .= "<table>\n"; | |
| 63 | + $sToRender .= "\t<tr><td>Your request has been processed, you will be notified when the document is restored.</td></tr>\n"; | |
| 64 | + $sToRender .= "\t<tr><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=" . $oDocument->getFolderID() . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 65 | + $sToRender .= "</table>\n"; | |
| 66 | + return $sToRender; | |
| 67 | +} | |
| 68 | + | |
| 69 | +/** | |
| 70 | + * Display the error page for archiving request failure | |
| 71 | + */ | |
| 72 | +function renderRequestFailurePage($oDocument, $oUnitAdminUser) { | |
| 73 | + global $default; | |
| 74 | + $sToRender = renderHeading("Restore Archived Document"); | |
| 75 | + $sToRender .= "<table>\n"; | |
| 76 | + $sToRender .= "\t<tr><td>There was an error requesting the restoration of this document from the archive. Please try again later.</td></tr>\n"; | |
| 77 | + $sToRender .= "\t<tr><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=" . $oDocument->getFolderID() . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 78 | + $sToRender .= "</table>\n"; | |
| 79 | + return $sToRender; | |
| 80 | +} | |
| 81 | +?> | |
| 0 | 82 | \ No newline at end of file | ... | ... |