Commit 2d60dffd0d7653b58913385c7e811106f74fec1a

Authored by bshuttle
1 parent 90ec040f

handle missing documents gracefully.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5631 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktcore/KTDocumentActions.php
@@ -72,10 +72,17 @@ class KTDocumentViewAction extends KTDocumentAction { @@ -72,10 +72,17 @@ class KTDocumentViewAction extends KTDocumentAction {
72 if ($iVersion) { 72 if ($iVersion) {
73 $oVersion = KTDocumentContentVersion::get($iVersion); 73 $oVersion = KTDocumentContentVersion::get($iVersion);
74 $aOptions['version'] = sprintf("%d.%d", $oVersion->getMajorVersionNumber(), $oVersion->getMinorVersionNumber());; 74 $aOptions['version'] = sprintf("%d.%d", $oVersion->getMajorVersionNumber(), $oVersion->getMinorVersionNumber());;
75 - $oStorage->downloadVersion($this->oDocument, $iVersion); 75 + $res = $oStorage->downloadVersion($this->oDocument, $iVersion);
76 } else { 76 } else {
77 - $oStorage->download($this->oDocument); 77 + $res = $oStorage->download($this->oDocument);
78 } 78 }
  79 +
  80 + if ($res === false) {
  81 + $this->addErrorMessage(_kt('The file you requested is not available - please contact the system administrator if this is incorrect.'));
  82 + redirect(generateControllerLink('viewDocument',sprintf(_kt('fDocumentId=%d'),$this->oDocument->getId())));
  83 + exit(0);
  84 + }
  85 +
79 $oDocumentTransaction = & new DocumentTransaction($this->oDocument, "Document downloaded", 'ktcore.transactions.download', $aOptions); 86 $oDocumentTransaction = & new DocumentTransaction($this->oDocument, "Document downloaded", 'ktcore.transactions.download', $aOptions);
80 $oDocumentTransaction->create(); 87 $oDocumentTransaction->create();
81 exit(0); 88 exit(0);