@@ -29,11 +29,11 @@ |
||
29 | 29 | */ |
30 | 30 | interface IProvideAvatarBackend { |
31 | 31 | |
32 | - /** |
|
33 | - * @since 14.0.0 |
|
34 | - * |
|
35 | - * @param string $uid |
|
36 | - * @return bool |
|
37 | - */ |
|
38 | - public function canChangeAvatar(string $uid): bool; |
|
32 | + /** |
|
33 | + * @since 14.0.0 |
|
34 | + * |
|
35 | + * @param string $uid |
|
36 | + * @return bool |
|
37 | + */ |
|
38 | + public function canChangeAvatar(string $uid): bool; |
|
39 | 39 | } |
@@ -31,10 +31,10 @@ |
||
31 | 31 | */ |
32 | 32 | interface IProvidesCustomCSP { |
33 | 33 | |
34 | - /** |
|
35 | - * @return ContentSecurityPolicy |
|
36 | - * |
|
37 | - * @since 13.0.0 |
|
38 | - */ |
|
39 | - public function getCSP(): ContentSecurityPolicy; |
|
34 | + /** |
|
35 | + * @return ContentSecurityPolicy |
|
36 | + * |
|
37 | + * @since 13.0.0 |
|
38 | + */ |
|
39 | + public function getCSP(): ContentSecurityPolicy; |
|
40 | 40 | } |
@@ -34,33 +34,33 @@ |
||
34 | 34 | */ |
35 | 35 | class LinkMenuAction extends SimpleMenuAction { |
36 | 36 | |
37 | - /** |
|
38 | - * LinkMenuAction constructor. |
|
39 | - * |
|
40 | - * @param string $label |
|
41 | - * @param string $icon |
|
42 | - * @param string $link |
|
43 | - * @since 14.0.0 |
|
44 | - */ |
|
45 | - public function __construct(string $label, string $icon, string $link) { |
|
46 | - parent::__construct('directLink-container', $label, $icon, $link); |
|
47 | - } |
|
37 | + /** |
|
38 | + * LinkMenuAction constructor. |
|
39 | + * |
|
40 | + * @param string $label |
|
41 | + * @param string $icon |
|
42 | + * @param string $link |
|
43 | + * @since 14.0.0 |
|
44 | + */ |
|
45 | + public function __construct(string $label, string $icon, string $link) { |
|
46 | + parent::__construct('directLink-container', $label, $icon, $link); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return string |
|
51 | - * @since 14.0.0 |
|
52 | - */ |
|
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>' . |
|
64 | - '</li>'; |
|
65 | - } |
|
49 | + /** |
|
50 | + * @return string |
|
51 | + * @since 14.0.0 |
|
52 | + */ |
|
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>' . |
|
64 | + '</li>'; |
|
65 | + } |
|
66 | 66 | } |
@@ -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 | } |
@@ -35,18 +35,18 @@ |
||
35 | 35 | */ |
36 | 36 | interface IDiscoveryService { |
37 | 37 | |
38 | - /** |
|
39 | - * Discover OCS end-points |
|
40 | - * |
|
41 | - * If no valid discovery data is found the defaults are returned |
|
42 | - * |
|
43 | - * @since 12.0.0 |
|
44 | - * |
|
45 | - * @param string $remote |
|
46 | - * @param string $service the service you want to discover |
|
47 | - * @param bool $skipCache We won't check if the data is in the cache. This is useful if a background job is updating the status - Added in 14.0.0 |
|
48 | - * @return array |
|
49 | - */ |
|
50 | - public function discover(string $remote, string $service, bool $skipCache = false): array; |
|
38 | + /** |
|
39 | + * Discover OCS end-points |
|
40 | + * |
|
41 | + * If no valid discovery data is found the defaults are returned |
|
42 | + * |
|
43 | + * @since 12.0.0 |
|
44 | + * |
|
45 | + * @param string $remote |
|
46 | + * @param string $service the service you want to discover |
|
47 | + * @param bool $skipCache We won't check if the data is in the cache. This is useful if a background job is updating the status - Added in 14.0.0 |
|
48 | + * @return array |
|
49 | + */ |
|
50 | + public function discover(string $remote, string $service, bool $skipCache = false): array; |
|
51 | 51 | |
52 | 52 | } |
@@ -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 | } |
@@ -29,8 +29,8 @@ |
||
29 | 29 | */ |
30 | 30 | interface IGroupDetailsBackend { |
31 | 31 | |
32 | - /** |
|
33 | - * @since 14.0.0 |
|
34 | - */ |
|
35 | - public function getGroupDetails(string $gid): array; |
|
32 | + /** |
|
33 | + * @since 14.0.0 |
|
34 | + */ |
|
35 | + public function getGroupDetails(string $gid): array; |
|
36 | 36 | } |