/
folder.php
56 lines (47 loc) · 1.75 KB
/
folder.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
54
55
56
<?php
namespace Concrete\Controller\Dialog\File;
use Concrete\Controller\Backend\UserInterface\File as BackendInterfaceFileController;
use Concrete\Core\Error\UserMessageException;
use Concrete\Core\File\EditResponse;
use Concrete\Core\Tree\Node\Node;
use URL;
class Folder extends BackendInterfaceFileController
{
protected $viewPath = '/dialogs/file/folder';
protected function canAccess()
{
return $this->permissions->canViewFileInFileManager();
}
public function view()
{
}
public function submit()
{
$destNode = Node::getByID($this->request->request->get('folderID'));
if (is_object($destNode)) {
$dp = new \Permissions($destNode);
if (!$dp->canAddTreeSubNode()) {
throw new UserMessageException(t('You are not allowed to move files to this location.'));
}
} else {
throw new UserMessageException(t('You have not selected a valid folder.'));
}
$sourceNode = $this->file->getFileNodeObject();
if (is_object($sourceNode)) {
$dp = new \Permissions($sourceNode);
if (!$dp->canEditTreeNode()) {
throw new UserMessageException(t('You are not allowed to move this file.'));
}
} else {
throw new UserMessageException(t('Invalid source file object.'));
}
if ($this->validateAction()) {
$sourceNode->move($destNode);
$response = new EditResponse();
$response->setFile($this->file);
$response->setMessage(t('File moved to folder successfully.'));
$response->setAdditionalDataAttribute('folder', $destNode->getTreeNodeJSON());
$response->outputJSON();
}
}
}