/
file_set.php
52 lines (43 loc) · 1.3 KB
/
file_set.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
<?php
namespace Concrete\Controller\Dialog\Permissions;
use Concrete\Controller\Backend\UserInterface;
use Concrete\Core\Error\UserMessageException;
use Concrete\Core\File\Set\Set;
use Concrete\Core\Permission\Checker;
use Concrete\Core\Utility\Service\Validation\Numbers;
defined('C5_EXECUTE') or die('Access Denied.');
class FileSet extends UserInterface
{
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Controller\Controller::$viewPath
*/
protected $viewPath = '/dialogs/permissions/file_set';
/**
* {@inheritdoc}
*
* @see \Concrete\Controller\Backend\UserInterface::canAccess()
*/
public function canAccess()
{
$fsp = new Checker($this->getFileSet());
return $fsp->canEditFileSetPermissions();
}
public function view()
{
$this->set('fileSet', $this->getFileSet());
}
protected function getFileSet(): Set
{
$fileSetID = $this->request->request->get('fsID', $this->request->query->get('fsID'));
if (!$this->app->make(Numbers::class)->integer($fileSetID, 1)) {
return Set::getGlobal();
}
$fileSet = Set::getByID((int) $fileSetID);
if ($fileSet === null) {
throw new UserMessageException(t('File Set not found'));
}
return $fileSet;
}
}