Commit 11598d3fbfdffac3df1ab9e62bb87e41c09cc5f9

Authored by rob
1 parent 6c24cc3b

Added functionality for uploading a linked document


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2015 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentBL.php
... ... @@ -18,6 +18,8 @@ if (checkSession()) {
18 18 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
19 19 require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
20 20 require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
  21 + require_once("$default->fileSystemRoot/lib/documentmanagement/DependantDocumentInstance.inc");
  22 + require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentLink.inc");
21 23 require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc");
22 24 require_once("$default->fileSystemRoot/lib/web/WebDocument.inc");
23 25 require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc");
... ... @@ -51,6 +53,17 @@ if (checkSession()) {
51 53 $oDocumentTransaction->create();
52 54 $default->log->info("addDocumentBL.php successfully added document " . $oDocument->getFileName() . " to folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID");
53 55  
  56 + //the document was created/uploaded due to a collaboration step in another
  57 + //document and must be linked to that document
  58 + if (isset($fDependantDocumentID)) {
  59 + $oDependantDocument = DependantDocumentInstance::get($fDependantDocumentID);
  60 + $oDocumentLink = & new DocumentLink($oDependantDocument->getParentDocumentID(), $oDocument->getID());
  61 + if ($oDocumentLink->create()) {
  62 + //no longer a dependant document, but a linked document
  63 + $oDependantDocument->delete();
  64 + }
  65 + }
  66 +
54 67 // fire subscription alerts for the new document
55 68 $count = SubscriptionEngine::fireSubscription($fFolderID, SubscriptionConstants::subscriptionAlertType("AddDocument"),
56 69 SubscriptionConstants::subscriptionType("FolderSubscription"),
... ... @@ -65,9 +78,9 @@ if (checkSession()) {
65 78 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
66 79 $oDocument->delete();
67 80 $oPatternCustom = & new PatternCustom();
68   - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID));
  81 + $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID));
69 82 $main->setCentralPayload($oPatternCustom);
70   - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1");
  83 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1" . (isset($fDependantDocumentID) ? "&fDependantDocumentID=$fDependantDocumentID" : ""));
71 84 $main->setFormEncType("multipart/form-data");
72 85 $main->setErrorMessage("An error occured while storing the document on the file system");
73 86 $default->log->error("addDocumentBL.php Filesystem error attempting to store document " . $oDocument->getFileName() . " in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID");
... ... @@ -77,9 +90,9 @@ if (checkSession()) {
77 90 // couldn't store document on fs
78 91 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
79 92 $oPatternCustom = & new PatternCustom();
80   - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID));
  93 + $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID));
81 94 $main->setCentralPayload($oPatternCustom);
82   - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1");
  95 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1" . (isset($fDependantDocumentID) ? "&fDependantDocumentID=$fDependantDocumentID" : ""));
83 96 $main->setFormEncType("multipart/form-data");
84 97 $main->setErrorMessage("An error occured while storing the document in the database");
85 98 $default->log->error("addDocumentBL.php DB error storing document in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID");
... ... @@ -89,9 +102,9 @@ if (checkSession()) {
89 102 // document already exists in folder
90 103 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
91 104 $oPatternCustom = & new PatternCustom();
92   - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID));
  105 + $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID));
93 106 $main->setCentralPayload($oPatternCustom);
94   - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1");
  107 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1" . (isset($fDependantDocumentID) ? "&fDependantDocumentID=$fDependantDocumentID" : ""));
95 108 $main->setFormEncType("multipart/form-data");
96 109 $main->setErrorMessage("A document with this file name already exists in this folder");
97 110 $default->log->error("addDocumentBL.php Document exists with name " . $oDocument->getFileName() . " in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID");
... ... @@ -100,9 +113,9 @@ if (checkSession()) {
100 113 } else {
101 114 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
102 115 $oPatternCustom = & new PatternCustom();
103   - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID));
  116 + $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID));
104 117 $main->setCentralPayload($oPatternCustom);
105   - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1");
  118 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1" . (isset($fDependantDocumentID) ? "&fDependantDocumentID=$fDependantDocumentID" : ""));
