allow pass the object with the document content

This commit is contained in:
Uwe Steinmann 2019-07-05 14:13:29 +02:00
parent 853d111738
commit 585c81bb66

View File

@ -28,25 +28,29 @@ class SeedDMS_Controller_Download extends SeedDMS_Controller_Common {
switch($type) { switch($type) {
case "version": case "version":
$version = $this->params['version']; if(empty($this->params['content'])) {
$document = $this->params['document']; $version = $this->params['version'];
if($version < 1) { $document = $this->params['document'];
$content = $this->callHook('documentLatestContent', $document); if($version < 1) {
if($content === null) $content = $this->callHook('documentLatestContent', $document);
$content = $document->getLatestContent(); if($content === null)
$content = $document->getLatestContent();
} else {
$content = $this->callHook('documentContent', $document, $version);
if($content === null)
$content = $document->getContentByVersion($version);
}
if (!is_object($content)) {
$this->errormsg = 'invalid_version';
return false;
}
/* set params['content'] for compatiblity with older extensions which
* expect the content in the controller
*/
$this->params['content'] = $content;
} else { } else {
$content = $this->callHook('documentContent', $document, $version); $content = $this->params['content'];
if($content === null)
$content = $document->getContentByVersion($version);
} }
if (!is_object($content)) {
$this->errormsg = 'invalid_version';
return false;
}
/* set params['content'] for compatiblity with older extensions which
* expect the content in the controller
*/
$this->params['content'] = $content;
if(null === $this->callHook('version')) { if(null === $this->callHook('version')) {
if(file_exists($dms->contentDir . $content->getPath())) { if(file_exists($dms->contentDir . $content->getPath())) {
header("Content-Transfer-Encoding: binary"); header("Content-Transfer-Encoding: binary");