Commit dbfc8db30a21a7e5b19e1d9449e0edf2af6f0f03

Authored by michael
1 parent bd2033af

added expunge deleted documents admin pages


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2132 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/expungeDeletedDocumentsBL.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 +
  12 +require_once("expungeDeletedDocumentsUI.inc");
  13 +require_once("$default->fileSystemRoot/presentation/Html.inc");
  14 +
  15 +/**
  16 + * $Id$
  17 + *
  18 + * Business logic for expunging 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 ($fDocumentIDs) {
  33 + // got some documents to expunge
  34 +
  35 + // instantiate document objects
  36 + $aDocuments = array();
  37 + for ($i = 0; $i < count($fDocumentIDs); $i++) {
  38 + $aDocuments[] = & Document::get($fDocumentIDs[$i]);
  39 + }
  40 +
  41 + if ($fConfirm) {
  42 + $aErrorDocuments = array();
  43 + $aSuccessDocuments = array();
  44 + // delete the specified documents
  45 + for ($i=0; $i<count($aDocuments); $i++) {
  46 + if (PhysicalDocumentManager::expunge($aDocuments[$i])) {
  47 + // delete this from the db now
  48 + if ($aDocuments[$i]->delete()) {
  49 + $aSuccessDocuments[] = $aDocuments[$i]->getDisplayPath();
  50 + } else {
  51 + $default->log->error("expungeDeletedDocumentsBL.php couldn't rm docID=" . $aDocuments[$i]->getID() . " from the db");
  52 + $aErrorDocuments[] = $aDocuments[$i]->getDisplayPath();
  53 + }
  54 + } else {
  55 + $default->log->error("expungeDeletedDocumentsBL.php couldn't rm docID=" . $aDocuments[$i]->getID() . " from the filesystem");
  56 + $aErrorDocuments[] = $aDocuments[$i]->getDisplayPath();
  57 + }
  58 + }
  59 + // display results page
  60 + $oContent->setHtml(renderStatusPage($aSuccessDocuments, $aErrorDocuments));
  61 + } else {
  62 + // ask for confirmation
  63 + $oContent->setHtml(renderConfirmDocuments($aDocuments));
  64 + }
  65 + } else {
  66 + // redirect to list deleted documents page
  67 + controllerRedirect("deletedDocuments", "");
  68 + }
  69 +
  70 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  71 + $main->setCentralPayload($oContent);
  72 + $main->setFormAction($_SERVER["PHP_SELF"]);
  73 + $main->render();
  74 +}
  75 +?>
0 76 \ No newline at end of file
... ...
presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/expungeDeletedDocumentsUI.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 + * Gives the user a last chance to bail out before expunging the documents
  17 + */
  18 +function renderConfirmDocuments($aDocuments) {
  19 + global $default;
  20 +
  21 + $sToRender = renderHeading("Expunge Deleted Documents");
  22 + $sToRender .= "<table>";
  23 + $sToRender .= "<tr><td>The documents you have chosen to expunge are listed below.</td></tr>\n";
  24 + $sToRender .= "<tr><td>Click 'Expunge' to confirm deletion, or 'Cancel' to abort.</td></tr>\n";
  25 + $sToRender .= "<tr/><tr/>";
  26 +
  27 + // loop through them
  28 + for ($i = 0; $i < count($aDocuments); $i++) {
  29 + $sToRender .= "\t<tr>\n";
  30 + $sToRender .= "\t\t<td bgcolor=\"" . getColour($i) . "\">\n";
  31 + $sToRender .= "<input type=\"hidden\" name=\"fDocumentIDs[]\" value=\"" . $aDocuments[$i]->getID() . "\"/>\n";
  32 + $sToRender .= $aDocuments[$i]->getDisplayPath(true) . "\n";
  33 + $sToRender .= "\t\t</td>\n";
  34 + $sToRender .= "\t</tr>\n";
  35 + }
  36 + $sToRender .= "<tr/><tr/>";
  37 + $sToRender .= "<input type=\"hidden\" name=\"fConfirm\" value=\"1\">";
  38 + $sToRender .= "<tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/expunge.gif\" border=\"0\"/></a>\n";
  39 + $sToRender .= generateControllerLink("deletedDocuments", "", "<img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></td></tr>");
  40 + $sToRender .= "</table>";
  41 + return $sToRender;
  42 +}
  43 +
  44 +/**
  45 + * Displays the status of expunged documents
  46 + */
  47 +function renderStatusPage($aSuccessDocuments, $aErrorDocuments) {
  48 + global $default;
  49 +
  50 + $sToRender = renderHeading("Expunge Deleted Documents Status");
  51 + $sToRender .= "<table>";
  52 + if (count($aSuccessDocuments) > 0) {
  53 + $sToRender .= "<tr><td>The following documents were successfully expunged:</td></tr>\n";
  54 + $sToRender .= "<tr/><tr/>";
  55 + for ($i=0; $i<count($aSuccessDocuments); $i++) {
  56 + $sToRender .= "<tr><td>" . $aSuccessDocuments[$i] . "</td></tr>\n";
  57 + }
  58 + }
  59 + if (count($aErrorDocuments) > 0) {
  60 + $sToRender .= "<tr><td>There were errors restoring the following documents:</td></tr>\n";
  61 + $sToRender .= "<tr/><tr/>";
  62 + for ($i=0; $i<count($aErrorDocuments); $i++) {
  63 + $sToRender .= "<tr><td>" . $aErrorDocuments[$i] . "</td></tr>\n";
  64 + }
  65 + }
  66 + $sToRender .= "<tr/><tr/>";
  67 + $sToRender .= "<tr><td>" . generateControllerLink("deletedDocuments", "", "<img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\"></td></tr>");
  68 + $sToRender .= "</table>";
  69 + return $sToRender;
  70 +}
  71 +?>
0 72 \ No newline at end of file
... ...