mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
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:
commit
c0fbe98851
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user