@@ -39,7 +39,7 @@ |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | public function createDirectory($name) { |
42 | - throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
42 | + throw new Forbidden('Permission denied to create file (filename '.$name.')'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function getChild($name) { |
@@ -32,92 +32,92 @@ |
||
32 | 32 | use Sabre\DAV\ICollection; |
33 | 33 | |
34 | 34 | class UploadFolder implements ICollection { |
35 | - /** @var Directory */ |
|
36 | - private $node; |
|
37 | - /** @var CleanupService */ |
|
38 | - private $cleanupService; |
|
39 | - /** @var IStorage */ |
|
40 | - private $storage; |
|
41 | - |
|
42 | - public function __construct(Directory $node, CleanupService $cleanupService, IStorage $storage) { |
|
43 | - $this->node = $node; |
|
44 | - $this->cleanupService = $cleanupService; |
|
45 | - $this->storage = $storage; |
|
46 | - } |
|
47 | - |
|
48 | - public function createFile($name, $data = null) { |
|
49 | - // TODO: verify name - should be a simple number |
|
50 | - $this->node->createFile($name, $data); |
|
51 | - } |
|
52 | - |
|
53 | - public function createDirectory($name) { |
|
54 | - throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
55 | - } |
|
56 | - |
|
57 | - public function getChild($name) { |
|
58 | - if ($name === '.file') { |
|
59 | - return new FutureFile($this->node, '.file'); |
|
60 | - } |
|
61 | - return new UploadFile($this->node->getChild($name)); |
|
62 | - } |
|
63 | - |
|
64 | - public function getChildren() { |
|
65 | - $tmpChildren = $this->node->getChildren(); |
|
66 | - |
|
67 | - $children = []; |
|
68 | - $children[] = new FutureFile($this->node, '.file'); |
|
69 | - |
|
70 | - foreach ($tmpChildren as $child) { |
|
71 | - $children[] = new UploadFile($child); |
|
72 | - } |
|
73 | - |
|
74 | - if ($this->storage->instanceOfStorage(ObjectStoreStorage::class)) { |
|
75 | - /** @var ObjectStoreStorage $storage */ |
|
76 | - $objectStore = $this->storage->getObjectStore(); |
|
77 | - if ($objectStore instanceof IObjectStoreMultiPartUpload) { |
|
78 | - $cache = \OC::$server->getMemCacheFactory()->createDistributed(ChunkingV2Plugin::CACHE_KEY); |
|
79 | - $uploadSession = $cache->get($this->getName()); |
|
80 | - if ($uploadSession) { |
|
81 | - $uploadId = $uploadSession[ChunkingV2Plugin::UPLOAD_ID]; |
|
82 | - $id = $uploadSession[ChunkingV2Plugin::UPLOAD_TARGET_ID]; |
|
83 | - $parts = $objectStore->getMultipartUploads($this->storage->getURN($id), $uploadId); |
|
84 | - foreach ($parts as $part) { |
|
85 | - $children[] = new PartFile($this->node, $part); |
|
86 | - } |
|
87 | - } |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - return $children; |
|
92 | - } |
|
93 | - |
|
94 | - public function childExists($name) { |
|
95 | - if ($name === '.file') { |
|
96 | - return true; |
|
97 | - } |
|
98 | - return $this->node->childExists($name); |
|
99 | - } |
|
100 | - |
|
101 | - public function delete() { |
|
102 | - $this->node->delete(); |
|
103 | - |
|
104 | - // Background cleanup job is not needed anymore |
|
105 | - $this->cleanupService->removeJob($this->getName()); |
|
106 | - } |
|
107 | - |
|
108 | - public function getName() { |
|
109 | - return $this->node->getName(); |
|
110 | - } |
|
111 | - |
|
112 | - public function setName($name) { |
|
113 | - throw new Forbidden('Permission denied to rename this folder'); |
|
114 | - } |
|
115 | - |
|
116 | - public function getLastModified() { |
|
117 | - return $this->node->getLastModified(); |
|
118 | - } |
|
119 | - |
|
120 | - public function getStorage() { |
|
121 | - return $this->storage; |
|
122 | - } |
|
35 | + /** @var Directory */ |
|
36 | + private $node; |
|
37 | + /** @var CleanupService */ |
|
38 | + private $cleanupService; |
|
39 | + /** @var IStorage */ |
|
40 | + private $storage; |
|
41 | + |
|
42 | + public function __construct(Directory $node, CleanupService $cleanupService, IStorage $storage) { |
|
43 | + $this->node = $node; |
|
44 | + $this->cleanupService = $cleanupService; |
|
45 | + $this->storage = $storage; |
|
46 | + } |
|
47 | + |
|
48 | + public function createFile($name, $data = null) { |
|
49 | + // TODO: verify name - should be a simple number |
|
50 | + $this->node->createFile($name, $data); |
|
51 | + } |
|
52 | + |
|
53 | + public function createDirectory($name) { |
|
54 | + throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
55 | + } |
|
56 | + |
|
57 | + public function getChild($name) { |
|
58 | + if ($name === '.file') { |
|
59 | + return new FutureFile($this->node, '.file'); |
|
60 | + } |
|
61 | + return new UploadFile($this->node->getChild($name)); |
|
62 | + } |
|
63 | + |
|
64 | + public function getChildren() { |
|
65 | + $tmpChildren = $this->node->getChildren(); |
|
66 | + |
|
67 | + $children = []; |
|
68 | + $children[] = new FutureFile($this->node, '.file'); |
|
69 | + |
|
70 | + foreach ($tmpChildren as $child) { |
|
71 | + $children[] = new UploadFile($child); |
|
72 | + } |
|
73 | + |
|
74 | + if ($this->storage->instanceOfStorage(ObjectStoreStorage::class)) { |
|
75 | + /** @var ObjectStoreStorage $storage */ |
|
76 | + $objectStore = $this->storage->getObjectStore(); |
|
77 | + if ($objectStore instanceof IObjectStoreMultiPartUpload) { |
|
78 | + $cache = \OC::$server->getMemCacheFactory()->createDistributed(ChunkingV2Plugin::CACHE_KEY); |
|
79 | + $uploadSession = $cache->get($this->getName()); |
|
80 | + if ($uploadSession) { |
|
81 | + $uploadId = $uploadSession[ChunkingV2Plugin::UPLOAD_ID]; |
|
82 | + $id = $uploadSession[ChunkingV2Plugin::UPLOAD_TARGET_ID]; |
|
83 | + $parts = $objectStore->getMultipartUploads($this->storage->getURN($id), $uploadId); |
|
84 | + foreach ($parts as $part) { |
|
85 | + $children[] = new PartFile($this->node, $part); |
|
86 | + } |
|
87 | + } |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + return $children; |
|
92 | + } |
|
93 | + |
|
94 | + public function childExists($name) { |
|
95 | + if ($name === '.file') { |
|
96 | + return true; |
|
97 | + } |
|
98 | + return $this->node->childExists($name); |
|
99 | + } |
|
100 | + |
|
101 | + public function delete() { |
|
102 | + $this->node->delete(); |
|
103 | + |
|
104 | + // Background cleanup job is not needed anymore |
|
105 | + $this->cleanupService->removeJob($this->getName()); |
|
106 | + } |
|
107 | + |
|
108 | + public function getName() { |
|
109 | + return $this->node->getName(); |
|
110 | + } |
|
111 | + |
|
112 | + public function setName($name) { |
|
113 | + throw new Forbidden('Permission denied to rename this folder'); |
|
114 | + } |
|
115 | + |
|
116 | + public function getLastModified() { |
|
117 | + return $this->node->getLastModified(); |
|
118 | + } |
|
119 | + |
|
120 | + public function getStorage() { |
|
121 | + return $this->storage; |
|
122 | + } |
|
123 | 123 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | |
63 | 63 | $requestUri = \OC::$server->getRequest()->getRequestUri(); |
64 | 64 | |
65 | -$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function () { |
|
65 | +$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function() { |
|
66 | 66 | // use the view for the logged in user |
67 | 67 | return \OC\Files\Filesystem::getView(); |
68 | 68 | }); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | // no php execution timeout for webdav |
34 | 34 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
35 | - @set_time_limit(0); |
|
35 | + @set_time_limit(0); |
|
36 | 36 | } |
37 | 37 | ignore_user_abort(true); |
38 | 38 | |
@@ -40,40 +40,40 @@ discard block |
||
40 | 40 | \OC_Util::obEnd(); |
41 | 41 | |
42 | 42 | $serverFactory = new \OCA\DAV\Connector\Sabre\ServerFactory( |
43 | - \OC::$server->getConfig(), |
|
44 | - \OC::$server->get(LoggerInterface::class), |
|
45 | - \OC::$server->getDatabaseConnection(), |
|
46 | - \OC::$server->getUserSession(), |
|
47 | - \OC::$server->getMountManager(), |
|
48 | - \OC::$server->getTagManager(), |
|
49 | - \OC::$server->getRequest(), |
|
50 | - \OC::$server->getPreviewManager(), |
|
51 | - \OC::$server->getEventDispatcher(), |
|
52 | - \OC::$server->getL10N('dav') |
|
43 | + \OC::$server->getConfig(), |
|
44 | + \OC::$server->get(LoggerInterface::class), |
|
45 | + \OC::$server->getDatabaseConnection(), |
|
46 | + \OC::$server->getUserSession(), |
|
47 | + \OC::$server->getMountManager(), |
|
48 | + \OC::$server->getTagManager(), |
|
49 | + \OC::$server->getRequest(), |
|
50 | + \OC::$server->getPreviewManager(), |
|
51 | + \OC::$server->getEventDispatcher(), |
|
52 | + \OC::$server->getL10N('dav') |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | // Backends |
56 | 56 | $authBackend = new \OCA\DAV\Connector\Sabre\Auth( |
57 | - \OC::$server->getSession(), |
|
58 | - \OC::$server->getUserSession(), |
|
59 | - \OC::$server->getRequest(), |
|
60 | - \OC::$server->getTwoFactorAuthManager(), |
|
61 | - \OC::$server->getBruteForceThrottler(), |
|
62 | - 'principals/' |
|
57 | + \OC::$server->getSession(), |
|
58 | + \OC::$server->getUserSession(), |
|
59 | + \OC::$server->getRequest(), |
|
60 | + \OC::$server->getTwoFactorAuthManager(), |
|
61 | + \OC::$server->getBruteForceThrottler(), |
|
62 | + 'principals/' |
|
63 | 63 | ); |
64 | 64 | $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend); |
65 | 65 | $bearerAuthPlugin = new \OCA\DAV\Connector\Sabre\BearerAuth( |
66 | - \OC::$server->getUserSession(), |
|
67 | - \OC::$server->getSession(), |
|
68 | - \OC::$server->getRequest() |
|
66 | + \OC::$server->getUserSession(), |
|
67 | + \OC::$server->getSession(), |
|
68 | + \OC::$server->getRequest() |
|
69 | 69 | ); |
70 | 70 | $authPlugin->addBackend($bearerAuthPlugin); |
71 | 71 | |
72 | 72 | $requestUri = \OC::$server->getRequest()->getRequestUri(); |
73 | 73 | |
74 | 74 | $server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function () { |
75 | - // use the view for the logged in user |
|
76 | - return \OC\Files\Filesystem::getView(); |
|
75 | + // use the view for the logged in user |
|
76 | + return \OC\Files\Filesystem::getView(); |
|
77 | 77 | }); |
78 | 78 | |
79 | 79 | $dispatcher = \OC::$server->getEventDispatcher(); |
@@ -55,8 +55,8 @@ |
||
55 | 55 | $logger = \OC::$server->getLogger(); |
56 | 56 | |
57 | 57 | $sql = |
58 | - 'DELETE FROM `*PREFIX*share` ' . |
|
59 | - 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
58 | + 'DELETE FROM `*PREFIX*share` '. |
|
59 | + 'WHERE `item_type` in (\'file\', \'folder\') '. |
|
60 | 60 | 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
61 | 61 | |
62 | 62 | $deletedEntries = $connection->executeUpdate($sql); |
@@ -31,37 +31,37 @@ |
||
31 | 31 | * Delete all share entries that have no matching entries in the file cache table. |
32 | 32 | */ |
33 | 33 | class DeleteOrphanedSharesJob extends TimedJob { |
34 | - /** |
|
35 | - * Default interval in minutes |
|
36 | - * |
|
37 | - * @var int $defaultIntervalMin |
|
38 | - **/ |
|
39 | - protected $defaultIntervalMin = 15; |
|
34 | + /** |
|
35 | + * Default interval in minutes |
|
36 | + * |
|
37 | + * @var int $defaultIntervalMin |
|
38 | + **/ |
|
39 | + protected $defaultIntervalMin = 15; |
|
40 | 40 | |
41 | - /** |
|
42 | - * sets the correct interval for this timed job |
|
43 | - */ |
|
44 | - public function __construct(ITimeFactory $time) { |
|
45 | - parent::__construct($time); |
|
41 | + /** |
|
42 | + * sets the correct interval for this timed job |
|
43 | + */ |
|
44 | + public function __construct(ITimeFactory $time) { |
|
45 | + parent::__construct($time); |
|
46 | 46 | |
47 | - $this->interval = $this->defaultIntervalMin * 60; |
|
48 | - } |
|
47 | + $this->interval = $this->defaultIntervalMin * 60; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Makes the background job do its work |
|
52 | - * |
|
53 | - * @param array $argument unused argument |
|
54 | - */ |
|
55 | - public function run($argument) { |
|
56 | - $connection = \OC::$server->getDatabaseConnection(); |
|
57 | - $logger = \OC::$server->getLogger(); |
|
50 | + /** |
|
51 | + * Makes the background job do its work |
|
52 | + * |
|
53 | + * @param array $argument unused argument |
|
54 | + */ |
|
55 | + public function run($argument) { |
|
56 | + $connection = \OC::$server->getDatabaseConnection(); |
|
57 | + $logger = \OC::$server->getLogger(); |
|
58 | 58 | |
59 | - $sql = |
|
60 | - 'DELETE FROM `*PREFIX*share` ' . |
|
61 | - 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
62 | - 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
|
59 | + $sql = |
|
60 | + 'DELETE FROM `*PREFIX*share` ' . |
|
61 | + 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
62 | + 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
|
63 | 63 | |
64 | - $deletedEntries = $connection->executeUpdate($sql); |
|
65 | - $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']); |
|
66 | - } |
|
64 | + $deletedEntries = $connection->executeUpdate($sql); |
|
65 | + $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']); |
|
66 | + } |
|
67 | 67 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | if (isset($parameters[$key])) { |
221 | 221 | switch ($parameters[$key]->getType()) { |
222 | 222 | case \OCA\Files_External\Lib\DefinitionParameter::VALUE_BOOLEAN: |
223 | - $value = (bool)$value; |
|
223 | + $value = (bool) $value; |
|
224 | 224 | break; |
225 | 225 | } |
226 | 226 | $backendOptions[$key] = $value; |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | $result['statusMessage'] = $this->statusMessage; |
427 | 427 | } |
428 | 428 | $result['userProvided'] = $this->authMechanism instanceof IUserProvided; |
429 | - $result['type'] = ($this->getType() === self::MOUNT_TYPE_PERSONAl) ? 'personal': 'system'; |
|
429 | + $result['type'] = ($this->getType() === self::MOUNT_TYPE_PERSONAl) ? 'personal' : 'system'; |
|
430 | 430 | return $result; |
431 | 431 | } |
432 | 432 | } |
@@ -36,396 +36,396 @@ |
||
36 | 36 | * External storage configuration |
37 | 37 | */ |
38 | 38 | class StorageConfig implements \JsonSerializable { |
39 | - public const MOUNT_TYPE_ADMIN = 1; |
|
40 | - public const MOUNT_TYPE_PERSONAl = 2; |
|
41 | - |
|
42 | - /** |
|
43 | - * Storage config id |
|
44 | - * |
|
45 | - * @var int |
|
46 | - */ |
|
47 | - private $id; |
|
48 | - |
|
49 | - /** |
|
50 | - * Backend |
|
51 | - * |
|
52 | - * @var Backend |
|
53 | - */ |
|
54 | - private $backend; |
|
55 | - |
|
56 | - /** |
|
57 | - * Authentication mechanism |
|
58 | - * |
|
59 | - * @var AuthMechanism |
|
60 | - */ |
|
61 | - private $authMechanism; |
|
62 | - |
|
63 | - /** |
|
64 | - * Backend options |
|
65 | - * |
|
66 | - * @var array |
|
67 | - */ |
|
68 | - private $backendOptions = []; |
|
69 | - |
|
70 | - /** |
|
71 | - * Mount point path, relative to the user's "files" folder |
|
72 | - * |
|
73 | - * @var string |
|
74 | - */ |
|
75 | - private $mountPoint; |
|
76 | - |
|
77 | - /** |
|
78 | - * Storage status |
|
79 | - * |
|
80 | - * @var int |
|
81 | - */ |
|
82 | - private $status; |
|
83 | - |
|
84 | - /** |
|
85 | - * Status message |
|
86 | - * |
|
87 | - * @var string |
|
88 | - */ |
|
89 | - private $statusMessage; |
|
90 | - |
|
91 | - /** |
|
92 | - * Priority |
|
93 | - * |
|
94 | - * @var int |
|
95 | - */ |
|
96 | - private $priority; |
|
97 | - |
|
98 | - /** |
|
99 | - * List of users who have access to this storage |
|
100 | - * |
|
101 | - * @var string[] |
|
102 | - */ |
|
103 | - private $applicableUsers = []; |
|
104 | - |
|
105 | - /** |
|
106 | - * List of groups that have access to this storage |
|
107 | - * |
|
108 | - * @var string[] |
|
109 | - */ |
|
110 | - private $applicableGroups = []; |
|
111 | - |
|
112 | - /** |
|
113 | - * Mount-specific options |
|
114 | - * |
|
115 | - * @var array |
|
116 | - */ |
|
117 | - private $mountOptions = []; |
|
118 | - |
|
119 | - /** |
|
120 | - * Whether it's a personal or admin mount |
|
121 | - * |
|
122 | - * @var int |
|
123 | - */ |
|
124 | - private $type; |
|
125 | - |
|
126 | - /** |
|
127 | - * Creates a storage config |
|
128 | - * |
|
129 | - * @param int|string $id config id or null for a new config |
|
130 | - */ |
|
131 | - public function __construct($id = null) { |
|
132 | - $this->id = $id ?? -1; |
|
133 | - $this->mountOptions['enable_sharing'] = false; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Returns the configuration id |
|
138 | - * |
|
139 | - * @retun int |
|
140 | - */ |
|
141 | - public function getId() { |
|
142 | - return $this->id; |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Sets the configuration id |
|
147 | - * |
|
148 | - * @param int $id configuration id |
|
149 | - */ |
|
150 | - public function setId(int $id): void { |
|
151 | - $this->id = $id; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Returns mount point path relative to the user's |
|
156 | - * "files" folder. |
|
157 | - * |
|
158 | - * @return string path |
|
159 | - */ |
|
160 | - public function getMountPoint() { |
|
161 | - return $this->mountPoint; |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Sets mount point path relative to the user's |
|
166 | - * "files" folder. |
|
167 | - * The path will be normalized. |
|
168 | - * |
|
169 | - * @param string $mountPoint path |
|
170 | - */ |
|
171 | - public function setMountPoint($mountPoint) { |
|
172 | - $this->mountPoint = \OC\Files\Filesystem::normalizePath($mountPoint); |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * @return Backend |
|
177 | - */ |
|
178 | - public function getBackend() { |
|
179 | - return $this->backend; |
|
180 | - } |
|
181 | - |
|
182 | - /** |
|
183 | - * @param Backend $backend |
|
184 | - */ |
|
185 | - public function setBackend(Backend $backend) { |
|
186 | - $this->backend = $backend; |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * @return AuthMechanism |
|
191 | - */ |
|
192 | - public function getAuthMechanism() { |
|
193 | - return $this->authMechanism; |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * @param AuthMechanism $authMechanism |
|
198 | - */ |
|
199 | - public function setAuthMechanism(AuthMechanism $authMechanism) { |
|
200 | - $this->authMechanism = $authMechanism; |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Returns the external storage backend-specific options |
|
205 | - * |
|
206 | - * @return array backend options |
|
207 | - */ |
|
208 | - public function getBackendOptions() { |
|
209 | - return $this->backendOptions; |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * Sets the external storage backend-specific options |
|
214 | - * |
|
215 | - * @param array $backendOptions backend options |
|
216 | - */ |
|
217 | - public function setBackendOptions($backendOptions) { |
|
218 | - if ($this->getBackend() instanceof Backend) { |
|
219 | - $parameters = $this->getBackend()->getParameters(); |
|
220 | - foreach ($backendOptions as $key => $value) { |
|
221 | - if (isset($parameters[$key])) { |
|
222 | - switch ($parameters[$key]->getType()) { |
|
223 | - case \OCA\Files_External\Lib\DefinitionParameter::VALUE_BOOLEAN: |
|
224 | - $value = (bool)$value; |
|
225 | - break; |
|
226 | - } |
|
227 | - $backendOptions[$key] = $value; |
|
228 | - } |
|
229 | - } |
|
230 | - } |
|
231 | - |
|
232 | - $this->backendOptions = $backendOptions; |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * @param string $key |
|
237 | - * @return mixed |
|
238 | - */ |
|
239 | - public function getBackendOption($key) { |
|
240 | - if (isset($this->backendOptions[$key])) { |
|
241 | - return $this->backendOptions[$key]; |
|
242 | - } |
|
243 | - return null; |
|
244 | - } |
|
245 | - |
|
246 | - /** |
|
247 | - * @param string $key |
|
248 | - * @param mixed $value |
|
249 | - */ |
|
250 | - public function setBackendOption($key, $value) { |
|
251 | - $this->backendOptions[$key] = $value; |
|
252 | - } |
|
253 | - |
|
254 | - /** |
|
255 | - * Returns the mount priority |
|
256 | - * |
|
257 | - * @return int priority |
|
258 | - */ |
|
259 | - public function getPriority() { |
|
260 | - return $this->priority; |
|
261 | - } |
|
262 | - |
|
263 | - /** |
|
264 | - * Sets the mount priority |
|
265 | - * |
|
266 | - * @param int $priority priority |
|
267 | - */ |
|
268 | - public function setPriority($priority) { |
|
269 | - $this->priority = $priority; |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
273 | - * Returns the users for which to mount this storage |
|
274 | - * |
|
275 | - * @return string[] applicable users |
|
276 | - */ |
|
277 | - public function getApplicableUsers() { |
|
278 | - return $this->applicableUsers; |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * Sets the users for which to mount this storage |
|
283 | - * |
|
284 | - * @param string[]|null $applicableUsers applicable users |
|
285 | - */ |
|
286 | - public function setApplicableUsers($applicableUsers) { |
|
287 | - if (is_null($applicableUsers)) { |
|
288 | - $applicableUsers = []; |
|
289 | - } |
|
290 | - $this->applicableUsers = $applicableUsers; |
|
291 | - } |
|
292 | - |
|
293 | - /** |
|
294 | - * Returns the groups for which to mount this storage |
|
295 | - * |
|
296 | - * @return string[] applicable groups |
|
297 | - */ |
|
298 | - public function getApplicableGroups() { |
|
299 | - return $this->applicableGroups; |
|
300 | - } |
|
301 | - |
|
302 | - /** |
|
303 | - * Sets the groups for which to mount this storage |
|
304 | - * |
|
305 | - * @param string[]|null $applicableGroups applicable groups |
|
306 | - */ |
|
307 | - public function setApplicableGroups($applicableGroups) { |
|
308 | - if (is_null($applicableGroups)) { |
|
309 | - $applicableGroups = []; |
|
310 | - } |
|
311 | - $this->applicableGroups = $applicableGroups; |
|
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * Returns the mount-specific options |
|
316 | - * |
|
317 | - * @return array mount specific options |
|
318 | - */ |
|
319 | - public function getMountOptions() { |
|
320 | - return $this->mountOptions; |
|
321 | - } |
|
322 | - |
|
323 | - /** |
|
324 | - * Sets the mount-specific options |
|
325 | - * |
|
326 | - * @param array $mountOptions applicable groups |
|
327 | - */ |
|
328 | - public function setMountOptions($mountOptions) { |
|
329 | - if (is_null($mountOptions)) { |
|
330 | - $mountOptions = []; |
|
331 | - } |
|
332 | - $this->mountOptions = $mountOptions; |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * @param string $key |
|
337 | - * @return mixed |
|
338 | - */ |
|
339 | - public function getMountOption($key) { |
|
340 | - if (isset($this->mountOptions[$key])) { |
|
341 | - return $this->mountOptions[$key]; |
|
342 | - } |
|
343 | - return null; |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * @param string $key |
|
348 | - * @param mixed $value |
|
349 | - */ |
|
350 | - public function setMountOption($key, $value) { |
|
351 | - $this->mountOptions[$key] = $value; |
|
352 | - } |
|
353 | - |
|
354 | - /** |
|
355 | - * Gets the storage status, whether the config worked last time |
|
356 | - * |
|
357 | - * @return int $status status |
|
358 | - */ |
|
359 | - public function getStatus() { |
|
360 | - return $this->status; |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * Gets the message describing the storage status |
|
365 | - * |
|
366 | - * @return string|null |
|
367 | - */ |
|
368 | - public function getStatusMessage() { |
|
369 | - return $this->statusMessage; |
|
370 | - } |
|
371 | - |
|
372 | - /** |
|
373 | - * Sets the storage status, whether the config worked last time |
|
374 | - * |
|
375 | - * @param int $status status |
|
376 | - * @param string|null $message optional message |
|
377 | - */ |
|
378 | - public function setStatus($status, $message = null) { |
|
379 | - $this->status = $status; |
|
380 | - $this->statusMessage = $message; |
|
381 | - } |
|
382 | - |
|
383 | - /** |
|
384 | - * @return int self::MOUNT_TYPE_ADMIN or self::MOUNT_TYPE_PERSONAl |
|
385 | - */ |
|
386 | - public function getType() { |
|
387 | - return $this->type; |
|
388 | - } |
|
389 | - |
|
390 | - /** |
|
391 | - * @param int $type self::MOUNT_TYPE_ADMIN or self::MOUNT_TYPE_PERSONAl |
|
392 | - */ |
|
393 | - public function setType($type) { |
|
394 | - $this->type = $type; |
|
395 | - } |
|
396 | - |
|
397 | - /** |
|
398 | - * Serialize config to JSON |
|
399 | - */ |
|
400 | - public function jsonSerialize(): array { |
|
401 | - $result = []; |
|
402 | - if (!is_null($this->id)) { |
|
403 | - $result['id'] = $this->id; |
|
404 | - } |
|
405 | - $result['mountPoint'] = $this->mountPoint; |
|
406 | - $result['backend'] = $this->backend->getIdentifier(); |
|
407 | - $result['authMechanism'] = $this->authMechanism->getIdentifier(); |
|
408 | - $result['backendOptions'] = $this->backendOptions; |
|
409 | - if (!is_null($this->priority)) { |
|
410 | - $result['priority'] = $this->priority; |
|
411 | - } |
|
412 | - if (!empty($this->applicableUsers)) { |
|
413 | - $result['applicableUsers'] = $this->applicableUsers; |
|
414 | - } |
|
415 | - if (!empty($this->applicableGroups)) { |
|
416 | - $result['applicableGroups'] = $this->applicableGroups; |
|
417 | - } |
|
418 | - if (!empty($this->mountOptions)) { |
|
419 | - $result['mountOptions'] = $this->mountOptions; |
|
420 | - } |
|
421 | - if (!is_null($this->status)) { |
|
422 | - $result['status'] = $this->status; |
|
423 | - } |
|
424 | - if (!is_null($this->statusMessage)) { |
|
425 | - $result['statusMessage'] = $this->statusMessage; |
|
426 | - } |
|
427 | - $result['userProvided'] = $this->authMechanism instanceof IUserProvided; |
|
428 | - $result['type'] = ($this->getType() === self::MOUNT_TYPE_PERSONAl) ? 'personal': 'system'; |
|
429 | - return $result; |
|
430 | - } |
|
39 | + public const MOUNT_TYPE_ADMIN = 1; |
|
40 | + public const MOUNT_TYPE_PERSONAl = 2; |
|
41 | + |
|
42 | + /** |
|
43 | + * Storage config id |
|
44 | + * |
|
45 | + * @var int |
|
46 | + */ |
|
47 | + private $id; |
|
48 | + |
|
49 | + /** |
|
50 | + * Backend |
|
51 | + * |
|
52 | + * @var Backend |
|
53 | + */ |
|
54 | + private $backend; |
|
55 | + |
|
56 | + /** |
|
57 | + * Authentication mechanism |
|
58 | + * |
|
59 | + * @var AuthMechanism |
|
60 | + */ |
|
61 | + private $authMechanism; |
|
62 | + |
|
63 | + /** |
|
64 | + * Backend options |
|
65 | + * |
|
66 | + * @var array |
|
67 | + */ |
|
68 | + private $backendOptions = []; |
|
69 | + |
|
70 | + /** |
|
71 | + * Mount point path, relative to the user's "files" folder |
|
72 | + * |
|
73 | + * @var string |
|
74 | + */ |
|
75 | + private $mountPoint; |
|
76 | + |
|
77 | + /** |
|
78 | + * Storage status |
|
79 | + * |
|
80 | + * @var int |
|
81 | + */ |
|
82 | + private $status; |
|
83 | + |
|
84 | + /** |
|
85 | + * Status message |
|
86 | + * |
|
87 | + * @var string |
|
88 | + */ |
|
89 | + private $statusMessage; |
|
90 | + |
|
91 | + /** |
|
92 | + * Priority |
|
93 | + * |
|
94 | + * @var int |
|
95 | + */ |
|
96 | + private $priority; |
|
97 | + |
|
98 | + /** |
|
99 | + * List of users who have access to this storage |
|
100 | + * |
|
101 | + * @var string[] |
|
102 | + */ |
|
103 | + private $applicableUsers = []; |
|
104 | + |
|
105 | + /** |
|
106 | + * List of groups that have access to this storage |
|
107 | + * |
|
108 | + * @var string[] |
|
109 | + */ |
|
110 | + private $applicableGroups = []; |
|
111 | + |
|
112 | + /** |
|
113 | + * Mount-specific options |
|
114 | + * |
|
115 | + * @var array |
|
116 | + */ |
|
117 | + private $mountOptions = []; |
|
118 | + |
|
119 | + /** |
|
120 | + * Whether it's a personal or admin mount |
|
121 | + * |
|
122 | + * @var int |
|
123 | + */ |
|
124 | + private $type; |
|
125 | + |
|
126 | + /** |
|
127 | + * Creates a storage config |
|
128 | + * |
|
129 | + * @param int|string $id config id or null for a new config |
|
130 | + */ |
|
131 | + public function __construct($id = null) { |
|
132 | + $this->id = $id ?? -1; |
|
133 | + $this->mountOptions['enable_sharing'] = false; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Returns the configuration id |
|
138 | + * |
|
139 | + * @retun int |
|
140 | + */ |
|
141 | + public function getId() { |
|
142 | + return $this->id; |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Sets the configuration id |
|
147 | + * |
|
148 | + * @param int $id configuration id |
|
149 | + */ |
|
150 | + public function setId(int $id): void { |
|
151 | + $this->id = $id; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Returns mount point path relative to the user's |
|
156 | + * "files" folder. |
|
157 | + * |
|
158 | + * @return string path |
|
159 | + */ |
|
160 | + public function getMountPoint() { |
|
161 | + return $this->mountPoint; |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Sets mount point path relative to the user's |
|
166 | + * "files" folder. |
|
167 | + * The path will be normalized. |
|
168 | + * |
|
169 | + * @param string $mountPoint path |
|
170 | + */ |
|
171 | + public function setMountPoint($mountPoint) { |
|
172 | + $this->mountPoint = \OC\Files\Filesystem::normalizePath($mountPoint); |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * @return Backend |
|
177 | + */ |
|
178 | + public function getBackend() { |
|
179 | + return $this->backend; |
|
180 | + } |
|
181 | + |
|
182 | + /** |
|
183 | + * @param Backend $backend |
|
184 | + */ |
|
185 | + public function setBackend(Backend $backend) { |
|
186 | + $this->backend = $backend; |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * @return AuthMechanism |
|
191 | + */ |
|
192 | + public function getAuthMechanism() { |
|
193 | + return $this->authMechanism; |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * @param AuthMechanism $authMechanism |
|
198 | + */ |
|
199 | + public function setAuthMechanism(AuthMechanism $authMechanism) { |
|
200 | + $this->authMechanism = $authMechanism; |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Returns the external storage backend-specific options |
|
205 | + * |
|
206 | + * @return array backend options |
|
207 | + */ |
|
208 | + public function getBackendOptions() { |
|
209 | + return $this->backendOptions; |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * Sets the external storage backend-specific options |
|
214 | + * |
|
215 | + * @param array $backendOptions backend options |
|
216 | + */ |
|
217 | + public function setBackendOptions($backendOptions) { |
|
218 | + if ($this->getBackend() instanceof Backend) { |
|
219 | + $parameters = $this->getBackend()->getParameters(); |
|
220 | + foreach ($backendOptions as $key => $value) { |
|
221 | + if (isset($parameters[$key])) { |
|
222 | + switch ($parameters[$key]->getType()) { |
|
223 | + case \OCA\Files_External\Lib\DefinitionParameter::VALUE_BOOLEAN: |
|
224 | + $value = (bool)$value; |
|
225 | + break; |
|
226 | + } |
|
227 | + $backendOptions[$key] = $value; |
|
228 | + } |
|
229 | + } |
|
230 | + } |
|
231 | + |
|
232 | + $this->backendOptions = $backendOptions; |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * @param string $key |
|
237 | + * @return mixed |
|
238 | + */ |
|
239 | + public function getBackendOption($key) { |
|
240 | + if (isset($this->backendOptions[$key])) { |
|
241 | + return $this->backendOptions[$key]; |
|
242 | + } |
|
243 | + return null; |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * @param string $key |
|
248 | + * @param mixed $value |
|
249 | + */ |
|
250 | + public function setBackendOption($key, $value) { |
|
251 | + $this->backendOptions[$key] = $value; |
|
252 | + } |
|
253 | + |
|
254 | + /** |
|
255 | + * Returns the mount priority |
|
256 | + * |
|
257 | + * @return int priority |
|
258 | + */ |
|
259 | + public function getPriority() { |
|
260 | + return $this->priority; |
|
261 | + } |
|
262 | + |
|
263 | + /** |
|
264 | + * Sets the mount priority |
|
265 | + * |
|
266 | + * @param int $priority priority |
|
267 | + */ |
|
268 | + public function setPriority($priority) { |
|
269 | + $this->priority = $priority; |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | + * Returns the users for which to mount this storage |
|
274 | + * |
|
275 | + * @return string[] applicable users |
|
276 | + */ |
|
277 | + public function getApplicableUsers() { |
|
278 | + return $this->applicableUsers; |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * Sets the users for which to mount this storage |
|
283 | + * |
|
284 | + * @param string[]|null $applicableUsers applicable users |
|
285 | + */ |
|
286 | + public function setApplicableUsers($applicableUsers) { |
|
287 | + if (is_null($applicableUsers)) { |
|
288 | + $applicableUsers = []; |
|
289 | + } |
|
290 | + $this->applicableUsers = $applicableUsers; |
|
291 | + } |
|
292 | + |
|
293 | + /** |
|
294 | + * Returns the groups for which to mount this storage |
|
295 | + * |
|
296 | + * @return string[] applicable groups |
|
297 | + */ |
|
298 | + public function getApplicableGroups() { |
|
299 | + return $this->applicableGroups; |
|
300 | + } |
|
301 | + |
|
302 | + /** |
|
303 | + * Sets the groups for which to mount this storage |
|
304 | + * |
|
305 | + * @param string[]|null $applicableGroups applicable groups |
|
306 | + */ |
|
307 | + public function setApplicableGroups($applicableGroups) { |
|
308 | + if (is_null($applicableGroups)) { |
|
309 | + $applicableGroups = []; |
|
310 | + } |
|
311 | + $this->applicableGroups = $applicableGroups; |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * Returns the mount-specific options |
|
316 | + * |
|
317 | + * @return array mount specific options |
|
318 | + */ |
|
319 | + public function getMountOptions() { |
|
320 | + return $this->mountOptions; |
|
321 | + } |
|
322 | + |
|
323 | + /** |
|
324 | + * Sets the mount-specific options |
|
325 | + * |
|
326 | + * @param array $mountOptions applicable groups |
|
327 | + */ |
|
328 | + public function setMountOptions($mountOptions) { |
|
329 | + if (is_null($mountOptions)) { |
|
330 | + $mountOptions = []; |
|
331 | + } |
|
332 | + $this->mountOptions = $mountOptions; |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * @param string $key |
|
337 | + * @return mixed |
|
338 | + */ |
|
339 | + public function getMountOption($key) { |
|
340 | + if (isset($this->mountOptions[$key])) { |
|
341 | + return $this->mountOptions[$key]; |
|
342 | + } |
|
343 | + return null; |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * @param string $key |
|
348 | + * @param mixed $value |
|
349 | + */ |
|
350 | + public function setMountOption($key, $value) { |
|
351 | + $this->mountOptions[$key] = $value; |
|
352 | + } |
|
353 | + |
|
354 | + /** |
|
355 | + * Gets the storage status, whether the config worked last time |
|
356 | + * |
|
357 | + * @return int $status status |
|
358 | + */ |
|
359 | + public function getStatus() { |
|
360 | + return $this->status; |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * Gets the message describing the storage status |
|
365 | + * |
|
366 | + * @return string|null |
|
367 | + */ |
|
368 | + public function getStatusMessage() { |
|
369 | + return $this->statusMessage; |
|
370 | + } |
|
371 | + |
|
372 | + /** |
|
373 | + * Sets the storage status, whether the config worked last time |
|
374 | + * |
|
375 | + * @param int $status status |
|
376 | + * @param string|null $message optional message |
|
377 | + */ |
|
378 | + public function setStatus($status, $message = null) { |
|
379 | + $this->status = $status; |
|
380 | + $this->statusMessage = $message; |
|
381 | + } |
|
382 | + |
|
383 | + /** |
|
384 | + * @return int self::MOUNT_TYPE_ADMIN or self::MOUNT_TYPE_PERSONAl |
|
385 | + */ |
|
386 | + public function getType() { |
|
387 | + return $this->type; |
|
388 | + } |
|
389 | + |
|
390 | + /** |
|
391 | + * @param int $type self::MOUNT_TYPE_ADMIN or self::MOUNT_TYPE_PERSONAl |
|
392 | + */ |
|
393 | + public function setType($type) { |
|
394 | + $this->type = $type; |
|
395 | + } |
|
396 | + |
|
397 | + /** |
|
398 | + * Serialize config to JSON |
|
399 | + */ |
|
400 | + public function jsonSerialize(): array { |
|
401 | + $result = []; |
|
402 | + if (!is_null($this->id)) { |
|
403 | + $result['id'] = $this->id; |
|
404 | + } |
|
405 | + $result['mountPoint'] = $this->mountPoint; |
|
406 | + $result['backend'] = $this->backend->getIdentifier(); |
|
407 | + $result['authMechanism'] = $this->authMechanism->getIdentifier(); |
|
408 | + $result['backendOptions'] = $this->backendOptions; |
|
409 | + if (!is_null($this->priority)) { |
|
410 | + $result['priority'] = $this->priority; |
|
411 | + } |
|
412 | + if (!empty($this->applicableUsers)) { |
|
413 | + $result['applicableUsers'] = $this->applicableUsers; |
|
414 | + } |
|
415 | + if (!empty($this->applicableGroups)) { |
|
416 | + $result['applicableGroups'] = $this->applicableGroups; |
|
417 | + } |
|
418 | + if (!empty($this->mountOptions)) { |
|
419 | + $result['mountOptions'] = $this->mountOptions; |
|
420 | + } |
|
421 | + if (!is_null($this->status)) { |
|
422 | + $result['status'] = $this->status; |
|
423 | + } |
|
424 | + if (!is_null($this->statusMessage)) { |
|
425 | + $result['statusMessage'] = $this->statusMessage; |
|
426 | + } |
|
427 | + $result['userProvided'] = $this->authMechanism instanceof IUserProvided; |
|
428 | + $result['type'] = ($this->getType() === self::MOUNT_TYPE_PERSONAl) ? 'personal': 'system'; |
|
429 | + return $result; |
|
430 | + } |
|
431 | 431 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
51 | 51 | ]) |
52 | 52 | ->addAuthScheme(AuthMechanism::SCHEME_OPENSTACK) |
53 | - ->setLegacyAuthMechanismCallback(function (array $params) use ($openstackAuth, $rackspaceAuth) { |
|
53 | + ->setLegacyAuthMechanismCallback(function(array $params) use ($openstackAuth, $rackspaceAuth) { |
|
54 | 54 | if (isset($params['options']['key']) && $params['options']['key']) { |
55 | 55 | return $rackspaceAuth; |
56 | 56 | } |
@@ -33,29 +33,29 @@ |
||
33 | 33 | use OCP\IL10N; |
34 | 34 | |
35 | 35 | class Swift extends Backend { |
36 | - use LegacyDependencyCheckPolyfill; |
|
36 | + use LegacyDependencyCheckPolyfill; |
|
37 | 37 | |
38 | - public function __construct(IL10N $l, OpenStackV2 $openstackAuth, Rackspace $rackspaceAuth) { |
|
39 | - $this |
|
40 | - ->setIdentifier('swift') |
|
41 | - ->addIdentifierAlias('\OC\Files\Storage\Swift') // legacy compat |
|
42 | - ->setStorageClass('\OCA\Files_External\Lib\Storage\Swift') |
|
43 | - ->setText($l->t('OpenStack Object Storage')) |
|
44 | - ->addParameters([ |
|
45 | - (new DefinitionParameter('service_name', $l->t('Service name'))) |
|
46 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
47 | - new DefinitionParameter('region', $l->t('Region')), |
|
48 | - new DefinitionParameter('bucket', $l->t('Bucket')), |
|
49 | - (new DefinitionParameter('timeout', $l->t('Request timeout (seconds)'))) |
|
50 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
51 | - ]) |
|
52 | - ->addAuthScheme(AuthMechanism::SCHEME_OPENSTACK) |
|
53 | - ->setLegacyAuthMechanismCallback(function (array $params) use ($openstackAuth, $rackspaceAuth) { |
|
54 | - if (isset($params['options']['key']) && $params['options']['key']) { |
|
55 | - return $rackspaceAuth; |
|
56 | - } |
|
57 | - return $openstackAuth; |
|
58 | - }) |
|
59 | - ; |
|
60 | - } |
|
38 | + public function __construct(IL10N $l, OpenStackV2 $openstackAuth, Rackspace $rackspaceAuth) { |
|
39 | + $this |
|
40 | + ->setIdentifier('swift') |
|
41 | + ->addIdentifierAlias('\OC\Files\Storage\Swift') // legacy compat |
|
42 | + ->setStorageClass('\OCA\Files_External\Lib\Storage\Swift') |
|
43 | + ->setText($l->t('OpenStack Object Storage')) |
|
44 | + ->addParameters([ |
|
45 | + (new DefinitionParameter('service_name', $l->t('Service name'))) |
|
46 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
47 | + new DefinitionParameter('region', $l->t('Region')), |
|
48 | + new DefinitionParameter('bucket', $l->t('Bucket')), |
|
49 | + (new DefinitionParameter('timeout', $l->t('Request timeout (seconds)'))) |
|
50 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
51 | + ]) |
|
52 | + ->addAuthScheme(AuthMechanism::SCHEME_OPENSTACK) |
|
53 | + ->setLegacyAuthMechanismCallback(function (array $params) use ($openstackAuth, $rackspaceAuth) { |
|
54 | + if (isset($params['options']['key']) && $params['options']['key']) { |
|
55 | + return $rackspaceAuth; |
|
56 | + } |
|
57 | + return $openstackAuth; |
|
58 | + }) |
|
59 | + ; |
|
60 | + } |
|
61 | 61 | } |
@@ -36,101 +36,101 @@ |
||
36 | 36 | */ |
37 | 37 | trait VisibilityTrait { |
38 | 38 | |
39 | - /** @var int visibility */ |
|
40 | - protected $visibility = BackendService::VISIBILITY_DEFAULT; |
|
39 | + /** @var int visibility */ |
|
40 | + protected $visibility = BackendService::VISIBILITY_DEFAULT; |
|
41 | 41 | |
42 | - /** @var int allowed visibilities */ |
|
43 | - protected $allowedVisibility = BackendService::VISIBILITY_DEFAULT; |
|
42 | + /** @var int allowed visibilities */ |
|
43 | + protected $allowedVisibility = BackendService::VISIBILITY_DEFAULT; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return int |
|
47 | - */ |
|
48 | - public function getVisibility() { |
|
49 | - return $this->visibility; |
|
50 | - } |
|
45 | + /** |
|
46 | + * @return int |
|
47 | + */ |
|
48 | + public function getVisibility() { |
|
49 | + return $this->visibility; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Check if the backend is visible for a user type |
|
54 | - * |
|
55 | - * @param int $visibility |
|
56 | - * @return bool |
|
57 | - */ |
|
58 | - public function isVisibleFor($visibility) { |
|
59 | - if ($this->visibility & $visibility) { |
|
60 | - return true; |
|
61 | - } |
|
62 | - return false; |
|
63 | - } |
|
52 | + /** |
|
53 | + * Check if the backend is visible for a user type |
|
54 | + * |
|
55 | + * @param int $visibility |
|
56 | + * @return bool |
|
57 | + */ |
|
58 | + public function isVisibleFor($visibility) { |
|
59 | + if ($this->visibility & $visibility) { |
|
60 | + return true; |
|
61 | + } |
|
62 | + return false; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @param int $visibility |
|
67 | - * @return self |
|
68 | - */ |
|
69 | - public function setVisibility($visibility) { |
|
70 | - $this->visibility = $visibility; |
|
71 | - $this->allowedVisibility |= $visibility; |
|
72 | - return $this; |
|
73 | - } |
|
65 | + /** |
|
66 | + * @param int $visibility |
|
67 | + * @return self |
|
68 | + */ |
|
69 | + public function setVisibility($visibility) { |
|
70 | + $this->visibility = $visibility; |
|
71 | + $this->allowedVisibility |= $visibility; |
|
72 | + return $this; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @param int $visibility |
|
77 | - * @return self |
|
78 | - */ |
|
79 | - public function addVisibility($visibility) { |
|
80 | - return $this->setVisibility($this->visibility | $visibility); |
|
81 | - } |
|
75 | + /** |
|
76 | + * @param int $visibility |
|
77 | + * @return self |
|
78 | + */ |
|
79 | + public function addVisibility($visibility) { |
|
80 | + return $this->setVisibility($this->visibility | $visibility); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @param int $visibility |
|
85 | - * @return self |
|
86 | - */ |
|
87 | - public function removeVisibility($visibility) { |
|
88 | - return $this->setVisibility($this->visibility & ~$visibility); |
|
89 | - } |
|
83 | + /** |
|
84 | + * @param int $visibility |
|
85 | + * @return self |
|
86 | + */ |
|
87 | + public function removeVisibility($visibility) { |
|
88 | + return $this->setVisibility($this->visibility & ~$visibility); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * @return int |
|
93 | - */ |
|
94 | - public function getAllowedVisibility() { |
|
95 | - return $this->allowedVisibility; |
|
96 | - } |
|
91 | + /** |
|
92 | + * @return int |
|
93 | + */ |
|
94 | + public function getAllowedVisibility() { |
|
95 | + return $this->allowedVisibility; |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Check if the backend is allowed to be visible for a user type |
|
100 | - * |
|
101 | - * @param int $allowedVisibility |
|
102 | - * @return bool |
|
103 | - */ |
|
104 | - public function isAllowedVisibleFor($allowedVisibility) { |
|
105 | - if ($this->allowedVisibility & $allowedVisibility) { |
|
106 | - return true; |
|
107 | - } |
|
108 | - return false; |
|
109 | - } |
|
98 | + /** |
|
99 | + * Check if the backend is allowed to be visible for a user type |
|
100 | + * |
|
101 | + * @param int $allowedVisibility |
|
102 | + * @return bool |
|
103 | + */ |
|
104 | + public function isAllowedVisibleFor($allowedVisibility) { |
|
105 | + if ($this->allowedVisibility & $allowedVisibility) { |
|
106 | + return true; |
|
107 | + } |
|
108 | + return false; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * @param int $allowedVisibility |
|
113 | - * @return self |
|
114 | - */ |
|
115 | - public function setAllowedVisibility($allowedVisibility) { |
|
116 | - $this->allowedVisibility = $allowedVisibility; |
|
117 | - $this->visibility &= $allowedVisibility; |
|
118 | - return $this; |
|
119 | - } |
|
111 | + /** |
|
112 | + * @param int $allowedVisibility |
|
113 | + * @return self |
|
114 | + */ |
|
115 | + public function setAllowedVisibility($allowedVisibility) { |
|
116 | + $this->allowedVisibility = $allowedVisibility; |
|
117 | + $this->visibility &= $allowedVisibility; |
|
118 | + return $this; |
|
119 | + } |
|
120 | 120 | |
121 | - /** |
|
122 | - * @param int $allowedVisibility |
|
123 | - * @return self |
|
124 | - */ |
|
125 | - public function addAllowedVisibility($allowedVisibility) { |
|
126 | - return $this->setAllowedVisibility($this->allowedVisibility | $allowedVisibility); |
|
127 | - } |
|
121 | + /** |
|
122 | + * @param int $allowedVisibility |
|
123 | + * @return self |
|
124 | + */ |
|
125 | + public function addAllowedVisibility($allowedVisibility) { |
|
126 | + return $this->setAllowedVisibility($this->allowedVisibility | $allowedVisibility); |
|
127 | + } |
|
128 | 128 | |
129 | - /** |
|
130 | - * @param int $allowedVisibility |
|
131 | - * @return self |
|
132 | - */ |
|
133 | - public function removeAllowedVisibility($allowedVisibility) { |
|
134 | - return $this->setAllowedVisibility($this->allowedVisibility & ~$allowedVisibility); |
|
135 | - } |
|
129 | + /** |
|
130 | + * @param int $allowedVisibility |
|
131 | + * @return self |
|
132 | + */ |
|
133 | + public function removeAllowedVisibility($allowedVisibility) { |
|
134 | + return $this->setAllowedVisibility($this->allowedVisibility & ~$allowedVisibility); |
|
135 | + } |
|
136 | 136 | } |
@@ -28,11 +28,11 @@ |
||
28 | 28 | * Builtin authentication mechanism, for legacy backends |
29 | 29 | */ |
30 | 30 | class Builtin extends AuthMechanism { |
31 | - public function __construct(IL10N $l) { |
|
32 | - $this |
|
33 | - ->setIdentifier('builtin::builtin') |
|
34 | - ->setScheme(self::SCHEME_BUILTIN) |
|
35 | - ->setText($l->t('Builtin')) |
|
36 | - ; |
|
37 | - } |
|
31 | + public function __construct(IL10N $l) { |
|
32 | + $this |
|
33 | + ->setIdentifier('builtin::builtin') |
|
34 | + ->setScheme(self::SCHEME_BUILTIN) |
|
35 | + ->setText($l->t('Builtin')) |
|
36 | + ; |
|
37 | + } |
|
38 | 38 | } |
@@ -28,11 +28,11 @@ |
||
28 | 28 | * Null authentication mechanism |
29 | 29 | */ |
30 | 30 | class NullMechanism extends AuthMechanism { |
31 | - public function __construct(IL10N $l) { |
|
32 | - $this |
|
33 | - ->setIdentifier('null::null') |
|
34 | - ->setScheme(self::SCHEME_NULL) |
|
35 | - ->setText($l->t('None')) |
|
36 | - ; |
|
37 | - } |
|
31 | + public function __construct(IL10N $l) { |
|
32 | + $this |
|
33 | + ->setIdentifier('null::null') |
|
34 | + ->setScheme(self::SCHEME_NULL) |
|
35 | + ->setText($l->t('None')) |
|
36 | + ; |
|
37 | + } |
|
38 | 38 | } |
@@ -41,48 +41,48 @@ |
||
41 | 41 | $is_optional = $parameter->isFlagSet(DefinitionParameter::FLAG_OPTIONAL); |
42 | 42 | |
43 | 43 | switch ($parameter->getType()) { |
44 | - case DefinitionParameter::VALUE_PASSWORD: ?> |
|
45 | - <?php if ($is_optional) { |
|
46 | - $classes[] = 'optional'; |
|
47 | - } ?> |
|
48 | - <input type="password" |
|
44 | + case DefinitionParameter::VALUE_PASSWORD: ?> |
|
45 | + <?php if ($is_optional) { |
|
46 | + $classes[] = 'optional'; |
|
47 | + } ?> |
|
48 | + <input type="password" |
|
49 | 49 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
50 | - data-parameter="<?php p($parameter->getName()); ?>" |
|
50 | + data-parameter="<?php p($parameter->getName()); ?>" |
|
51 | 51 | value="<?php p($value); ?>" |
52 | 52 | placeholder="<?php p($placeholder); ?>" |
53 | 53 | /> |
54 | 54 | <?php |
55 | - break; |
|
56 | - case DefinitionParameter::VALUE_BOOLEAN: ?> |
|
57 | - <?php $checkboxId = uniqid("checkbox_"); ?> |
|
55 | + break; |
|
56 | + case DefinitionParameter::VALUE_BOOLEAN: ?> |
|
57 | + <?php $checkboxId = uniqid("checkbox_"); ?> |
|
58 | 58 | <div> |
59 | 59 | <label> |
60 | 60 | <input type="checkbox" |
61 | 61 | id="<?php p($checkboxId); ?>" |
62 | 62 | <?php if (!empty($classes)): ?> class="checkbox <?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
63 | - data-parameter="<?php p($parameter->getName()); ?>" |
|
63 | + data-parameter="<?php p($parameter->getName()); ?>" |
|
64 | 64 | <?php if ($value === true): ?> checked="checked"<?php endif; ?> |
65 | - /> |
|
65 | + /> |
|
66 | 66 | <?php p($placeholder); ?> |
67 | 67 | </label> |
68 | 68 | </div> |
69 | 69 | <?php |
70 | - break; |
|
71 | - case DefinitionParameter::VALUE_HIDDEN: ?> |
|
72 | - <input type="hidden" |
|
70 | + break; |
|
71 | + case DefinitionParameter::VALUE_HIDDEN: ?> |
|
72 | + <input type="hidden" |
|
73 | 73 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
74 | - data-parameter="<?php p($parameter->getName()); ?>" |
|
74 | + data-parameter="<?php p($parameter->getName()); ?>" |
|
75 | 75 | value="<?php p($value); ?>" |
76 | 76 | /> |
77 | 77 | <?php |
78 | - break; |
|
79 | - default: ?> |
|
80 | - <?php if ($is_optional) { |
|
81 | - $classes[] = 'optional'; |
|
82 | - } ?> |
|
83 | - <input type="text" |
|
78 | + break; |
|
79 | + default: ?> |
|
80 | + <?php if ($is_optional) { |
|
81 | + $classes[] = 'optional'; |
|
82 | + } ?> |
|
83 | + <input type="text" |
|
84 | 84 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
85 | - data-parameter="<?php p($parameter->getName()); ?>" |
|
85 | + data-parameter="<?php p($parameter->getName()); ?>" |
|
86 | 86 | value="<?php p($value); ?>" |
87 | 87 | placeholder="<?php p($placeholder); ?>" |
88 | 88 | /> |
@@ -194,8 +194,11 @@ |
||
194 | 194 | <?php $i = 0; foreach ($userBackends as $backend): ?> |
195 | 195 | <?php if ($deprecateTo = $backend->getDeprecateTo()): ?> |
196 | 196 | <input type="hidden" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" data-deprecate-to="<?php p($deprecateTo->getIdentifier()); ?>" /> |
197 | - <?php else: ?> |
|
198 | - <input type="checkbox" id="allowUserMountingBackends<?php p($i); ?>" class="checkbox" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" <?php if ($backend->isVisibleFor(BackendService::VISIBILITY_PERSONAL)) { |
|
197 | + <?php else { |
|
198 | + : ?> |
|
199 | + <input type="checkbox" id="allowUserMountingBackends<?php p($i); |
|
200 | +} |
|
201 | +?>" class="checkbox" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" <?php if ($backend->isVisibleFor(BackendService::VISIBILITY_PERSONAL)) { |
|
199 | 202 | print_unescaped(' checked="checked"'); |
200 | 203 | } ?> /> |
201 | 204 | <label for="allowUserMountingBackends<?php p($i); ?>"><?php p($backend->getText()); ?></label> <br /> |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | <?php |
104 | 104 | $canCreateNewLocalStorage = \OC::$server->getConfig()->getSystemValue('files_external_allow_create_new_local', true); |
105 | 105 | ?> |
106 | -<form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" data-can-create-local="<?php echo $canCreateNewLocalStorage?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>"> |
|
106 | +<form data-can-create="<?php echo $canCreateMounts ? 'true' : 'false' ?>" data-can-create-local="<?php echo $canCreateNewLocalStorage ? 'true' : 'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled'] ? 'true' : 'false'; ?>"> |
|
107 | 107 | <h2 class="inlineblock" data-anchor-name="external-storage"><?php p($l->t('External storage')); ?></h2> |
108 | - <a target="_blank" rel="noreferrer" class="icon-info" title="<?php p($l->t('Open documentation'));?>" href="<?php p(link_to_docs('admin-external-storage')); ?>"></a> |
|
108 | + <a target="_blank" rel="noreferrer" class="icon-info" title="<?php p($l->t('Open documentation')); ?>" href="<?php p(link_to_docs('admin-external-storage')); ?>"></a> |
|
109 | 109 | <p class="settings-hint"><?php p($l->t('External storage enables you to mount external storage services and devices as secondary Nextcloud storage devices. You may also allow users to mount their own external storage services.')); ?></p> |
110 | 110 | <?php if (isset($_['dependencies']) and ($_['dependencies'] !== '') and $canCreateMounts) { |
111 | 111 | print_unescaped(''.$_['dependencies'].''); |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | <?php p($l->t('Add storage')); ?> |
151 | 151 | </option> |
152 | 152 | <?php |
153 | - $sortedBackends = array_filter($_['backends'], function ($backend) use ($_) { |
|
153 | + $sortedBackends = array_filter($_['backends'], function($backend) use ($_) { |
|
154 | 154 | return $backend->isVisibleFor($_['visibilityType']); |
155 | 155 | }); |
156 | - uasort($sortedBackends, function ($a, $b) { |
|
156 | + uasort($sortedBackends, function($a, $b) { |
|
157 | 157 | return strcasecmp($a->getText(), $b->getText()); |
158 | 158 | }); |
159 | 159 | ?> |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | <p id="userMountingBackends"<?php if (!$_['allowUserMounting']): ?> class="hidden"<?php endif; ?>> |
194 | 194 | <?php |
195 | - $userBackends = array_filter($_['backends'], function ($backend) { |
|
195 | + $userBackends = array_filter($_['backends'], function($backend) { |
|
196 | 196 | return $backend->isAllowedVisibleFor(BackendService::VISIBILITY_PERSONAL); |
197 | 197 | }); |
198 | 198 | ?> |
@@ -8,49 +8,49 @@ discard block |
||
8 | 8 | |
9 | 9 | $canCreateMounts = $_['visibilityType'] === BackendService::VISIBILITY_ADMIN || $_['allowUserMounting']; |
10 | 10 | |
11 | - $l->t("Enable encryption"); |
|
12 | - $l->t("Enable previews"); |
|
13 | - $l->t("Enable sharing"); |
|
14 | - $l->t("Check for changes"); |
|
15 | - $l->t("Never"); |
|
16 | - $l->t("Once every direct access"); |
|
17 | - $l->t('Read only'); |
|
11 | + $l->t("Enable encryption"); |
|
12 | + $l->t("Enable previews"); |
|
13 | + $l->t("Enable sharing"); |
|
14 | + $l->t("Check for changes"); |
|
15 | + $l->t("Never"); |
|
16 | + $l->t("Once every direct access"); |
|
17 | + $l->t('Read only'); |
|
18 | 18 | |
19 | - script('files_external', [ |
|
20 | - 'settings', |
|
21 | - 'templates' |
|
22 | - ]); |
|
23 | - style('files_external', 'settings'); |
|
19 | + script('files_external', [ |
|
20 | + 'settings', |
|
21 | + 'templates' |
|
22 | + ]); |
|
23 | + style('files_external', 'settings'); |
|
24 | 24 | |
25 | - // load custom JS |
|
26 | - foreach ($_['backends'] as $backend) { |
|
27 | - /** @var Backend $backend */ |
|
28 | - $scripts = $backend->getCustomJs(); |
|
29 | - foreach ($scripts as $script) { |
|
30 | - script('files_external', $script); |
|
31 | - } |
|
32 | - } |
|
33 | - foreach ($_['authMechanisms'] as $authMechanism) { |
|
34 | - /** @var AuthMechanism $authMechanism */ |
|
35 | - $scripts = $authMechanism->getCustomJs(); |
|
36 | - foreach ($scripts as $script) { |
|
37 | - script('files_external', $script); |
|
38 | - } |
|
39 | - } |
|
25 | + // load custom JS |
|
26 | + foreach ($_['backends'] as $backend) { |
|
27 | + /** @var Backend $backend */ |
|
28 | + $scripts = $backend->getCustomJs(); |
|
29 | + foreach ($scripts as $script) { |
|
30 | + script('files_external', $script); |
|
31 | + } |
|
32 | + } |
|
33 | + foreach ($_['authMechanisms'] as $authMechanism) { |
|
34 | + /** @var AuthMechanism $authMechanism */ |
|
35 | + $scripts = $authMechanism->getCustomJs(); |
|
36 | + foreach ($scripts as $script) { |
|
37 | + script('files_external', $script); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - function writeParameterInput($parameter, $options, $classes = []) { |
|
42 | - $value = ''; |
|
43 | - if (isset($options[$parameter->getName()])) { |
|
44 | - $value = $options[$parameter->getName()]; |
|
45 | - } |
|
46 | - $placeholder = $parameter->getText(); |
|
47 | - $is_optional = $parameter->isFlagSet(DefinitionParameter::FLAG_OPTIONAL); |
|
41 | + function writeParameterInput($parameter, $options, $classes = []) { |
|
42 | + $value = ''; |
|
43 | + if (isset($options[$parameter->getName()])) { |
|
44 | + $value = $options[$parameter->getName()]; |
|
45 | + } |
|
46 | + $placeholder = $parameter->getText(); |
|
47 | + $is_optional = $parameter->isFlagSet(DefinitionParameter::FLAG_OPTIONAL); |
|
48 | 48 | |
49 | - switch ($parameter->getType()) { |
|
50 | - case DefinitionParameter::VALUE_PASSWORD: ?> |
|
49 | + switch ($parameter->getType()) { |
|
50 | + case DefinitionParameter::VALUE_PASSWORD: ?> |
|
51 | 51 | <?php if ($is_optional) { |
52 | - $classes[] = 'optional'; |
|
53 | - } ?> |
|
52 | + $classes[] = 'optional'; |
|
53 | + } ?> |
|
54 | 54 | <input type="password" |
55 | 55 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
56 | 56 | data-parameter="<?php p($parameter->getName()); ?>" |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | placeholder="<?php p($placeholder); ?>" |
59 | 59 | /> |
60 | 60 | <?php |
61 | - break; |
|
62 | - case DefinitionParameter::VALUE_BOOLEAN: ?> |
|
61 | + break; |
|
62 | + case DefinitionParameter::VALUE_BOOLEAN: ?> |
|
63 | 63 | <?php $checkboxId = uniqid("checkbox_"); ?> |
64 | 64 | <div> |
65 | 65 | <label> |
@@ -73,19 +73,19 @@ discard block |
||
73 | 73 | </label> |
74 | 74 | </div> |
75 | 75 | <?php |
76 | - break; |
|
77 | - case DefinitionParameter::VALUE_HIDDEN: ?> |
|
76 | + break; |
|
77 | + case DefinitionParameter::VALUE_HIDDEN: ?> |
|
78 | 78 | <input type="hidden" |
79 | 79 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
80 | 80 | data-parameter="<?php p($parameter->getName()); ?>" |
81 | 81 | value="<?php p($value); ?>" |
82 | 82 | /> |
83 | 83 | <?php |
84 | - break; |
|
85 | - default: ?> |
|
84 | + break; |
|
85 | + default: ?> |
|
86 | 86 | <?php if ($is_optional) { |
87 | - $classes[] = 'optional'; |
|
88 | - } ?> |
|
87 | + $classes[] = 'optional'; |
|
88 | + } ?> |
|
89 | 89 | <input type="text" |
90 | 90 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
91 | 91 | data-parameter="<?php p($parameter->getName()); ?>" |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | placeholder="<?php p($placeholder); ?>" |
94 | 94 | /> |
95 | 95 | <?php |
96 | - } |
|
97 | - } |
|
96 | + } |
|
97 | + } |
|
98 | 98 | ?> |
99 | 99 | |
100 | 100 | <div class="emptyfilelist emptycontent hidden"> |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | </div> |
104 | 104 | |
105 | 105 | <?php |
106 | - $canCreateNewLocalStorage = \OC::$server->getConfig()->getSystemValue('files_external_allow_create_new_local', true); |
|
106 | + $canCreateNewLocalStorage = \OC::$server->getConfig()->getSystemValue('files_external_allow_create_new_local', true); |
|
107 | 107 | ?> |
108 | 108 | <form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" data-can-create-local="<?php echo $canCreateNewLocalStorage?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>"> |
109 | 109 | <h2 class="inlineblock" data-anchor-name="external-storage"><?php p($l->t('External storage')); ?></h2> |
110 | 110 | <a target="_blank" rel="noreferrer" class="icon-info" title="<?php p($l->t('Open documentation'));?>" href="<?php p(link_to_docs('admin-external-storage')); ?>"></a> |
111 | 111 | <p class="settings-hint"><?php p($l->t('External storage enables you to mount external storage services and devices as secondary Nextcloud storage devices. You may also allow users to mount their own external storage services.')); ?></p> |
112 | 112 | <?php if (isset($_['dependencies']) and ($_['dependencies'] !== '') and $canCreateMounts) { |
113 | - print_unescaped(''.$_['dependencies'].''); |
|
113 | + print_unescaped(''.$_['dependencies'].''); |
|
114 | 114 | } ?> |
115 | 115 | <table id="externalStorage" class="grid" data-admin='<?php print_unescaped(json_encode($_['visibilityType'] === BackendService::VISIBILITY_ADMIN)); ?>'> |
116 | 116 | <thead> |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | <th><?php p($l->t('Authentication')); ?></th> |
122 | 122 | <th><?php p($l->t('Configuration')); ?></th> |
123 | 123 | <?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN) { |
124 | - print_unescaped('<th>'.$l->t('Available for').'</th>'); |
|
124 | + print_unescaped('<th>'.$l->t('Available for').'</th>'); |
|
125 | 125 | } ?> |
126 | 126 | <th> </th> |
127 | 127 | <th> </th> |
@@ -152,17 +152,17 @@ discard block |
||
152 | 152 | <?php p($l->t('Add storage')); ?> |
153 | 153 | </option> |
154 | 154 | <?php |
155 | - $sortedBackends = array_filter($_['backends'], function ($backend) use ($_) { |
|
156 | - return $backend->isVisibleFor($_['visibilityType']); |
|
157 | - }); |
|
158 | - uasort($sortedBackends, function ($a, $b) { |
|
159 | - return strcasecmp($a->getText(), $b->getText()); |
|
160 | - }); |
|
161 | - ?> |
|
155 | + $sortedBackends = array_filter($_['backends'], function ($backend) use ($_) { |
|
156 | + return $backend->isVisibleFor($_['visibilityType']); |
|
157 | + }); |
|
158 | + uasort($sortedBackends, function ($a, $b) { |
|
159 | + return strcasecmp($a->getText(), $b->getText()); |
|
160 | + }); |
|
161 | + ?> |
|
162 | 162 | <?php foreach ($sortedBackends as $backend): ?> |
163 | 163 | <?php if ($backend->getDeprecateTo() || (!$canCreateNewLocalStorage && $backend->getIdentifier() == "local")) { |
164 | - continue; |
|
165 | - } // ignore deprecated backends?> |
|
164 | + continue; |
|
165 | + } // ignore deprecated backends?> |
|
166 | 166 | <option value="<?php p($backend->getIdentifier()); ?>"><?php p($backend->getText()); ?></option> |
167 | 167 | <?php endforeach; ?> |
168 | 168 | </select> |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | <?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN): ?> |
189 | 189 | <input type="checkbox" name="allowUserMounting" id="allowUserMounting" class="checkbox" |
190 | 190 | value="1" <?php if ($_['allowUserMounting']) { |
191 | - print_unescaped(' checked="checked"'); |
|
192 | - } ?> /> |
|
191 | + print_unescaped(' checked="checked"'); |
|
192 | + } ?> /> |
|
193 | 193 | <label for="allowUserMounting"><?php p($l->t('Allow users to mount external storage')); ?></label> <span id="userMountingMsg" class="msg"></span> |
194 | 194 | |
195 | 195 | <p id="userMountingBackends"<?php if (!$_['allowUserMounting']): ?> class="hidden"<?php endif; ?>> |
196 | 196 | <?php |
197 | - $userBackends = array_filter($_['backends'], function ($backend) { |
|
198 | - return $backend->isAllowedVisibleFor(BackendService::VISIBILITY_PERSONAL); |
|
199 | - }); |
|
200 | - ?> |
|
197 | + $userBackends = array_filter($_['backends'], function ($backend) { |
|
198 | + return $backend->isAllowedVisibleFor(BackendService::VISIBILITY_PERSONAL); |
|
199 | + }); |
|
200 | + ?> |
|
201 | 201 | <?php $i = 0; foreach ($userBackends as $backend): ?> |
202 | 202 | <?php if ($deprecateTo = $backend->getDeprecateTo()): ?> |
203 | 203 | <input type="hidden" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" data-deprecate-to="<?php p($deprecateTo->getIdentifier()); ?>" /> |
204 | 204 | <?php else: ?> |
205 | 205 | <input type="checkbox" id="allowUserMountingBackends<?php p($i); ?>" class="checkbox" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" <?php if ($backend->isVisibleFor(BackendService::VISIBILITY_PERSONAL)) { |
206 | - print_unescaped(' checked="checked"'); |
|
207 | - } ?> /> |
|
206 | + print_unescaped(' checked="checked"'); |
|
207 | + } ?> /> |
|
208 | 208 | <label for="allowUserMountingBackends<?php p($i); ?>"><?php p($backend->getText()); ?></label> <br /> |
209 | 209 | <?php endif; ?> |
210 | 210 | <?php $i++; ?> |