Merge pull request #214 from InnisMaggiore/dmc/download-behavior-on-write

Save default DownloadBehaviour on a DMSDocument when initially uploading a new one
This commit is contained in:
Daniel Hensby 2018-07-06 16:57:19 +01:00 committed by GitHub
commit c0fbe98851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 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,21 @@ class DMSDocument extends DataObject implements DMSDocumentInterface
}
$this->LastEditedByID = $currentUserID;
}
// make sure default DownloadBehavior is respected when initially writing document
// in case the default in the enum is different than what's set in an outside config
$defaultDownloadBehaviour = Config::inst()->get('DMSDocument', 'default_download_behaviour');
if ($this->DownloadBehavior == null && !empty($defaultDownloadBehaviour)) {
$possibleBehaviors = $this->dbObject('DownloadBehavior')
->enumValues();
if (array_key_exists($defaultDownloadBehaviour, $possibleBehaviors)) {
$behavior = $possibleBehaviors[$defaultDownloadBehaviour];
if ($behavior) {
$this->DownloadBehavior = $behavior;
}
}
}
}
/**