Make sure default DownloadBehavior is stored when initially uploading a document

This commit is contained in:
Dave Collins 2018-07-05 11:58:18 -04:00
parent d94aa25ac7
commit 71c09244f7
1 changed files with 13 additions and 1 deletions

View File

@ -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;
}
}
}
/**