From 71c09244f7b554ad68bd12dbf0d09da19fadb7ae Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Thu, 5 Jul 2018 11:58:18 -0400 Subject: [PATCH] Make sure default DownloadBehavior is stored when initially uploading a document --- code/model/DMSDocument.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/code/model/DMSDocument.php b/code/model/DMSDocument.php index 3a0258f..2044d4b 100644 --- a/code/model/DMSDocument.php +++ b/code/model/DMSDocument.php @@ -235,7 +235,7 @@ class DMSDocument extends DataObject implements DMSDocumentInterface $this->ViewCount = $count; DB::query("UPDATE \"DMSDocument\" SET \"ViewCount\"='$count' WHERE \"ID\"={$this->ID}"); - + $this->extend('trackView'); } @@ -1003,6 +1003,18 @@ class DMSDocument extends DataObject implements DMSDocumentInterface } $this->LastEditedByID = $currentUserID; } + + // make sure default DownloadBehavior is respected when writing since + $defaultDownloadBehaviour = Config::inst()->get('DMSDocument', 'default_download_behaviour'); + if ($this->DownloadBehavior == null && !empty($defaultDownloadBehaviour)) { + $possibleBehaviors = $this->dbObject('DownloadBehavior') + ->enumValues(); + + $behavior =$possibleBehaviors[$defaultDownloadBehaviour]; + if ($behavior) { + $this->DownloadBehavior = $behavior; + } + } } /**