-
Notifications
You must be signed in to change notification settings - Fork 452
/
file.php
53 lines (46 loc) · 1.42 KB
/
file.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Concrete\Controller\Backend\UserInterface;
use Concrete\Core\Entity\File\File as FileEntity;
use Concrete\Core\File\File as ConcreteFile;
use Loader;
use Permissions;
use Exception;
abstract class File extends \Concrete\Controller\Backend\UserInterface
{
protected $file;
public function on_start()
{
if (!isset($this->file)) {
$request = $this->request;
$fID = Loader::helper('security')->sanitizeInt($request->query->get('fID'));
if ($fID) {
$file = ConcreteFile::getByID($fID);
if (is_object($file) && !$file->isError()) {
$this->setFileObject($file);
} else {
throw new Exception(t('Invalid file.'));
}
}
}
}
public function setFileObject(FileEntity $f)
{
$this->file = $f;
$this->permissions = new Permissions($this->file);
$this->set('f', $this->file);
$this->set('fp', $this->permissions);
}
public function getViewObject()
{
if ($this->permissions->canViewFileInFileManager()) {
return parent::getViewObject();
}
throw new Exception(t('Access Denied'));
}
public function action()
{
$url = call_user_func_array('parent::action', func_get_args());
$url .= '&fID=' . $this->file->getFileID();
return $url;
}
}