Commit 10092bf26ad8b6d6019630319f63006f61466402
1 parent
b381fd06
Initial revision. Move a document to a new folder
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@967 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
118 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentBL.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | + | |
| 4 | +require_once("../../../../config/dmsDefaults.php"); | |
| 5 | + | |
| 6 | +require_once("$default->owl_fs_root/lib/security/permission.inc"); | |
| 7 | + | |
| 8 | +require_once("$default->owl_fs_root/lib/users/User.inc"); | |
| 9 | + | |
| 10 | +require_once("$default->owl_fs_root/lib/documentmanagement/DocumentTransaction.inc"); | |
| 11 | +require_once("$default->owl_fs_root/lib/documentmanagement/Document.inc"); | |
| 12 | +require_once("$default->owl_fs_root/lib/documentmanagement/PhysicalDocumentManager.inc"); | |
| 13 | +require_once("$default->owl_fs_root/lib/foldermanagement/Folder.inc"); | |
| 14 | + | |
| 15 | +require_once("$default->owl_fs_root/lib/visualpatterns/PatternTableSqlQuery.inc"); | |
| 16 | +require_once("$default->owl_fs_root/lib/visualpatterns/PatternCustom.inc"); | |
| 17 | + | |
| 18 | +require_once("$default->owl_fs_root/presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentUI.inc"); | |
| 19 | +require_once("$default->owl_fs_root/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | |
| 20 | +require_once("$default->owl_fs_root/presentation/Html.inc"); | |
| 21 | + | |
| 22 | +if (checkSession()) { | |
| 23 | + | |
| 24 | + if (isset($fDocumentID) && isset($fFolderID)) { | |
| 25 | + if (isset($fForMove)) { | |
| 26 | + //we're trying to move a document | |
| 27 | + $oDocument = & Document::get($fDocumentID); | |
| 28 | + $iOldFolderID = $oDocument->getFolderID(); | |
| 29 | + if (Permission::userHasDocumentWritePermission($fDocumentID) && Permission::userHasFolderWritePermission($fFolderID)) { | |
| 30 | + //if the user has both document and folder write permissions | |
| 31 | + //get the old document path | |
| 32 | + $sOldDocumentFileSystemPath = Folder::getFolderPath($iOldFolderID) . $oDocument->getFileName(); | |
| 33 | + //put the document in the new folder | |
| 34 | + $oDocument->setFolderID($fFolderID); | |
| 35 | + if ($oDocument->update()) { | |
| 36 | + //get the new document path | |
| 37 | + $sNewDocumentFileSystemPath = Folder::getFolderPath($oDocument->getFolderID()) . $oDocument->getFileName(); | |
| 38 | + //move the document on the file system | |
| 39 | + if (PhysicalDocumentManager::move($sOldDocumentFileSystemPath, $sNewDocumentFileSystemPath)) { | |
| 40 | + //redirect to the view path | |
| 41 | + redirect("$default->owl_root_url/control.php?action=viewDocument&fDocumentID=$fDocumentID"); | |
| 42 | + } else { | |
| 43 | + require_once("$default->owl_fs_root/presentation/webpageTemplate.inc"); | |
| 44 | + //we couldn't move the document on the file system | |
| 45 | + //so reset the database values | |
| 46 | + $oDocument->setFolderID($iOldFolderID); | |
| 47 | + $oDocument->update(); | |
| 48 | + $oPatternCustom = & new PatternCustom(); | |
| 49 | + $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID)); | |
| 50 | + $main->setCentralPayload($oPatternCustom); | |
| 51 | + $main->setErrorMessage("Could not move document on file system"); | |
| 52 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1"); | |
| 53 | + $main->render(); | |
| 54 | + } | |
| 55 | + } else { | |
| 56 | + require_once("$default->owl_fs_root/presentation/webpageTemplate.inc"); | |
| 57 | + //had a problem with the database | |
| 58 | + $oPatternCustom = & new PatternCustom(); | |
| 59 | + $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID)); | |
| 60 | + $main->setCentralPayload($oPatternCustom); | |
| 61 | + $main->setErrorMessage("Could not update document in database"); | |
| 62 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID"); | |
| 63 | + $main->render(); | |
| 64 | + } | |
| 65 | + } else { | |
| 66 | + require_once("$default->owl_fs_root/presentation/webpageTemplate.inc"); | |
| 67 | + $oPatternCustom = & new PatternCustom(); | |
| 68 | + $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID)); | |
| 69 | + $main->setCentralPayload($oPatternCustom); | |
| 70 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID"); | |
| 71 | + $main->setErrorMessage("You do not have rights to move this document"); | |
| 72 | + $main->render(); | |
| 73 | + } | |
| 74 | + | |
| 75 | + } else { | |
| 76 | + require_once("$default->owl_fs_root/presentation/webpageTemplate.inc"); | |
| 77 | + $oPatternCustom = & new PatternCustom(); | |
| 78 | + $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID)); | |
| 79 | + $main->setCentralPayload($oPatternCustom); | |
| 80 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID"); | |
| 81 | + $main->render(); | |
| 82 | + } | |
| 83 | + } else { | |
| 84 | + require_once("$default->owl_fs_root/presentation/webpageTemplate.inc"); | |
| 85 | + $oPatternCustom = & new PatternCustom(); | |
| 86 | + $oPatternCustom->setHtml(""); | |
| 87 | + $main->setCentralPayload($oPatternCustom); | |
| 88 | + $main->setErrorMessage("No document/folder selected"); | |
| 89 | + $main->render(); | |
| 90 | + } | |
| 91 | + | |
| 92 | +} | |
| 93 | +?> | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentUI.inc
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +function getFolderPath($iFolderID) { | |
| 4 | + global $default; | |
| 5 | + $sFolderPath = displayFolderPathLink(Folder::getFolderPathAsArray($iFolderID), "$default->owl_root_url/control.php?action=browse"); | |
| 6 | + return "<table border=1 width = 100%><tr><td>$sFolderPath</td></tr></table>\n"; | |
| 7 | +} | |
| 8 | + | |
| 9 | +function getPage($iFolderID, $iDocumentID) { | |
| 10 | + global $default; | |
| 11 | + $sToRender = "<table>\n"; | |
| 12 | + $sToRender .= "<tr>\n"; | |
| 13 | + $sToRender .= "<td>" . getFolderPath($iFolderID) . "</td>\n"; | |
| 14 | + $sToRender .= "</tr>\n"; | |
| 15 | + $sToRender .= "</table>\n"; | |
| 16 | + $sToRender .= "<table>\n"; | |
| 17 | + $sToRender .= "<tr>\n"; | |
| 18 | + $sToRender .= "<td>" . renderFolderList($iFolderID, "control.php?action=moveDocument&fDocumentID=$iDocumentID") . "</td>\n"; | |
| 19 | + $sToRender .= "</tr>\n"; | |
| 20 | + $sToRender .= "<tr><td><table><tr><td><input type=\"image\" src=\"$default->owl_graphics_url/widgets/movehere.gif\" /></td></tr></table></td>\n"; | |
| 21 | + $sToRender .= "</table>\n"; | |
| 22 | + return $sToRender; | |
| 23 | +} | |
| 24 | + | |
| 25 | +?> | ... | ... |