Commit 4d8da59b1d4f837f0948a60b7f3873ab1d973c34
1 parent
ad940210
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
Showing
2 changed files
with
29 additions
and
16 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentBL.php
| @@ -18,6 +18,8 @@ if (checkSession()) { | @@ -18,6 +18,8 @@ if (checkSession()) { | ||
| 18 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | 18 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); |
| 19 | require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | 19 | require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); |
| 20 | require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | 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 | require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc"); | 23 | require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc"); |
| 22 | require_once("$default->fileSystemRoot/lib/web/WebDocument.inc"); | 24 | require_once("$default->fileSystemRoot/lib/web/WebDocument.inc"); |
| 23 | require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc"); | 25 | require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc"); |
| @@ -51,6 +53,17 @@ if (checkSession()) { | @@ -51,6 +53,17 @@ if (checkSession()) { | ||
| 51 | $oDocumentTransaction->create(); | 53 | $oDocumentTransaction->create(); |
| 52 | $default->log->info("addDocumentBL.php successfully added document " . $oDocument->getFileName() . " to folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID"); | 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 | // fire subscription alerts for the new document | 67 | // fire subscription alerts for the new document |
| 55 | $count = SubscriptionEngine::fireSubscription($fFolderID, SubscriptionConstants::subscriptionAlertType("AddDocument"), | 68 | $count = SubscriptionEngine::fireSubscription($fFolderID, SubscriptionConstants::subscriptionAlertType("AddDocument"), |
| 56 | SubscriptionConstants::subscriptionType("FolderSubscription"), | 69 | SubscriptionConstants::subscriptionType("FolderSubscription"), |
| @@ -65,9 +78,9 @@ if (checkSession()) { | @@ -65,9 +78,9 @@ if (checkSession()) { | ||
| 65 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 78 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 66 | $oDocument->delete(); | 79 | $oDocument->delete(); |
| 67 | $oPatternCustom = & new PatternCustom(); | 80 | $oPatternCustom = & new PatternCustom(); |
| 68 | - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID)); | 81 | + $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID)); |
| 69 | $main->setCentralPayload($oPatternCustom); | 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 | $main->setFormEncType("multipart/form-data"); | 84 | $main->setFormEncType("multipart/form-data"); |
| 72 | $main->setErrorMessage("An error occured while storing the document on the file system"); | 85 | $main->setErrorMessage("An error occured while storing the document on the file system"); |
| 73 | $default->log->error("addDocumentBL.php Filesystem error attempting to store document " . $oDocument->getFileName() . " in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID"); | 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,9 +90,9 @@ if (checkSession()) { | ||
| 77 | // couldn't store document on fs | 90 | // couldn't store document on fs |
| 78 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 91 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 79 | $oPatternCustom = & new PatternCustom(); | 92 | $oPatternCustom = & new PatternCustom(); |
| 80 | - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID)); | 93 | + $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID)); |
| 81 | $main->setCentralPayload($oPatternCustom); | 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 | $main->setFormEncType("multipart/form-data"); | 96 | $main->setFormEncType("multipart/form-data"); |
| 84 | $main->setErrorMessage("An error occured while storing the document in the database"); | 97 | $main->setErrorMessage("An error occured while storing the document in the database"); |
| 85 | $default->log->error("addDocumentBL.php DB error storing document in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID"); | 98 | $default->log->error("addDocumentBL.php DB error storing document in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID"); |
| @@ -89,9 +102,9 @@ if (checkSession()) { | @@ -89,9 +102,9 @@ if (checkSession()) { | ||
| 89 | // document already exists in folder | 102 | // document already exists in folder |
| 90 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 103 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 91 | $oPatternCustom = & new PatternCustom(); | 104 | $oPatternCustom = & new PatternCustom(); |
| 92 | - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID)); | 105 | + $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID)); |
| 93 | $main->setCentralPayload($oPatternCustom); | 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 | $main->setFormEncType("multipart/form-data"); | 108 | $main->setFormEncType("multipart/form-data"); |
| 96 | $main->setErrorMessage("A document with this file name already exists in this folder"); | 109 | $main->setErrorMessage("A document with this file name already exists in this folder"); |
| 97 | $default->log->error("addDocumentBL.php Document exists with name " . $oDocument->getFileName() . " in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID"); | 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,9 +113,9 @@ if (checkSession()) { | ||
| 100 | } else { | 113 | } else { |
| 101 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 114 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 102 | $oPatternCustom = & new PatternCustom(); | 115 | $oPatternCustom = & new PatternCustom(); |
| 103 | - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID)); | 116 | + $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID)); |
| 104 | $main->setCentralPayload($oPatternCustom); | 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 | $main->setFormEncType("multipart/form-data"); | 119 | $main->setFormEncType("multipart/form-data"); |
| 107 | $main->setErrorMessage("Please select a document by first clicking on 'Browse'. Then click 'Add'"); | 120 | $main->setErrorMessage("Please select a document by first clicking on 'Browse'. Then click 'Add'"); |
| 108 | $main->render(); | 121 | $main->render(); |
| @@ -111,7 +124,7 @@ if (checkSession()) { | @@ -111,7 +124,7 @@ if (checkSession()) { | ||
| 111 | // the folder doesn't have a default document type | 124 | // the folder doesn't have a default document type |
| 112 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 125 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 113 | $oPatternCustom = & new PatternCustom(); | 126 | $oPatternCustom = & new PatternCustom(); |
| 114 | - $oPatternCustom->setHtml(getBrowsePage($fFolderID)); | 127 | + $oPatternCustom->setHtml(getBrowsePage($fFolderID, $fDependantDocumentID)); |
| 115 | $main->setCentralPayload($oPatternCustom); | 128 | $main->setCentralPayload($oPatternCustom); |
| 116 | $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1"); | 129 | $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1"); |
| 117 | $main->setFormEncType("multipart/form-data"); | 130 | $main->setFormEncType("multipart/form-data"); |
| @@ -120,12 +133,12 @@ if (checkSession()) { | @@ -120,12 +133,12 @@ if (checkSession()) { | ||
| 120 | } | 133 | } |
| 121 | 134 | ||
| 122 | } else { | 135 | } else { |
| 123 | - //we're still just browsing | 136 | + //we're still just browsing |
| 124 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 137 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 125 | $oPatternCustom = & new PatternCustom(); | 138 | $oPatternCustom = & new PatternCustom(); |
| 126 | - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID)); | 139 | + $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID)); |
| 127 | $main->setCentralPayload($oPatternCustom); | 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 | $main->setFormEncType("multipart/form-data"); | 142 | $main->setFormEncType("multipart/form-data"); |
| 130 | $main->render(); | 143 | $main->render(); |
| 131 | } | 144 | } |
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc
| @@ -28,7 +28,7 @@ function getDocumentListForFolder($fFolderID) { | @@ -28,7 +28,7 @@ function getDocumentListForFolder($fFolderID) { | ||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | -function getBrowsePage($fFolderID) { | 31 | +function getBrowsePage($fFolderID, $iDependantDocumentID) { |
| 32 | $sToRender = "<table border=\"0\">\n"; | 32 | $sToRender = "<table border=\"0\">\n"; |
| 33 | $sToRender .= "<tr>\n"; | 33 | $sToRender .= "<tr>\n"; |
| 34 | $sToRender .= "\t<td>" . renderFolderPath($fFolderID, "/control.php?action=addDocument") . "</td>\n"; | 34 | $sToRender .= "\t<td>" . renderFolderPath($fFolderID, "/control.php?action=addDocument") . "</td>\n"; |
| @@ -36,7 +36,7 @@ function getBrowsePage($fFolderID) { | @@ -36,7 +36,7 @@ function getBrowsePage($fFolderID) { | ||
| 36 | $sToRender .= "</table>\n"; | 36 | $sToRender .= "</table>\n"; |
| 37 | $sToRender .= "<table border=\"0\">\n"; | 37 | $sToRender .= "<table border=\"0\">\n"; |
| 38 | $sToRender .= "<tr>\n"; | 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 | $sToRender .= "</tr>\n"; | 40 | $sToRender .= "</tr>\n"; |
| 41 | $sToRender .= "<tr>\n"; | 41 | $sToRender .= "<tr>\n"; |
| 42 | if (Permission::userHasFolderReadPermission($fFolderID)) { | 42 | if (Permission::userHasFolderReadPermission($fFolderID)) { |
| @@ -48,7 +48,7 @@ function getBrowsePage($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 | global $default; | 52 | global $default; |
| 53 | 53 | ||
| 54 | $sToRender = "<table border=\"0\" width=\"600\">\n"; | 54 | $sToRender = "<table border=\"0\" width=\"600\">\n"; |
| @@ -67,7 +67,7 @@ function getBrowseAddPage($fFolderID) { | @@ -67,7 +67,7 @@ function getBrowseAddPage($fFolderID) { | ||
| 67 | $sToRender .= "</table>\n"; | 67 | $sToRender .= "</table>\n"; |
| 68 | $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | 68 | $sToRender .= "<table border=\"0\" width=\"100%\">\n"; |
| 69 | $sToRender .= "<tr>\n"; | 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 | $sToRender .= "</tr>\n"; | 71 | $sToRender .= "</tr>\n"; |
| 72 | $sToRender .= "<tr>\n"; | 72 | $sToRender .= "<tr>\n"; |
| 73 | $sToRender .= "<td>" . getDocumentListForFolder($fFolderID) . "</td>\n"; | 73 | $sToRender .= "<td>" . getDocumentListForFolder($fFolderID) . "</td>\n"; |