106 119 $main->setFormEncType("multipart/form-data");
107 120 $main->setErrorMessage("Please select a document by first clicking on 'Browse'. Then click 'Add'");
108 121 $main->render();
... ... @@ -111,7 +124,7 @@ if (checkSession()) {
111 124 // the folder doesn't have a default document type
112 125 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
113 126 $oPatternCustom = & new PatternCustom();
114   - $oPatternCustom->setHtml(getBrowsePage($fFolderID));
  127 + $oPatternCustom->setHtml(getBrowsePage($fFolderID, $fDependantDocumentID));
115 128 $main->setCentralPayload($oPatternCustom);
116 129 $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1");
117 130 $main->setFormEncType("multipart/form-data");
... ... @@ -120,12 +133,12 @@ if (checkSession()) {
120 133 }
121 134  
122 135 } else {
123   - //we're still just browsing
  136 + //we're still just browsing
124 137 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
125 138 $oPatternCustom = & new PatternCustom();
126   - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID));
  139 + $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID));
127 140 $main->setCentralPayload($oPatternCustom);
128   - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1");
  141 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1" . (isset($fDependantDocumentID) ? "&fDependantDocumentID=$fDependantDocumentID" : ""));
129 142 $main->setFormEncType("multipart/form-data");
130 143 $main->render();
131 144 }
... ...
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc
... ... @@ -28,7 +28,7 @@ function getDocumentListForFolder($fFolderID) {
28 28 }
29 29  
30 30  
31   -function getBrowsePage($fFolderID) {
  31 +function getBrowsePage($fFolderID, $iDependantDocumentID) {
32 32 $sToRender = "<table border=\"0\">\n";
33 33 $sToRender .= "<tr>\n";
34 34 $sToRender .= "\t<td>" . renderFolderPath($fFolderID, "/control.php?action=addDocument") . "</td>\n";
... ... @@ -36,7 +36,7 @@ function getBrowsePage($fFolderID) {
36 36 $sToRender .= "</table>\n";
37 37 $sToRender .= "<table border=\"0\">\n";
38 38 $sToRender .= "<tr>\n";
39   - $sToRender .= "\t<td>" . renderFolderList($fFolderID, "/control.php?action=addDocument") . "<td>\n";
  39 + $sToRender .= "\t<td>" . renderFolderList($fFolderID, "/control.php?action=addDocument" .(isset($fDependantDocumentID) ? "&fDependantDocumentID=$iDependantDocumentID" : "")) . "<td>\n";
40 40 $sToRender .= "</tr>\n";
41 41 $sToRender .= "<tr>\n";
42 42 if (Permission::userHasFolderReadPermission($fFolderID)) {
... ... @@ -48,7 +48,7 @@ function getBrowsePage($fFolderID) {
48 48 }
49 49  
50 50  
51   -function getBrowseAddPage($fFolderID) {
  51 +function getBrowseAddPage($fFolderID, $iDependantDocumentID = null) {
52 52 global $default;
53 53  
54 54 $sToRender = "<table border=\"0\" width=\"600\">\n";
... ... @@ -67,7 +67,7 @@ function getBrowseAddPage($fFolderID) {
67 67 $sToRender .= "</table>\n";
68 68 $sToRender .= "<table border=\"0\" width=\"100%\">\n";
69 69 $sToRender .= "<tr>\n";
70   - $sToRender .= "\t<td>" . renderFolderList($fFolderID, "/control.php?action=addDocument") . "<td>\n";
  70 + $sToRender .= "\t<td>" . renderFolderList($fFolderID, "/control.php?action=addDocument" . (isset($iDependantDocumentID) ? "&fDependantDocumentID=$iDependantDocumentID" : "")) . "<td>\n";
71 71 $sToRender .= "</tr>\n";
72 72 $sToRender .= "<tr>\n";
73 73 $sToRender .= "<td>" . getDocumentListForFolder($fFolderID) . "</td>\n";
... ...