(array $src, bool $includeSecrets, bool $adminView)
| 221 | } |
| 222 | |
| 223 | private static function buildSourceView(array $src, bool $includeSecrets, bool $adminView): array |
| 224 | { |
| 225 | $out = [ |
| 226 | 'id' => $src['id'], |
| 227 | 'name' => $src['name'], |
| 228 | 'type' => $src['type'], |
| 229 | 'enabled' => !empty($src['enabled']), |
| 230 | 'readOnly' => !empty($src['readOnly']), |
| 231 | 'disableTrash' => !empty($src['disableTrash']), |
| 232 | ]; |
| 233 | |
| 234 | $cfg = isset($src['config']) && is_array($src['config']) ? $src['config'] : []; |
| 235 | if ($src['type'] === 'local') { |
| 236 | $out['config'] = [ |
| 237 | 'path' => (string)($cfg['path'] ?? ''), |
| 238 | ]; |
| 239 | return $out; |
| 240 | } |
| 241 | |
| 242 | if ($src['type'] === 'webdav') { |
| 243 | $config = [ |
| 244 | 'baseUrl' => (string)($cfg['baseUrl'] ?? $cfg['url'] ?? ''), |
| 245 | 'username' => (string)($cfg['username'] ?? ''), |
| 246 | 'root' => (string)($cfg['root'] ?? $cfg['path'] ?? ''), |
| 247 | 'verifyTls' => !isset($cfg['verifyTls']) || $cfg['verifyTls'] !== false, |
| 248 | ]; |
| 249 | $hasPassword = !empty($cfg['passwordEnc']); |
| 250 | |
| 251 | if ($includeSecrets) { |
| 252 | $config['password'] = $hasPassword ? self::decryptSecret((string)$cfg['passwordEnc']) : ''; |
| 253 | } elseif ($adminView) { |
| 254 | $config['hasPassword'] = $hasPassword; |
| 255 | } |
| 256 | |
| 257 | $out['config'] = $config; |
| 258 | return $out; |
| 259 | } |
| 260 | |
| 261 | $out['config'] = []; |
| 262 | return $out; |
| 263 | } |
| 264 | |
| 265 | public static function sourcesEnabled(): bool |
| 266 | { |
no test coverage detected