@@ -100,7 +100,7 @@ |
||
100 | 100 | |
101 | 101 | // casted to string because cast to float cause equality for non equal numbers |
102 | 102 | // and integer has the problem of limited size on 32 bit systems |
103 | - if ((string)$expectedSize !== (string)$actualSize) { |
|
103 | + if ((string) $expectedSize !== (string) $actualSize) { |
|
104 | 104 | throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize bytes"); |
105 | 105 | } |
106 | 106 | } |
@@ -35,97 +35,97 @@ |
||
35 | 35 | |
36 | 36 | class ChunkingPlugin extends ServerPlugin { |
37 | 37 | |
38 | - /** @var Server */ |
|
39 | - private $server; |
|
40 | - /** @var FutureFile */ |
|
41 | - private $sourceNode; |
|
38 | + /** @var Server */ |
|
39 | + private $server; |
|
40 | + /** @var FutureFile */ |
|
41 | + private $sourceNode; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @inheritdoc |
|
45 | - */ |
|
46 | - public function initialize(Server $server) { |
|
47 | - $server->on('beforeMove', [$this, 'beforeMove']); |
|
48 | - $this->server = $server; |
|
49 | - } |
|
43 | + /** |
|
44 | + * @inheritdoc |
|
45 | + */ |
|
46 | + public function initialize(Server $server) { |
|
47 | + $server->on('beforeMove', [$this, 'beforeMove']); |
|
48 | + $this->server = $server; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param string $sourcePath source path |
|
53 | - * @param string $destination destination path |
|
54 | - * @return bool|void |
|
55 | - * @throws BadRequest |
|
56 | - * @throws NotFound |
|
57 | - */ |
|
58 | - public function beforeMove($sourcePath, $destination) { |
|
59 | - $this->sourceNode = $this->server->tree->getNodeForPath($sourcePath); |
|
60 | - if (!$this->sourceNode instanceof FutureFile) { |
|
61 | - // skip handling as the source is not a chunked FutureFile |
|
62 | - return; |
|
63 | - } |
|
51 | + /** |
|
52 | + * @param string $sourcePath source path |
|
53 | + * @param string $destination destination path |
|
54 | + * @return bool|void |
|
55 | + * @throws BadRequest |
|
56 | + * @throws NotFound |
|
57 | + */ |
|
58 | + public function beforeMove($sourcePath, $destination) { |
|
59 | + $this->sourceNode = $this->server->tree->getNodeForPath($sourcePath); |
|
60 | + if (!$this->sourceNode instanceof FutureFile) { |
|
61 | + // skip handling as the source is not a chunked FutureFile |
|
62 | + return; |
|
63 | + } |
|
64 | 64 | |
65 | - try { |
|
66 | - /** @var INode $destinationNode */ |
|
67 | - $destinationNode = $this->server->tree->getNodeForPath($destination); |
|
68 | - if ($destinationNode instanceof Directory) { |
|
69 | - throw new BadRequest("The given destination $destination is a directory."); |
|
70 | - } |
|
71 | - } catch (NotFound $e) { |
|
72 | - // If the destination does not exist yet it's not a directory either ;) |
|
73 | - } |
|
65 | + try { |
|
66 | + /** @var INode $destinationNode */ |
|
67 | + $destinationNode = $this->server->tree->getNodeForPath($destination); |
|
68 | + if ($destinationNode instanceof Directory) { |
|
69 | + throw new BadRequest("The given destination $destination is a directory."); |
|
70 | + } |
|
71 | + } catch (NotFound $e) { |
|
72 | + // If the destination does not exist yet it's not a directory either ;) |
|
73 | + } |
|
74 | 74 | |
75 | - $this->verifySize(); |
|
76 | - return $this->performMove($sourcePath, $destination); |
|
77 | - } |
|
75 | + $this->verifySize(); |
|
76 | + return $this->performMove($sourcePath, $destination); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Move handler for future file. |
|
81 | - * |
|
82 | - * This overrides the default move behavior to prevent Sabre |
|
83 | - * to delete the target file before moving. Because deleting would |
|
84 | - * lose the file id and metadata. |
|
85 | - * |
|
86 | - * @param string $path source path |
|
87 | - * @param string $destination destination path |
|
88 | - * @return bool|void false to stop handling, void to skip this handler |
|
89 | - */ |
|
90 | - public function performMove($path, $destination) { |
|
91 | - $fileExists = $this->server->tree->nodeExists($destination); |
|
92 | - // do a move manually, skipping Sabre's default "delete" for existing nodes |
|
93 | - try { |
|
94 | - $this->server->tree->move($path, $destination); |
|
95 | - } catch (Forbidden $e) { |
|
96 | - $sourceNode = $this->server->tree->getNodeForPath($path); |
|
97 | - if ($sourceNode instanceof FutureFile) { |
|
98 | - $sourceNode->delete(); |
|
99 | - } |
|
100 | - throw $e; |
|
101 | - } |
|
79 | + /** |
|
80 | + * Move handler for future file. |
|
81 | + * |
|
82 | + * This overrides the default move behavior to prevent Sabre |
|
83 | + * to delete the target file before moving. Because deleting would |
|
84 | + * lose the file id and metadata. |
|
85 | + * |
|
86 | + * @param string $path source path |
|
87 | + * @param string $destination destination path |
|
88 | + * @return bool|void false to stop handling, void to skip this handler |
|
89 | + */ |
|
90 | + public function performMove($path, $destination) { |
|
91 | + $fileExists = $this->server->tree->nodeExists($destination); |
|
92 | + // do a move manually, skipping Sabre's default "delete" for existing nodes |
|
93 | + try { |
|
94 | + $this->server->tree->move($path, $destination); |
|
95 | + } catch (Forbidden $e) { |
|
96 | + $sourceNode = $this->server->tree->getNodeForPath($path); |
|
97 | + if ($sourceNode instanceof FutureFile) { |
|
98 | + $sourceNode->delete(); |
|
99 | + } |
|
100 | + throw $e; |
|
101 | + } |
|
102 | 102 | |
103 | - // trigger all default events (copied from CorePlugin::move) |
|
104 | - $this->server->emit('afterMove', [$path, $destination]); |
|
105 | - $this->server->emit('afterUnbind', [$path]); |
|
106 | - $this->server->emit('afterBind', [$destination]); |
|
103 | + // trigger all default events (copied from CorePlugin::move) |
|
104 | + $this->server->emit('afterMove', [$path, $destination]); |
|
105 | + $this->server->emit('afterUnbind', [$path]); |
|
106 | + $this->server->emit('afterBind', [$destination]); |
|
107 | 107 | |
108 | - $response = $this->server->httpResponse; |
|
109 | - $response->setHeader('Content-Length', '0'); |
|
110 | - $response->setStatus($fileExists ? 204 : 201); |
|
108 | + $response = $this->server->httpResponse; |
|
109 | + $response->setHeader('Content-Length', '0'); |
|
110 | + $response->setStatus($fileExists ? 204 : 201); |
|
111 | 111 | |
112 | - return false; |
|
113 | - } |
|
112 | + return false; |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * @throws BadRequest |
|
117 | - */ |
|
118 | - private function verifySize() { |
|
119 | - $expectedSize = $this->server->httpRequest->getHeader('OC-Total-Length'); |
|
120 | - if ($expectedSize === null) { |
|
121 | - return; |
|
122 | - } |
|
123 | - $actualSize = $this->sourceNode->getSize(); |
|
115 | + /** |
|
116 | + * @throws BadRequest |
|
117 | + */ |
|
118 | + private function verifySize() { |
|
119 | + $expectedSize = $this->server->httpRequest->getHeader('OC-Total-Length'); |
|
120 | + if ($expectedSize === null) { |
|
121 | + return; |
|
122 | + } |
|
123 | + $actualSize = $this->sourceNode->getSize(); |
|
124 | 124 | |
125 | - // casted to string because cast to float cause equality for non equal numbers |
|
126 | - // and integer has the problem of limited size on 32 bit systems |
|
127 | - if ((string)$expectedSize !== (string)$actualSize) { |
|
128 | - throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize bytes"); |
|
129 | - } |
|
130 | - } |
|
125 | + // casted to string because cast to float cause equality for non equal numbers |
|
126 | + // and integer has the problem of limited size on 32 bit systems |
|
127 | + if ((string)$expectedSize !== (string)$actualSize) { |
|
128 | + throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize bytes"); |
|
129 | + } |
|
130 | + } |
|
131 | 131 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | \OC_JSON::checkAppEnabled('user_ldap'); |
30 | 30 | \OC_JSON::callCheck(); |
31 | 31 | |
32 | -$prefix = (string)$_POST['ldap_serverconfig_chooser']; |
|
32 | +$prefix = (string) $_POST['ldap_serverconfig_chooser']; |
|
33 | 33 | $ldapWrapper = new OCA\User_LDAP\LDAP(); |
34 | 34 | $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); |
35 | 35 | $configuration = $connection->getConfiguration(); |
@@ -35,7 +35,7 @@ |
||
35 | 35 | $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); |
36 | 36 | $configuration = $connection->getConfiguration(); |
37 | 37 | if (isset($configuration['ldap_agent_password']) && $configuration['ldap_agent_password'] !== '') { |
38 | - // hide password |
|
39 | - $configuration['ldap_agent_password'] = '**PASSWORD SET**'; |
|
38 | + // hide password |
|
39 | + $configuration['ldap_agent_password'] = '**PASSWORD SET**'; |
|
40 | 40 | } |
41 | 41 | \OC_JSON::success(['configuration' => $configuration]); |
@@ -51,16 +51,16 @@ |
||
51 | 51 | * @since 14.0.0 |
52 | 52 | */ |
53 | 53 | public function render(): string { |
54 | - return '<li>' . |
|
55 | - '<a id="directLink-container">' . |
|
56 | - '<span class="icon ' . Util::sanitizeHTML($this->getIcon()) . '"></span>' . |
|
57 | - '<label for="directLink">' . Util::sanitizeHTML($this->getLabel()) . '</label>' . |
|
58 | - '</a>' . |
|
59 | - '</li>' . |
|
60 | - '<li>' . |
|
61 | - '<span class="menuitem">' . |
|
62 | - '<input id="directLink" type="text" readonly="" value="' . Util::sanitizeHTML($this->getLink()) . '">' . |
|
63 | - '</span>' . |
|
54 | + return '<li>'. |
|
55 | + '<a id="directLink-container">'. |
|
56 | + '<span class="icon '.Util::sanitizeHTML($this->getIcon()).'"></span>'. |
|
57 | + '<label for="directLink">'.Util::sanitizeHTML($this->getLabel()).'</label>'. |
|
58 | + '</a>'. |
|
59 | + '</li>'. |
|
60 | + '<li>'. |
|
61 | + '<span class="menuitem">'. |
|
62 | + '<input id="directLink" type="text" readonly="" value="'.Util::sanitizeHTML($this->getLink()).'">'. |
|
63 | + '</span>'. |
|
64 | 64 | '</li>'; |
65 | 65 | } |
66 | 66 | } |
@@ -31,33 +31,33 @@ |
||
31 | 31 | * @since 14.0.0 |
32 | 32 | */ |
33 | 33 | class LinkMenuAction extends SimpleMenuAction { |
34 | - /** |
|
35 | - * LinkMenuAction constructor. |
|
36 | - * |
|
37 | - * @param string $label |
|
38 | - * @param string $icon |
|
39 | - * @param string $link |
|
40 | - * @since 14.0.0 |
|
41 | - */ |
|
42 | - public function __construct(string $label, string $icon, string $link) { |
|
43 | - parent::__construct('directLink-container', $label, $icon, $link); |
|
44 | - } |
|
34 | + /** |
|
35 | + * LinkMenuAction constructor. |
|
36 | + * |
|
37 | + * @param string $label |
|
38 | + * @param string $icon |
|
39 | + * @param string $link |
|
40 | + * @since 14.0.0 |
|
41 | + */ |
|
42 | + public function __construct(string $label, string $icon, string $link) { |
|
43 | + parent::__construct('directLink-container', $label, $icon, $link); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @return string |
|
48 | - * @since 14.0.0 |
|
49 | - */ |
|
50 | - public function render(): string { |
|
51 | - return '<li>' . |
|
52 | - '<a id="directLink-container">' . |
|
53 | - '<span class="icon ' . Util::sanitizeHTML($this->getIcon()) . '"></span>' . |
|
54 | - '<label for="directLink">' . Util::sanitizeHTML($this->getLabel()) . '</label>' . |
|
55 | - '</a>' . |
|
56 | - '</li>' . |
|
57 | - '<li>' . |
|
58 | - '<span class="menuitem">' . |
|
59 | - '<input id="directLink" type="text" readonly="" value="' . Util::sanitizeHTML($this->getLink()) . '">' . |
|
60 | - '</span>' . |
|
61 | - '</li>'; |
|
62 | - } |
|
46 | + /** |
|
47 | + * @return string |
|
48 | + * @since 14.0.0 |
|
49 | + */ |
|
50 | + public function render(): string { |
|
51 | + return '<li>' . |
|
52 | + '<a id="directLink-container">' . |
|
53 | + '<span class="icon ' . Util::sanitizeHTML($this->getIcon()) . '"></span>' . |
|
54 | + '<label for="directLink">' . Util::sanitizeHTML($this->getLabel()) . '</label>' . |
|
55 | + '</a>' . |
|
56 | + '</li>' . |
|
57 | + '<li>' . |
|
58 | + '<span class="menuitem">' . |
|
59 | + '<input id="directLink" type="text" readonly="" value="' . Util::sanitizeHTML($this->getLink()) . '">' . |
|
60 | + '</span>' . |
|
61 | + '</li>'; |
|
62 | + } |
|
63 | 63 | } |
@@ -30,30 +30,30 @@ |
||
30 | 30 | * Delete the admin|personal sections and settings tables |
31 | 31 | */ |
32 | 32 | class Version14000Date20180129121024 extends SimpleMigrationStep { |
33 | - public function name(): string { |
|
34 | - return 'Drop obsolete settings tables'; |
|
35 | - } |
|
33 | + public function name(): string { |
|
34 | + return 'Drop obsolete settings tables'; |
|
35 | + } |
|
36 | 36 | |
37 | - public function description(): string { |
|
38 | - return 'Drops the following obsolete tables: "admin_sections", "admin_settings", "personal_sections" and "personal_settings"'; |
|
39 | - } |
|
37 | + public function description(): string { |
|
38 | + return 'Drops the following obsolete tables: "admin_sections", "admin_settings", "personal_sections" and "personal_settings"'; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param IOutput $output |
|
43 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
44 | - * @param array $options |
|
45 | - * @return null|ISchemaWrapper |
|
46 | - * @since 13.0.0 |
|
47 | - */ |
|
48 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
49 | - /** @var ISchemaWrapper $schema */ |
|
50 | - $schema = $schemaClosure(); |
|
41 | + /** |
|
42 | + * @param IOutput $output |
|
43 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
44 | + * @param array $options |
|
45 | + * @return null|ISchemaWrapper |
|
46 | + * @since 13.0.0 |
|
47 | + */ |
|
48 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
49 | + /** @var ISchemaWrapper $schema */ |
|
50 | + $schema = $schemaClosure(); |
|
51 | 51 | |
52 | - $schema->dropTable('admin_sections'); |
|
53 | - $schema->dropTable('admin_settings'); |
|
54 | - $schema->dropTable('personal_sections'); |
|
55 | - $schema->dropTable('personal_settings'); |
|
52 | + $schema->dropTable('admin_sections'); |
|
53 | + $schema->dropTable('admin_settings'); |
|
54 | + $schema->dropTable('personal_sections'); |
|
55 | + $schema->dropTable('personal_settings'); |
|
56 | 56 | |
57 | - return $schema; |
|
58 | - } |
|
57 | + return $schema; |
|
58 | + } |
|
59 | 59 | } |
@@ -25,9 +25,9 @@ |
||
25 | 25 | namespace OCA\DAV\Direct; |
26 | 26 | |
27 | 27 | class Server extends \Sabre\DAV\Server { |
28 | - public function __construct($treeOrNode = null) { |
|
29 | - parent::__construct($treeOrNode); |
|
30 | - self::$exposeVersion = false; |
|
31 | - $this->enablePropfindDepthInfinityf = false; |
|
32 | - } |
|
28 | + public function __construct($treeOrNode = null) { |
|
29 | + parent::__construct($treeOrNode); |
|
30 | + self::$exposeVersion = false; |
|
31 | + $this->enablePropfindDepthInfinityf = false; |
|
32 | + } |
|
33 | 33 | } |
@@ -37,22 +37,22 @@ |
||
37 | 37 | * @method void setExpiration(int $expiration) |
38 | 38 | */ |
39 | 39 | class Direct extends Entity { |
40 | - /** @var string */ |
|
41 | - protected $userId; |
|
40 | + /** @var string */ |
|
41 | + protected $userId; |
|
42 | 42 | |
43 | - /** @var int */ |
|
44 | - protected $fileId; |
|
43 | + /** @var int */ |
|
44 | + protected $fileId; |
|
45 | 45 | |
46 | - /** @var string */ |
|
47 | - protected $token; |
|
46 | + /** @var string */ |
|
47 | + protected $token; |
|
48 | 48 | |
49 | - /** @var int */ |
|
50 | - protected $expiration; |
|
49 | + /** @var int */ |
|
50 | + protected $expiration; |
|
51 | 51 | |
52 | - public function __construct() { |
|
53 | - $this->addType('userId', 'string'); |
|
54 | - $this->addType('fileId', 'int'); |
|
55 | - $this->addType('token', 'string'); |
|
56 | - $this->addType('expiration', 'int'); |
|
57 | - } |
|
52 | + public function __construct() { |
|
53 | + $this->addType('userId', 'string'); |
|
54 | + $this->addType('fileId', 'int'); |
|
55 | + $this->addType('token', 'string'); |
|
56 | + $this->addType('expiration', 'int'); |
|
57 | + } |
|
58 | 58 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ) { |
59 | 59 | $backend = $this->backendService->getBackend($storageOptions['backend']); |
60 | 60 | if (!$backend) { |
61 | - throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']); |
|
61 | + throw new \UnexpectedValueException('Invalid backend '.$storageOptions['backend']); |
|
62 | 62 | } |
63 | 63 | $storageConfig->setBackend($backend); |
64 | 64 | if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $storageOptions['authMechanism'] = 'null'; // to make error handling easier |
69 | 69 | } |
70 | 70 | if (!$authMechanism) { |
71 | - throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']); |
|
71 | + throw new \UnexpectedValueException('Invalid authentication mechanism '.$storageOptions['authMechanism']); |
|
72 | 72 | } |
73 | 73 | $storageConfig->setAuthMechanism($authMechanism); |
74 | 74 | $storageConfig->setBackendOptions($storageOptions['options']); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $parts = explode('/', ltrim($rootMountPath, '/'), 3); |
141 | 141 | if (count($parts) < 3) { |
142 | 142 | // something went wrong, skip |
143 | - \OC::$server->getLogger()->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']); |
|
143 | + \OC::$server->getLogger()->error('Could not parse mount point "'.$rootMountPath.'"', ['app' => 'files_external']); |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | $relativeMountPath = rtrim($parts[2], '/'); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $storageOptions['authMechanism'] = null; // ensure config hash works |
155 | 155 | } |
156 | 156 | if (isset($storageOptions['id'])) { |
157 | - $configId = (int)$storageOptions['id']; |
|
157 | + $configId = (int) $storageOptions['id']; |
|
158 | 158 | if (isset($storages[$configId])) { |
159 | 159 | $currentStorage = $storages[$configId]; |
160 | 160 | } |
@@ -33,179 +33,179 @@ |
||
33 | 33 | * Read mount config from legacy mount.json |
34 | 34 | */ |
35 | 35 | abstract class LegacyStoragesService { |
36 | - /** @var BackendService */ |
|
37 | - protected $backendService; |
|
36 | + /** @var BackendService */ |
|
37 | + protected $backendService; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Read legacy config data |
|
41 | - * |
|
42 | - * @return array list of mount configs |
|
43 | - */ |
|
44 | - abstract protected function readLegacyConfig(); |
|
39 | + /** |
|
40 | + * Read legacy config data |
|
41 | + * |
|
42 | + * @return array list of mount configs |
|
43 | + */ |
|
44 | + abstract protected function readLegacyConfig(); |
|
45 | 45 | |
46 | - /** |
|
47 | - * Copy legacy storage options into the given storage config object. |
|
48 | - * |
|
49 | - * @param StorageConfig $storageConfig storage config to populate |
|
50 | - * @param string $mountType mount type |
|
51 | - * @param string $applicable applicable user or group |
|
52 | - * @param array $storageOptions legacy storage options |
|
53 | - * |
|
54 | - * @return StorageConfig populated storage config |
|
55 | - */ |
|
56 | - protected function populateStorageConfigWithLegacyOptions( |
|
57 | - &$storageConfig, |
|
58 | - $mountType, |
|
59 | - $applicable, |
|
60 | - $storageOptions |
|
61 | - ) { |
|
62 | - $backend = $this->backendService->getBackend($storageOptions['backend']); |
|
63 | - if (!$backend) { |
|
64 | - throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']); |
|
65 | - } |
|
66 | - $storageConfig->setBackend($backend); |
|
67 | - if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') { |
|
68 | - $authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']); |
|
69 | - } else { |
|
70 | - $authMechanism = $backend->getLegacyAuthMechanism($storageOptions); |
|
71 | - $storageOptions['authMechanism'] = 'null'; // to make error handling easier |
|
72 | - } |
|
73 | - if (!$authMechanism) { |
|
74 | - throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']); |
|
75 | - } |
|
76 | - $storageConfig->setAuthMechanism($authMechanism); |
|
77 | - $storageConfig->setBackendOptions($storageOptions['options']); |
|
78 | - if (isset($storageOptions['mountOptions'])) { |
|
79 | - $storageConfig->setMountOptions($storageOptions['mountOptions']); |
|
80 | - } |
|
81 | - if (!isset($storageOptions['priority'])) { |
|
82 | - $storageOptions['priority'] = $backend->getPriority(); |
|
83 | - } |
|
84 | - $storageConfig->setPriority($storageOptions['priority']); |
|
85 | - if ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_USER) { |
|
86 | - $applicableUsers = $storageConfig->getApplicableUsers(); |
|
87 | - if ($applicable !== 'all') { |
|
88 | - $applicableUsers[] = $applicable; |
|
89 | - $storageConfig->setApplicableUsers($applicableUsers); |
|
90 | - } |
|
91 | - } elseif ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP) { |
|
92 | - $applicableGroups = $storageConfig->getApplicableGroups(); |
|
93 | - $applicableGroups[] = $applicable; |
|
94 | - $storageConfig->setApplicableGroups($applicableGroups); |
|
95 | - } |
|
96 | - return $storageConfig; |
|
97 | - } |
|
46 | + /** |
|
47 | + * Copy legacy storage options into the given storage config object. |
|
48 | + * |
|
49 | + * @param StorageConfig $storageConfig storage config to populate |
|
50 | + * @param string $mountType mount type |
|
51 | + * @param string $applicable applicable user or group |
|
52 | + * @param array $storageOptions legacy storage options |
|
53 | + * |
|
54 | + * @return StorageConfig populated storage config |
|
55 | + */ |
|
56 | + protected function populateStorageConfigWithLegacyOptions( |
|
57 | + &$storageConfig, |
|
58 | + $mountType, |
|
59 | + $applicable, |
|
60 | + $storageOptions |
|
61 | + ) { |
|
62 | + $backend = $this->backendService->getBackend($storageOptions['backend']); |
|
63 | + if (!$backend) { |
|
64 | + throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']); |
|
65 | + } |
|
66 | + $storageConfig->setBackend($backend); |
|
67 | + if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') { |
|
68 | + $authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']); |
|
69 | + } else { |
|
70 | + $authMechanism = $backend->getLegacyAuthMechanism($storageOptions); |
|
71 | + $storageOptions['authMechanism'] = 'null'; // to make error handling easier |
|
72 | + } |
|
73 | + if (!$authMechanism) { |
|
74 | + throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']); |
|
75 | + } |
|
76 | + $storageConfig->setAuthMechanism($authMechanism); |
|
77 | + $storageConfig->setBackendOptions($storageOptions['options']); |
|
78 | + if (isset($storageOptions['mountOptions'])) { |
|
79 | + $storageConfig->setMountOptions($storageOptions['mountOptions']); |
|
80 | + } |
|
81 | + if (!isset($storageOptions['priority'])) { |
|
82 | + $storageOptions['priority'] = $backend->getPriority(); |
|
83 | + } |
|
84 | + $storageConfig->setPriority($storageOptions['priority']); |
|
85 | + if ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_USER) { |
|
86 | + $applicableUsers = $storageConfig->getApplicableUsers(); |
|
87 | + if ($applicable !== 'all') { |
|
88 | + $applicableUsers[] = $applicable; |
|
89 | + $storageConfig->setApplicableUsers($applicableUsers); |
|
90 | + } |
|
91 | + } elseif ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP) { |
|
92 | + $applicableGroups = $storageConfig->getApplicableGroups(); |
|
93 | + $applicableGroups[] = $applicable; |
|
94 | + $storageConfig->setApplicableGroups($applicableGroups); |
|
95 | + } |
|
96 | + return $storageConfig; |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Read the external storage config |
|
101 | - * |
|
102 | - * @return StorageConfig[] map of storage id to storage config |
|
103 | - */ |
|
104 | - public function getAllStorages() { |
|
105 | - $mountPoints = $this->readLegacyConfig(); |
|
106 | - /** |
|
107 | - * Here is the how the horribly messy mount point array looks like |
|
108 | - * from the mount.json file: |
|
109 | - * |
|
110 | - * $storageOptions = $mountPoints[$mountType][$applicable][$mountPath] |
|
111 | - * |
|
112 | - * - $mountType is either "user" or "group" |
|
113 | - * - $applicable is the name of a user or group (or the current user for personal mounts) |
|
114 | - * - $mountPath is the mount point path (where the storage must be mounted) |
|
115 | - * - $storageOptions is a map of storage options: |
|
116 | - * - "priority": storage priority |
|
117 | - * - "backend": backend identifier |
|
118 | - * - "class": LEGACY backend class name |
|
119 | - * - "options": backend-specific options |
|
120 | - * - "authMechanism": authentication mechanism identifier |
|
121 | - * - "mountOptions": mount-specific options (ex: disable previews, scanner, etc) |
|
122 | - */ |
|
123 | - // group by storage id |
|
124 | - /** @var StorageConfig[] $storages */ |
|
125 | - $storages = []; |
|
126 | - // for storages without id (legacy), group by config hash for |
|
127 | - // later processing |
|
128 | - $storagesWithConfigHash = []; |
|
129 | - foreach ($mountPoints as $mountType => $applicables) { |
|
130 | - foreach ($applicables as $applicable => $mountPaths) { |
|
131 | - foreach ($mountPaths as $rootMountPath => $storageOptions) { |
|
132 | - $currentStorage = null; |
|
133 | - /** |
|
134 | - * Flag whether the config that was read already has an id. |
|
135 | - * If not, it will use a config hash instead and generate |
|
136 | - * a proper id later |
|
137 | - * |
|
138 | - * @var boolean |
|
139 | - */ |
|
140 | - $hasId = false; |
|
141 | - // the root mount point is in the format "/$user/files/the/mount/point" |
|
142 | - // we remove the "/$user/files" prefix |
|
143 | - $parts = explode('/', ltrim($rootMountPath, '/'), 3); |
|
144 | - if (count($parts) < 3) { |
|
145 | - // something went wrong, skip |
|
146 | - \OC::$server->getLogger()->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']); |
|
147 | - continue; |
|
148 | - } |
|
149 | - $relativeMountPath = rtrim($parts[2], '/'); |
|
150 | - // note: we cannot do this after the loop because the decrypted config |
|
151 | - // options might be needed for the config hash |
|
152 | - $storageOptions['options'] = \OCA\Files_External\MountConfig::decryptPasswords($storageOptions['options']); |
|
153 | - if (!isset($storageOptions['backend'])) { |
|
154 | - $storageOptions['backend'] = $storageOptions['class']; // legacy compat |
|
155 | - } |
|
156 | - if (!isset($storageOptions['authMechanism'])) { |
|
157 | - $storageOptions['authMechanism'] = null; // ensure config hash works |
|
158 | - } |
|
159 | - if (isset($storageOptions['id'])) { |
|
160 | - $configId = (int)$storageOptions['id']; |
|
161 | - if (isset($storages[$configId])) { |
|
162 | - $currentStorage = $storages[$configId]; |
|
163 | - } |
|
164 | - $hasId = true; |
|
165 | - } else { |
|
166 | - // missing id in legacy config, need to generate |
|
167 | - // but at this point we don't know the max-id, so use |
|
168 | - // first group it by config hash |
|
169 | - $storageOptions['mountpoint'] = $rootMountPath; |
|
170 | - $configId = \OCA\Files_External\MountConfig::makeConfigHash($storageOptions); |
|
171 | - if (isset($storagesWithConfigHash[$configId])) { |
|
172 | - $currentStorage = $storagesWithConfigHash[$configId]; |
|
173 | - } |
|
174 | - } |
|
175 | - if (is_null($currentStorage)) { |
|
176 | - // create new |
|
177 | - $currentStorage = new StorageConfig($configId); |
|
178 | - $currentStorage->setMountPoint($relativeMountPath); |
|
179 | - } |
|
180 | - try { |
|
181 | - $this->populateStorageConfigWithLegacyOptions( |
|
182 | - $currentStorage, |
|
183 | - $mountType, |
|
184 | - $applicable, |
|
185 | - $storageOptions |
|
186 | - ); |
|
187 | - if ($hasId) { |
|
188 | - $storages[$configId] = $currentStorage; |
|
189 | - } else { |
|
190 | - $storagesWithConfigHash[$configId] = $currentStorage; |
|
191 | - } |
|
192 | - } catch (\UnexpectedValueException $e) { |
|
193 | - // don't die if a storage backend doesn't exist |
|
194 | - \OC::$server->getLogger()->logException($e, [ |
|
195 | - 'message' => 'Could not load storage.', |
|
196 | - 'level' => ILogger::ERROR, |
|
197 | - 'app' => 'files_external', |
|
198 | - ]); |
|
199 | - } |
|
200 | - } |
|
201 | - } |
|
202 | - } |
|
99 | + /** |
|
100 | + * Read the external storage config |
|
101 | + * |
|
102 | + * @return StorageConfig[] map of storage id to storage config |
|
103 | + */ |
|
104 | + public function getAllStorages() { |
|
105 | + $mountPoints = $this->readLegacyConfig(); |
|
106 | + /** |
|
107 | + * Here is the how the horribly messy mount point array looks like |
|
108 | + * from the mount.json file: |
|
109 | + * |
|
110 | + * $storageOptions = $mountPoints[$mountType][$applicable][$mountPath] |
|
111 | + * |
|
112 | + * - $mountType is either "user" or "group" |
|
113 | + * - $applicable is the name of a user or group (or the current user for personal mounts) |
|
114 | + * - $mountPath is the mount point path (where the storage must be mounted) |
|
115 | + * - $storageOptions is a map of storage options: |
|
116 | + * - "priority": storage priority |
|
117 | + * - "backend": backend identifier |
|
118 | + * - "class": LEGACY backend class name |
|
119 | + * - "options": backend-specific options |
|
120 | + * - "authMechanism": authentication mechanism identifier |
|
121 | + * - "mountOptions": mount-specific options (ex: disable previews, scanner, etc) |
|
122 | + */ |
|
123 | + // group by storage id |
|
124 | + /** @var StorageConfig[] $storages */ |
|
125 | + $storages = []; |
|
126 | + // for storages without id (legacy), group by config hash for |
|
127 | + // later processing |
|
128 | + $storagesWithConfigHash = []; |
|
129 | + foreach ($mountPoints as $mountType => $applicables) { |
|
130 | + foreach ($applicables as $applicable => $mountPaths) { |
|
131 | + foreach ($mountPaths as $rootMountPath => $storageOptions) { |
|
132 | + $currentStorage = null; |
|
133 | + /** |
|
134 | + * Flag whether the config that was read already has an id. |
|
135 | + * If not, it will use a config hash instead and generate |
|
136 | + * a proper id later |
|
137 | + * |
|
138 | + * @var boolean |
|
139 | + */ |
|
140 | + $hasId = false; |
|
141 | + // the root mount point is in the format "/$user/files/the/mount/point" |
|
142 | + // we remove the "/$user/files" prefix |
|
143 | + $parts = explode('/', ltrim($rootMountPath, '/'), 3); |
|
144 | + if (count($parts) < 3) { |
|
145 | + // something went wrong, skip |
|
146 | + \OC::$server->getLogger()->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']); |
|
147 | + continue; |
|
148 | + } |
|
149 | + $relativeMountPath = rtrim($parts[2], '/'); |
|
150 | + // note: we cannot do this after the loop because the decrypted config |
|
151 | + // options might be needed for the config hash |
|
152 | + $storageOptions['options'] = \OCA\Files_External\MountConfig::decryptPasswords($storageOptions['options']); |
|
153 | + if (!isset($storageOptions['backend'])) { |
|
154 | + $storageOptions['backend'] = $storageOptions['class']; // legacy compat |
|
155 | + } |
|
156 | + if (!isset($storageOptions['authMechanism'])) { |
|
157 | + $storageOptions['authMechanism'] = null; // ensure config hash works |
|
158 | + } |
|
159 | + if (isset($storageOptions['id'])) { |
|
160 | + $configId = (int)$storageOptions['id']; |
|
161 | + if (isset($storages[$configId])) { |
|
162 | + $currentStorage = $storages[$configId]; |
|
163 | + } |
|
164 | + $hasId = true; |
|
165 | + } else { |
|
166 | + // missing id in legacy config, need to generate |
|
167 | + // but at this point we don't know the max-id, so use |
|
168 | + // first group it by config hash |
|
169 | + $storageOptions['mountpoint'] = $rootMountPath; |
|
170 | + $configId = \OCA\Files_External\MountConfig::makeConfigHash($storageOptions); |
|
171 | + if (isset($storagesWithConfigHash[$configId])) { |
|
172 | + $currentStorage = $storagesWithConfigHash[$configId]; |
|
173 | + } |
|
174 | + } |
|
175 | + if (is_null($currentStorage)) { |
|
176 | + // create new |
|
177 | + $currentStorage = new StorageConfig($configId); |
|
178 | + $currentStorage->setMountPoint($relativeMountPath); |
|
179 | + } |
|
180 | + try { |
|
181 | + $this->populateStorageConfigWithLegacyOptions( |
|
182 | + $currentStorage, |
|
183 | + $mountType, |
|
184 | + $applicable, |
|
185 | + $storageOptions |
|
186 | + ); |
|
187 | + if ($hasId) { |
|
188 | + $storages[$configId] = $currentStorage; |
|
189 | + } else { |
|
190 | + $storagesWithConfigHash[$configId] = $currentStorage; |
|
191 | + } |
|
192 | + } catch (\UnexpectedValueException $e) { |
|
193 | + // don't die if a storage backend doesn't exist |
|
194 | + \OC::$server->getLogger()->logException($e, [ |
|
195 | + 'message' => 'Could not load storage.', |
|
196 | + 'level' => ILogger::ERROR, |
|
197 | + 'app' => 'files_external', |
|
198 | + ]); |
|
199 | + } |
|
200 | + } |
|
201 | + } |
|
202 | + } |
|
203 | 203 | |
204 | - // convert parameter values |
|
205 | - foreach ($storages as $storage) { |
|
206 | - $storage->getBackend()->validateStorageDefinition($storage); |
|
207 | - $storage->getAuthMechanism()->validateStorageDefinition($storage); |
|
208 | - } |
|
209 | - return $storages; |
|
210 | - } |
|
204 | + // convert parameter values |
|
205 | + foreach ($storages as $storage) { |
|
206 | + $storage->getBackend()->validateStorageDefinition($storage); |
|
207 | + $storage->getAuthMechanism()->validateStorageDefinition($storage); |
|
208 | + } |
|
209 | + return $storages; |
|
210 | + } |
|
211 | 211 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | */ |
63 | 63 | public function addEntityCollection(string $name, \Closure $entityExistsFunction) { |
64 | 64 | if (isset($this->collections[$name])) { |
65 | - throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
65 | + throw new \OutOfBoundsException('Duplicate entity name "'.$name.'"'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $this->collections[$name] = $entityExistsFunction; |
@@ -35,49 +35,49 @@ |
||
35 | 35 | * @since 9.1.0 |
36 | 36 | */ |
37 | 37 | class SystemTagsEntityEvent extends Event { |
38 | - /** |
|
39 | - * @deprecated 22.0.0 |
|
40 | - */ |
|
41 | - public const EVENT_ENTITY = 'OCP\SystemTag\ISystemTagManager::registerEntity'; |
|
38 | + /** |
|
39 | + * @deprecated 22.0.0 |
|
40 | + */ |
|
41 | + public const EVENT_ENTITY = 'OCP\SystemTag\ISystemTagManager::registerEntity'; |
|
42 | 42 | |
43 | - /** @var string */ |
|
44 | - protected $event; |
|
45 | - /** @var \Closure[] */ |
|
46 | - protected $collections; |
|
43 | + /** @var string */ |
|
44 | + protected $event; |
|
45 | + /** @var \Closure[] */ |
|
46 | + protected $collections; |
|
47 | 47 | |
48 | - /** |
|
49 | - * SystemTagsEntityEvent constructor. |
|
50 | - * |
|
51 | - * @param string $event |
|
52 | - * @since 9.1.0 |
|
53 | - */ |
|
54 | - public function __construct(string $event) { |
|
55 | - $this->event = $event; |
|
56 | - $this->collections = []; |
|
57 | - } |
|
48 | + /** |
|
49 | + * SystemTagsEntityEvent constructor. |
|
50 | + * |
|
51 | + * @param string $event |
|
52 | + * @since 9.1.0 |
|
53 | + */ |
|
54 | + public function __construct(string $event) { |
|
55 | + $this->event = $event; |
|
56 | + $this->collections = []; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @param string $name |
|
61 | - * @param \Closure $entityExistsFunction The closure should take one |
|
62 | - * argument, which is the id of the entity, that tags |
|
63 | - * should be handled for. The return should then be bool, |
|
64 | - * depending on whether tags are allowed (true) or not. |
|
65 | - * @throws \OutOfBoundsException when the entity name is already taken |
|
66 | - * @since 9.1.0 |
|
67 | - */ |
|
68 | - public function addEntityCollection(string $name, \Closure $entityExistsFunction) { |
|
69 | - if (isset($this->collections[$name])) { |
|
70 | - throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
71 | - } |
|
59 | + /** |
|
60 | + * @param string $name |
|
61 | + * @param \Closure $entityExistsFunction The closure should take one |
|
62 | + * argument, which is the id of the entity, that tags |
|
63 | + * should be handled for. The return should then be bool, |
|
64 | + * depending on whether tags are allowed (true) or not. |
|
65 | + * @throws \OutOfBoundsException when the entity name is already taken |
|
66 | + * @since 9.1.0 |
|
67 | + */ |
|
68 | + public function addEntityCollection(string $name, \Closure $entityExistsFunction) { |
|
69 | + if (isset($this->collections[$name])) { |
|
70 | + throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
71 | + } |
|
72 | 72 | |
73 | - $this->collections[$name] = $entityExistsFunction; |
|
74 | - } |
|
73 | + $this->collections[$name] = $entityExistsFunction; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @return \Closure[] |
|
78 | - * @since 9.1.0 |
|
79 | - */ |
|
80 | - public function getEntityCollections(): array { |
|
81 | - return $this->collections; |
|
82 | - } |
|
76 | + /** |
|
77 | + * @return \Closure[] |
|
78 | + * @since 9.1.0 |
|
79 | + */ |
|
80 | + public function getEntityCollections(): array { |
|
81 | + return $this->collections; |
|
82 | + } |
|
83 | 83 | } |
@@ -67,6 +67,6 @@ |
||
67 | 67 | $implements |= Backend::COUNT_USERS; |
68 | 68 | } |
69 | 69 | |
70 | - return (bool)($actions & $implements); |
|
70 | + return (bool) ($actions & $implements); |
|
71 | 71 | } |
72 | 72 | } |
@@ -34,41 +34,41 @@ |
||
34 | 34 | * @since 14.0.0 |
35 | 35 | */ |
36 | 36 | abstract class ABackend implements IUserBackend, UserInterface { |
37 | - /** |
|
38 | - * @deprecated 14.0.0 |
|
39 | - * @since 14.0.0 |
|
40 | - * |
|
41 | - * @param int $actions The action to check for |
|
42 | - * @return bool |
|
43 | - */ |
|
44 | - public function implementsActions($actions): bool { |
|
45 | - $implements = 0; |
|
37 | + /** |
|
38 | + * @deprecated 14.0.0 |
|
39 | + * @since 14.0.0 |
|
40 | + * |
|
41 | + * @param int $actions The action to check for |
|
42 | + * @return bool |
|
43 | + */ |
|
44 | + public function implementsActions($actions): bool { |
|
45 | + $implements = 0; |
|
46 | 46 | |
47 | - if ($this instanceof ICreateUserBackend) { |
|
48 | - $implements |= Backend::CREATE_USER; |
|
49 | - } |
|
50 | - if ($this instanceof ISetPasswordBackend) { |
|
51 | - $implements |= Backend::SET_PASSWORD; |
|
52 | - } |
|
53 | - if ($this instanceof ICheckPasswordBackend) { |
|
54 | - $implements |= Backend::CHECK_PASSWORD; |
|
55 | - } |
|
56 | - if ($this instanceof IGetHomeBackend) { |
|
57 | - $implements |= Backend::GET_HOME; |
|
58 | - } |
|
59 | - if ($this instanceof IGetDisplayNameBackend) { |
|
60 | - $implements |= Backend::GET_DISPLAYNAME; |
|
61 | - } |
|
62 | - if ($this instanceof ISetDisplayNameBackend) { |
|
63 | - $implements |= Backend::SET_DISPLAYNAME; |
|
64 | - } |
|
65 | - if ($this instanceof IProvideAvatarBackend) { |
|
66 | - $implements |= Backend::PROVIDE_AVATAR; |
|
67 | - } |
|
68 | - if ($this instanceof ICountUsersBackend) { |
|
69 | - $implements |= Backend::COUNT_USERS; |
|
70 | - } |
|
47 | + if ($this instanceof ICreateUserBackend) { |
|
48 | + $implements |= Backend::CREATE_USER; |
|
49 | + } |
|
50 | + if ($this instanceof ISetPasswordBackend) { |
|
51 | + $implements |= Backend::SET_PASSWORD; |
|
52 | + } |
|
53 | + if ($this instanceof ICheckPasswordBackend) { |
|
54 | + $implements |= Backend::CHECK_PASSWORD; |
|
55 | + } |
|
56 | + if ($this instanceof IGetHomeBackend) { |
|
57 | + $implements |= Backend::GET_HOME; |
|
58 | + } |
|
59 | + if ($this instanceof IGetDisplayNameBackend) { |
|
60 | + $implements |= Backend::GET_DISPLAYNAME; |
|
61 | + } |
|
62 | + if ($this instanceof ISetDisplayNameBackend) { |
|
63 | + $implements |= Backend::SET_DISPLAYNAME; |
|
64 | + } |
|
65 | + if ($this instanceof IProvideAvatarBackend) { |
|
66 | + $implements |= Backend::PROVIDE_AVATAR; |
|
67 | + } |
|
68 | + if ($this instanceof ICountUsersBackend) { |
|
69 | + $implements |= Backend::COUNT_USERS; |
|
70 | + } |
|
71 | 71 | |
72 | - return (bool)($actions & $implements); |
|
73 | - } |
|
72 | + return (bool)($actions & $implements); |
|
73 | + } |
|
74 | 74 | } |