|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OCA\Files_External\Panels; |
|
4
|
|
|
|
|
5
|
|
|
use OC\Encryption\Manager; |
|
6
|
|
|
use OCP\Files\External\Service\IGlobalStoragesService; |
|
7
|
|
|
use OCP\Settings\ISettings; |
|
8
|
|
|
use OCP\Files\External\IStoragesBackendService; |
|
9
|
|
|
use OCP\Template; |
|
10
|
|
|
|
|
11
|
|
View Code Duplication |
class Admin implements ISettings { |
|
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
/** @var IGlobalStoragesService */ |
|
14
|
|
|
protected $globalStoragesService; |
|
15
|
|
|
/** @var IStoragesBackendService */ |
|
16
|
|
|
protected $backendService; |
|
17
|
|
|
/** @var Manager */ |
|
18
|
|
|
protected $encManager; |
|
19
|
|
|
|
|
20
|
|
|
public function __construct(IGlobalStoragesService $globalStoragesService, |
|
21
|
|
|
IStoragesBackendService $backendService, |
|
22
|
|
|
Manager $encManager) { |
|
23
|
|
|
$this->globalStoragesService = $globalStoragesService; |
|
24
|
|
|
$this->backendService = $backendService; |
|
25
|
|
|
$this->encManager = $encManager; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function getPriority() { |
|
29
|
|
|
return 0; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function getSectionID() { |
|
33
|
|
|
return 'storage'; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function getPanel() { |
|
37
|
|
|
// we must use the same container |
|
38
|
|
|
$tmpl = new Template('files_external', 'settings'); |
|
39
|
|
|
$tmpl->assign('encryptionEnabled', $this->encManager->isEnabled()); |
|
40
|
|
|
$tmpl->assign('visibilityType', IStoragesBackendService::VISIBILITY_ADMIN); |
|
41
|
|
|
$tmpl->assign('storages', $this->globalStoragesService->getStorages()); |
|
42
|
|
|
$tmpl->assign('backends', $this->backendService->getAvailableBackends()); |
|
43
|
|
|
$tmpl->assign('authMechanisms', $this->backendService->getAuthMechanisms()); |
|
44
|
|
|
$tmpl->assign('dependencies', \OC_Mount_Config::dependencyMessage($this->backendService->getBackends())); |
|
|
|
|
|
|
45
|
|
|
$tmpl->assign('allowUserMounting', $this->backendService->isUserMountingAllowed()); |
|
46
|
|
|
return $tmpl; |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.