Commit 6d01530154c8794b052b01b06bfc0b21cdbcf26a

Authored by rob
1 parent ae92f104

Added document transaction functionality


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@982 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/deleteDocumentBL.php
... ... @@ -13,6 +13,7 @@ require_once("../../../../config/dmsDefaults.php");
13 13 require_once("$default->owl_fs_root/lib/foldermanagement/Folder.inc");
14 14 require_once("$default->owl_fs_root/lib/users/User.inc");
15 15 require_once("$default->owl_fs_root/lib/documentmanagement/Document.inc");
  16 +require_once("$default->owl_fs_root/lib/documentmanagement/DocumentTransaction.inc");
16 17  
17 18 require_once("$default->owl_fs_root/presentation/Html.inc");
18 19  
... ... @@ -28,14 +29,18 @@ if (checkSession()) {
28 29 $oDocument = Document::get($fDocumentID);
29 30 if (isset($oDocument)) {
30 31 $sDocumentPath = Folder::getFolderPath($oDocument->getFolderID()) . $oDocument->getFileName();
  32 + $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document deleted", DELETE);
  33 + $oDocumentTransaction->create();
31 34 if ($oDocument->delete()) {
32 35 if (unlink($sDocumentPath)) {
33   - //successfully deleted the document from the file system
  36 + //successfully deleted the document from the file system
34 37 redirect("$default->owl_root_url/control.php?action=browse&fFolderID=" . $oDocument->getFolderID());
35 38 } else {
36 39 //could not delete the document from the file system
37 40 //reverse the document deletion
38 41 $oDocument->create();
  42 + //get rid of the document transaction
  43 + $oDocumentTransaction->delete();
39 44 require_once("$default->owl_fs_root/presentation/webpageTemplate.inc");
40 45 $oPatternCustom = & new PatternCustom();
41 46 $oPatternCustom->setHtml("");
... ... @@ -43,6 +48,15 @@ if (checkSession()) {
43 48 $main->setErrorMessage("The document could not be deleted from the file system");
44 49 $main->render();
45 50 }
  51 + } else {
  52 + //could not delete the document in the db
  53 + $oDocumentTransaction->delete();
  54 + require_once("$default->owl_fs_root/presentation/webpageTemplate.inc");
  55 + $oPatternCustom = & new PatternCustom();
  56 + $oPatternCustom->setHtml("");
  57 + $main->setCentralPayload($oPatternCustom);
  58 + $main->setErrorMessage("The document could not be deleted from the database");
  59 + $main->render();
46 60 }
47 61 } else {
48 62 //could not load document object
... ...