From a5b06ff30b778c6c06b76964a81807a2b7fdb67a Mon Sep 17 00:00:00 2001 From: Michael Joseph Date: Tue, 10 Jun 2003 12:32:00 +0000 Subject: [PATCH] added expunge deleted documents admin pages --- presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/expungeDeletedDocumentsBL.php | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/expungeDeletedDocumentsUI.inc | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 0 deletions(-) create mode 100644 presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/expungeDeletedDocumentsBL.php create mode 100644 presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/expungeDeletedDocumentsUI.inc diff --git a/presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/expungeDeletedDocumentsBL.php b/presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/expungeDeletedDocumentsBL.php new file mode 100644 index 0000000..bc9794b --- /dev/null +++ b/presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/expungeDeletedDocumentsBL.php @@ -0,0 +1,75 @@ +fileSystemRoot/lib/documentmanagement/Document.inc"); +require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc"); +require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc"); +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc"); +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); +require_once("$default->uiDirectory/documentmanagement/documentUI.inc"); + +require_once("expungeDeletedDocumentsUI.inc"); +require_once("$default->fileSystemRoot/presentation/Html.inc"); + +/** + * $Id$ + * + * Business logic for expunging deleted documents. + * + * Licensed under the GNU GPL. For full terms see the file DOCS/COPYING. + * + * @version $Revision$ + * @author Michael Joseph , Jam Warehouse (Pty) Ltd, South Africa + * @package presentation.lookAndFeel.knowledgeTree.administration.documentmanagement + */ + +if (checkSession()) { + global $default; + + $oContent = new PatternCustom(); + + if ($fDocumentIDs) { + // got some documents to expunge + + // instantiate document objects + $aDocuments = array(); + for ($i = 0; $i < count($fDocumentIDs); $i++) { + $aDocuments[] = & Document::get($fDocumentIDs[$i]); + } + + if ($fConfirm) { + $aErrorDocuments = array(); + $aSuccessDocuments = array(); + // delete the specified documents + for ($i=0; $idelete()) { + $aSuccessDocuments[] = $aDocuments[$i]->getDisplayPath(); + } else { + $default->log->error("expungeDeletedDocumentsBL.php couldn't rm docID=" . $aDocuments[$i]->getID() . " from the db"); + $aErrorDocuments[] = $aDocuments[$i]->getDisplayPath(); + } + } else { + $default->log->error("expungeDeletedDocumentsBL.php couldn't rm docID=" . $aDocuments[$i]->getID() . " from the filesystem"); + $aErrorDocuments[] = $aDocuments[$i]->getDisplayPath(); + } + } + // display results page + $oContent->setHtml(renderStatusPage($aSuccessDocuments, $aErrorDocuments)); + } else { + // ask for confirmation + $oContent->setHtml(renderConfirmDocuments($aDocuments)); + } + } else { + // redirect to list deleted documents page + controllerRedirect("deletedDocuments", ""); + } + + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); + $main->setCentralPayload($oContent); + $main->setFormAction($_SERVER["PHP_SELF"]); + $main->render(); +} +?> \ No newline at end of file diff --git a/presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/expungeDeletedDocumentsUI.inc b/presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/expungeDeletedDocumentsUI.inc new file mode 100644 index 0000000..b96c36f --- /dev/null +++ b/presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/expungeDeletedDocumentsUI.inc @@ -0,0 +1,71 @@ +, Jam Warehouse (Pty) Ltd, South Africa + * @package presentation.lookAndFeel.knowledgeTree.administration.documentmanagement + */ + +/** + * Gives the user a last chance to bail out before expunging the documents + */ +function renderConfirmDocuments($aDocuments) { + global $default; + + $sToRender = renderHeading("Expunge Deleted Documents"); + $sToRender .= ""; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= ""; + + // loop through them + for ($i = 0; $i < count($aDocuments); $i++) { + $sToRender .= "\t\n"; + $sToRender .= "\t\t\n"; + $sToRender .= "\t\n"; + } + $sToRender .= ""; + $sToRender .= ""; + $sToRender .= ""); + $sToRender .= "
The documents you have chosen to expunge are listed below.
Click 'Expunge' to confirm deletion, or 'Cancel' to abort.
\n"; + $sToRender .= "getID() . "\"/>\n"; + $sToRender .= $aDocuments[$i]->getDisplayPath(true) . "\n"; + $sToRender .= "\t\t
graphicsUrl/widgets/expunge.gif\" border=\"0\"/>\n"; + $sToRender .= generateControllerLink("deletedDocuments", "", "graphicsUrl/widgets/cancel.gif\" border=\"0\">
"; + return $sToRender; +} + +/** + * Displays the status of expunged documents + */ +function renderStatusPage($aSuccessDocuments, $aErrorDocuments) { + global $default; + + $sToRender = renderHeading("Expunge Deleted Documents Status"); + $sToRender .= ""; + if (count($aSuccessDocuments) > 0) { + $sToRender .= "\n"; + $sToRender .= ""; + for ($i=0; $i\n"; + } + } + if (count($aErrorDocuments) > 0) { + $sToRender .= "\n"; + $sToRender .= ""; + for ($i=0; $i\n"; + } + } + $sToRender .= ""; + $sToRender .= ""); + $sToRender .= "
The following documents were successfully expunged:
There were errors restoring the following documents:
" . generateControllerLink("deletedDocuments", "", "graphicsUrl/widgets/back.gif\" border=\"0\">
"; + return $sToRender; +} +?> \ No newline at end of file -- libgit2 0.21.4