Commit 3e6b39c861749d133a37283c1a3c891a5390977f
1 parent
9eca8b6b
factored document download and inline view to a separate page
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2179 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
74 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/downloadBL.php
0 → 100644
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * $Id$ | |
| 4 | + * | |
| 5 | + * Contains the business logic required to download a document. | |
| 6 | + * | |
| 7 | + * Expected form varaibles: | |
| 8 | + * o $fDocumentID - Primary key of document to view | |
| 9 | + * | |
| 10 | + * Licensed under the GNU GPL. For full terms see the file DOCS/COPYING. | |
| 11 | + * | |
| 12 | + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | |
| 13 | + * @package presentation.lookAndFeel.knowledgeTree.documentmanagement | |
| 14 | + */ | |
| 15 | + | |
| 16 | +require_once("../../../../config/dmsDefaults.php"); | |
| 17 | + | |
| 18 | +require_once("$default->fileSystemRoot/lib/security/permission.inc"); | |
| 19 | +require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc"); | |
| 20 | +require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc"); | |
| 21 | +require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | |
| 22 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | |
| 23 | + | |
| 24 | +if (checkSession()) { | |
| 25 | + if (isset($fDocumentID)) { | |
| 26 | + $oDocument = Document::get($fDocumentID); | |
| 27 | + if (Permission::userHasDocumentReadPermission($fDocumentID)) { | |
| 28 | + if (isset($fForInlineView)) { | |
| 29 | + $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Inline view", VIEW); | |
| 30 | + $oDocumentTransaction->create(); | |
| 31 | + PhysicalDocumentManager::inlineViewPhysicalDocument($fDocumentID); | |
| 32 | + } else { | |
| 33 | + //if the user has document read permission, perform the download | |
| 34 | + if (isset($fVersion)) { | |
| 35 | + // we're downloading an old version of the document | |
| 36 | + $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document version $fVersion downloaded", DOWNLOAD); | |
| 37 | + $oDocumentTransaction->create(); | |
| 38 | + | |
| 39 | + // if the document is currently checked out, and we're the version we're downloading | |
| 40 | + // is the same as the current version, then download the current version of the document | |
| 41 | + if ($oDocument->getIsCheckedOut() && ($fVersion == $oDocument->getVersion())) { | |
| 42 | + PhysicalDocumentManager::downloadPhysicalDocument($fDocumentID); | |
| 43 | + } else { | |
| 44 | + PhysicalDocumentManager::downloadVersionedPhysicalDocument($fDocumentID, $fVersion); | |
| 45 | + } | |
| 46 | + } else { | |
| 47 | + // download the current version | |
| 48 | + $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document downloaded", DOWNLOAD); | |
| 49 | + $oDocumentTransaction->create(); | |
| 50 | + PhysicalDocumentManager::downloadPhysicalDocument($fDocumentID); | |
| 51 | + } | |
| 52 | + } | |
| 53 | + } else { | |
| 54 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 55 | + $oPatternCustom = new PatternCustom(); | |
| 56 | + if ($oDocument) { | |
| 57 | + $oPatternCustom->setHtml("<a href=\"" . generateControllerLink("browse", "fFolderID=" . $oDocument->getFolderID()) . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n"); | |
| 58 | + } else { | |
| 59 | + $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n"); | |
| 60 | + } | |
| 61 | + $main->setErrorMessage("Either you do not have permission to view this document, or the document you have chosen no longer exists on the file system."); | |
| 62 | + $main->setCentralPayload($oPatternCustom); | |
| 63 | + $main->render(); | |
| 64 | + } | |
| 65 | + } else { | |
| 66 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 67 | + $oPatternCustom = new PatternCustom(); | |
| 68 | + $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n"); | |
| 69 | + $main->setErrorMessage("You have not chosen a document to view"); | |
| 70 | + $main->setCentralPayload($oPatternCustom); | |
| 71 | + $main->render(); | |
| 72 | + } | |
| 73 | +} | |
| 74 | +?> | |
| 0 | 75 | \ No newline at end of file | ... | ... |