mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-09-30 21:29:23 +02:00
ENHANCEMENT: adding the ability to extend a DMSDocument's file querying mechanism.
This commit is contained in:
parent
ccfbe6e158
commit
4854be9eea
@ -586,16 +586,26 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DMSDocument_Controller extends Controller {
|
class DMSDocument_Controller extends Controller {
|
||||||
|
|
||||||
static $allowed_actions = array(
|
static $allowed_actions = array(
|
||||||
'index'
|
'index'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the document object from the request object's ID parameter.
|
||||||
|
* Returns null, if no document found
|
||||||
|
*/
|
||||||
|
protected function getDocumentFromID($request) {
|
||||||
|
$id = Convert::raw2sql($request->param('ID'));
|
||||||
|
return DataObject::get_by_id('DMSDocument', $id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access the file download without redirecting user, so we can block direct access to documents.
|
* Access the file download without redirecting user, so we can block direct access to documents.
|
||||||
*/
|
*/
|
||||||
function index(SS_HTTPRequest $request) {
|
function index(SS_HTTPRequest $request) {
|
||||||
$id = Convert::raw2sql($this->getRequest()->param('ID'));
|
$doc = $this->getDocumentFromID($request);
|
||||||
if (!empty($id)) $doc = DataObject::get_by_id('DMSDocument', $id);
|
|
||||||
if (!empty($doc)) {
|
if (!empty($doc)) {
|
||||||
$canView = false;
|
$canView = false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user