Passed
Push — master ( b794fa...797527 )
by Christoph
82:28 queued 66:03
created
lib/public/Files/Mount/IMountManager.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -32,77 +32,77 @@
 block discarded – undo
32 32
  */
33 33
 interface IMountManager {
34 34
 
35
-	/**
36
-	 * Add a new mount
37
-	 *
38
-	 * @param \OCP\Files\Mount\IMountPoint $mount
39
-	 * @since 8.2.0
40
-	 */
41
-	public function addMount(IMountPoint $mount);
35
+    /**
36
+     * Add a new mount
37
+     *
38
+     * @param \OCP\Files\Mount\IMountPoint $mount
39
+     * @since 8.2.0
40
+     */
41
+    public function addMount(IMountPoint $mount);
42 42
 
43
-	/**
44
-	 * Remove a mount
45
-	 *
46
-	 * @param string $mountPoint
47
-	 * @since 8.2.0
48
-	 */
49
-	public function removeMount(string $mountPoint);
43
+    /**
44
+     * Remove a mount
45
+     *
46
+     * @param string $mountPoint
47
+     * @since 8.2.0
48
+     */
49
+    public function removeMount(string $mountPoint);
50 50
 
51
-	/**
52
-	 * Change the location of a mount
53
-	 *
54
-	 * @param string $mountPoint
55
-	 * @param string $target
56
-	 * @since 8.2.0
57
-	 */
58
-	public function moveMount(string $mountPoint, string $target);
51
+    /**
52
+     * Change the location of a mount
53
+     *
54
+     * @param string $mountPoint
55
+     * @param string $target
56
+     * @since 8.2.0
57
+     */
58
+    public function moveMount(string $mountPoint, string $target);
59 59
 
60
-	/**
61
-	 * Find the mount for $path
62
-	 *
63
-	 * @param string $path
64
-	 * @return \OCP\Files\Mount\IMountPoint|null
65
-	 * @since 8.2.0
66
-	 */
67
-	public function find(string $path);
60
+    /**
61
+     * Find the mount for $path
62
+     *
63
+     * @param string $path
64
+     * @return \OCP\Files\Mount\IMountPoint|null
65
+     * @since 8.2.0
66
+     */
67
+    public function find(string $path);
68 68
 
69
-	/**
70
-	 * Find all mounts in $path
71
-	 *
72
-	 * @param string $path
73
-	 * @return \OCP\Files\Mount\IMountPoint[]
74
-	 * @since 8.2.0
75
-	 */
76
-	public function findIn(string $path): array;
69
+    /**
70
+     * Find all mounts in $path
71
+     *
72
+     * @param string $path
73
+     * @return \OCP\Files\Mount\IMountPoint[]
74
+     * @since 8.2.0
75
+     */
76
+    public function findIn(string $path): array;
77 77
 
78
-	/**
79
-	 * Remove all registered mounts
80
-	 *
81
-	 * @since 8.2.0
82
-	 */
83
-	public function clear();
78
+    /**
79
+     * Remove all registered mounts
80
+     *
81
+     * @since 8.2.0
82
+     */
83
+    public function clear();
84 84
 
85
-	/**
86
-	 * Find mounts by storage id
87
-	 *
88
-	 * @param string $id
89
-	 * @return \OCP\Files\Mount\IMountPoint[]
90
-	 * @since 8.2.0
91
-	 */
92
-	public function findByStorageId(string $id): array;
85
+    /**
86
+     * Find mounts by storage id
87
+     *
88
+     * @param string $id
89
+     * @return \OCP\Files\Mount\IMountPoint[]
90
+     * @since 8.2.0
91
+     */
92
+    public function findByStorageId(string $id): array;
93 93
 
94
-	/**
95
-	 * @return \OCP\Files\Mount\IMountPoint[]
96
-	 * @since 8.2.0
97
-	 */
98
-	public function getAll(): array;
94
+    /**
95
+     * @return \OCP\Files\Mount\IMountPoint[]
96
+     * @since 8.2.0
97
+     */
98
+    public function getAll(): array;
99 99
 
100
-	/**
101
-	 * Find mounts by numeric storage id
102
-	 *
103
-	 * @param int $id
104
-	 * @return \OCP\Files\Mount\IMountPoint[]
105
-	 * @since 8.2.0
106
-	 */
107
-	public function findByNumericId(int $id): array;
100
+    /**
101
+     * Find mounts by numeric storage id
102
+     *
103
+     * @param int $id
104
+     * @return \OCP\Files\Mount\IMountPoint[]
105
+     * @since 8.2.0
106
+     */
107
+    public function findByNumericId(int $id): array;
108 108
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Http/Template/LinkMenuAction.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -34,33 +34,33 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -51,16 +51,16 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/public/OCS/IDiscoveryService.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -35,18 +35,18 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
core/Migrations/Version14000Date20180129121024.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -30,30 +30,30 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
apps/dav/lib/Direct/Server.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
apps/dav/lib/Db/Direct.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -37,22 +37,22 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Service/LegacyStoragesService.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 						}
Please login to merge, or discard this patch.
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -34,179 +34,179 @@
 block discarded – undo
34 34
  * Read mount config from legacy mount.json
35 35
  */
36 36
 abstract class LegacyStoragesService {
37
-	/** @var BackendService */
38
-	protected $backendService;
37
+    /** @var BackendService */
38
+    protected $backendService;
39 39
 
40
-	/**
41
-	 * Read legacy config data
42
-	 *
43
-	 * @return array list of mount configs
44
-	 */
45
-	abstract protected function readLegacyConfig();
40
+    /**
41
+     * Read legacy config data
42
+     *
43
+     * @return array list of mount configs
44
+     */
45
+    abstract protected function readLegacyConfig();
46 46
 
47
-	/**
48
-	 * Copy legacy storage options into the given storage config object.
49
-	 *
50
-	 * @param StorageConfig $storageConfig storage config to populate
51
-	 * @param string $mountType mount type
52
-	 * @param string $applicable applicable user or group
53
-	 * @param array $storageOptions legacy storage options
54
-	 *
55
-	 * @return StorageConfig populated storage config
56
-	 */
57
-	protected function populateStorageConfigWithLegacyOptions(
58
-		&$storageConfig,
59
-		$mountType,
60
-		$applicable,
61
-		$storageOptions
62
-	) {
63
-		$backend = $this->backendService->getBackend($storageOptions['backend']);
64
-		if (!$backend) {
65
-			throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']);
66
-		}
67
-		$storageConfig->setBackend($backend);
68
-		if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') {
69
-			$authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']);
70
-		} else {
71
-			$authMechanism = $backend->getLegacyAuthMechanism($storageOptions);
72
-			$storageOptions['authMechanism'] = 'null'; // to make error handling easier
73
-		}
74
-		if (!$authMechanism) {
75
-			throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']);
76
-		}
77
-		$storageConfig->setAuthMechanism($authMechanism);
78
-		$storageConfig->setBackendOptions($storageOptions['options']);
79
-		if (isset($storageOptions['mountOptions'])) {
80
-			$storageConfig->setMountOptions($storageOptions['mountOptions']);
81
-		}
82
-		if (!isset($storageOptions['priority'])) {
83
-			$storageOptions['priority'] = $backend->getPriority();
84
-		}
85
-		$storageConfig->setPriority($storageOptions['priority']);
86
-		if ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_USER) {
87
-			$applicableUsers = $storageConfig->getApplicableUsers();
88
-			if ($applicable !== 'all') {
89
-				$applicableUsers[] = $applicable;
90
-				$storageConfig->setApplicableUsers($applicableUsers);
91
-			}
92
-		} elseif ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP) {
93
-			$applicableGroups = $storageConfig->getApplicableGroups();
94
-			$applicableGroups[] = $applicable;
95
-			$storageConfig->setApplicableGroups($applicableGroups);
96
-		}
97
-		return $storageConfig;
98
-	}
47
+    /**
48
+     * Copy legacy storage options into the given storage config object.
49
+     *
50
+     * @param StorageConfig $storageConfig storage config to populate
51
+     * @param string $mountType mount type
52
+     * @param string $applicable applicable user or group
53
+     * @param array $storageOptions legacy storage options
54
+     *
55
+     * @return StorageConfig populated storage config
56
+     */
57
+    protected function populateStorageConfigWithLegacyOptions(
58
+        &$storageConfig,
59
+        $mountType,
60
+        $applicable,
61
+        $storageOptions
62
+    ) {
63
+        $backend = $this->backendService->getBackend($storageOptions['backend']);
64
+        if (!$backend) {
65
+            throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']);
66
+        }
67
+        $storageConfig->setBackend($backend);
68
+        if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') {
69
+            $authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']);
70
+        } else {
71
+            $authMechanism = $backend->getLegacyAuthMechanism($storageOptions);
72
+            $storageOptions['authMechanism'] = 'null'; // to make error handling easier
73
+        }
74
+        if (!$authMechanism) {
75
+            throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']);
76
+        }
77
+        $storageConfig->setAuthMechanism($authMechanism);
78
+        $storageConfig->setBackendOptions($storageOptions['options']);
79
+        if (isset($storageOptions['mountOptions'])) {
80
+            $storageConfig->setMountOptions($storageOptions['mountOptions']);
81
+        }
82
+        if (!isset($storageOptions['priority'])) {
83
+            $storageOptions['priority'] = $backend->getPriority();
84
+        }
85
+        $storageConfig->setPriority($storageOptions['priority']);
86
+        if ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_USER) {
87
+            $applicableUsers = $storageConfig->getApplicableUsers();
88
+            if ($applicable !== 'all') {
89
+                $applicableUsers[] = $applicable;
90
+                $storageConfig->setApplicableUsers($applicableUsers);
91
+            }
92
+        } elseif ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP) {
93
+            $applicableGroups = $storageConfig->getApplicableGroups();
94
+            $applicableGroups[] = $applicable;
95
+            $storageConfig->setApplicableGroups($applicableGroups);
96
+        }
97
+        return $storageConfig;
98
+    }
99 99
 
100
-	/**
101
-	 * Read the external storages config
102
-	 *
103
-	 * @return StorageConfig[] map of storage id to storage config
104
-	 */
105
-	public function getAllStorages() {
106
-		$mountPoints = $this->readLegacyConfig();
107
-		/**
108
-		 * Here is the how the horribly messy mount point array looks like
109
-		 * from the mount.json file:
110
-		 *
111
-		 * $storageOptions = $mountPoints[$mountType][$applicable][$mountPath]
112
-		 *
113
-		 * - $mountType is either "user" or "group"
114
-		 * - $applicable is the name of a user or group (or the current user for personal mounts)
115
-		 * - $mountPath is the mount point path (where the storage must be mounted)
116
-		 * - $storageOptions is a map of storage options:
117
-		 *     - "priority": storage priority
118
-		 *     - "backend": backend identifier
119
-		 *     - "class": LEGACY backend class name
120
-		 *     - "options": backend-specific options
121
-		 *     - "authMechanism": authentication mechanism identifier
122
-		 *     - "mountOptions": mount-specific options (ex: disable previews, scanner, etc)
123
-		 */
124
-		// group by storage id
125
-		/** @var StorageConfig[] $storages */
126
-		$storages = [];
127
-		// for storages without id (legacy), group by config hash for
128
-		// later processing
129
-		$storagesWithConfigHash = [];
130
-		foreach ($mountPoints as $mountType => $applicables) {
131
-			foreach ($applicables as $applicable => $mountPaths) {
132
-				foreach ($mountPaths as $rootMountPath => $storageOptions) {
133
-					$currentStorage = null;
134
-					/**
135
-					 * Flag whether the config that was read already has an id.
136
-					 * If not, it will use a config hash instead and generate
137
-					 * a proper id later
138
-					 *
139
-					 * @var boolean
140
-					 */
141
-					$hasId = false;
142
-					// the root mount point is in the format "/$user/files/the/mount/point"
143
-					// we remove the "/$user/files" prefix
144
-					$parts = explode('/', ltrim($rootMountPath, '/'), 3);
145
-					if (count($parts) < 3) {
146
-						// something went wrong, skip
147
-						\OC::$server->getLogger()->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']);
148
-						continue;
149
-					}
150
-					$relativeMountPath = rtrim($parts[2], '/');
151
-					// note: we cannot do this after the loop because the decrypted config
152
-					// options might be needed for the config hash
153
-					$storageOptions['options'] = \OCA\Files_External\MountConfig::decryptPasswords($storageOptions['options']);
154
-					if (!isset($storageOptions['backend'])) {
155
-						$storageOptions['backend'] = $storageOptions['class']; // legacy compat
156
-					}
157
-					if (!isset($storageOptions['authMechanism'])) {
158
-						$storageOptions['authMechanism'] = null; // ensure config hash works
159
-					}
160
-					if (isset($storageOptions['id'])) {
161
-						$configId = (int)$storageOptions['id'];
162
-						if (isset($storages[$configId])) {
163
-							$currentStorage = $storages[$configId];
164
-						}
165
-						$hasId = true;
166
-					} else {
167
-						// missing id in legacy config, need to generate
168
-						// but at this point we don't know the max-id, so use
169
-						// first group it by config hash
170
-						$storageOptions['mountpoint'] = $rootMountPath;
171
-						$configId = \OCA\Files_External\MountConfig::makeConfigHash($storageOptions);
172
-						if (isset($storagesWithConfigHash[$configId])) {
173
-							$currentStorage = $storagesWithConfigHash[$configId];
174
-						}
175
-					}
176
-					if (is_null($currentStorage)) {
177
-						// create new
178
-						$currentStorage = new StorageConfig($configId);
179
-						$currentStorage->setMountPoint($relativeMountPath);
180
-					}
181
-					try {
182
-						$this->populateStorageConfigWithLegacyOptions(
183
-							$currentStorage,
184
-							$mountType,
185
-							$applicable,
186
-							$storageOptions
187
-						);
188
-						if ($hasId) {
189
-							$storages[$configId] = $currentStorage;
190
-						} else {
191
-							$storagesWithConfigHash[$configId] = $currentStorage;
192
-						}
193
-					} catch (\UnexpectedValueException $e) {
194
-						// don't die if a storage backend doesn't exist
195
-						\OC::$server->getLogger()->logException($e, [
196
-							'message' => 'Could not load storage.',
197
-							'level' => ILogger::ERROR,
198
-							'app' => 'files_external',
199
-						]);
200
-					}
201
-				}
202
-			}
203
-		}
100
+    /**
101
+     * Read the external storages config
102
+     *
103
+     * @return StorageConfig[] map of storage id to storage config
104
+     */
105
+    public function getAllStorages() {
106
+        $mountPoints = $this->readLegacyConfig();
107
+        /**
108
+         * Here is the how the horribly messy mount point array looks like
109
+         * from the mount.json file:
110
+         *
111
+         * $storageOptions = $mountPoints[$mountType][$applicable][$mountPath]
112
+         *
113
+         * - $mountType is either "user" or "group"
114
+         * - $applicable is the name of a user or group (or the current user for personal mounts)
115
+         * - $mountPath is the mount point path (where the storage must be mounted)
116
+         * - $storageOptions is a map of storage options:
117
+         *     - "priority": storage priority
118
+         *     - "backend": backend identifier
119
+         *     - "class": LEGACY backend class name
120
+         *     - "options": backend-specific options
121
+         *     - "authMechanism": authentication mechanism identifier
122
+         *     - "mountOptions": mount-specific options (ex: disable previews, scanner, etc)
123
+         */
124
+        // group by storage id
125
+        /** @var StorageConfig[] $storages */
126
+        $storages = [];
127
+        // for storages without id (legacy), group by config hash for
128
+        // later processing
129
+        $storagesWithConfigHash = [];
130
+        foreach ($mountPoints as $mountType => $applicables) {
131
+            foreach ($applicables as $applicable => $mountPaths) {
132
+                foreach ($mountPaths as $rootMountPath => $storageOptions) {
133
+                    $currentStorage = null;
134
+                    /**
135
+                     * Flag whether the config that was read already has an id.
136
+                     * If not, it will use a config hash instead and generate
137
+                     * a proper id later
138
+                     *
139
+                     * @var boolean
140
+                     */
141
+                    $hasId = false;
142
+                    // the root mount point is in the format "/$user/files/the/mount/point"
143
+                    // we remove the "/$user/files" prefix
144
+                    $parts = explode('/', ltrim($rootMountPath, '/'), 3);
145
+                    if (count($parts) < 3) {
146
+                        // something went wrong, skip
147
+                        \OC::$server->getLogger()->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']);
148
+                        continue;
149
+                    }
150
+                    $relativeMountPath = rtrim($parts[2], '/');
151
+                    // note: we cannot do this after the loop because the decrypted config
152
+                    // options might be needed for the config hash
153
+                    $storageOptions['options'] = \OCA\Files_External\MountConfig::decryptPasswords($storageOptions['options']);
154
+                    if (!isset($storageOptions['backend'])) {
155
+                        $storageOptions['backend'] = $storageOptions['class']; // legacy compat
156
+                    }
157
+                    if (!isset($storageOptions['authMechanism'])) {
158
+                        $storageOptions['authMechanism'] = null; // ensure config hash works
159
+                    }
160
+                    if (isset($storageOptions['id'])) {
161
+                        $configId = (int)$storageOptions['id'];
162
+                        if (isset($storages[$configId])) {
163
+                            $currentStorage = $storages[$configId];
164
+                        }
165
+                        $hasId = true;
166
+                    } else {
167
+                        // missing id in legacy config, need to generate
168
+                        // but at this point we don't know the max-id, so use
169
+                        // first group it by config hash
170
+                        $storageOptions['mountpoint'] = $rootMountPath;
171
+                        $configId = \OCA\Files_External\MountConfig::makeConfigHash($storageOptions);
172
+                        if (isset($storagesWithConfigHash[$configId])) {
173
+                            $currentStorage = $storagesWithConfigHash[$configId];
174
+                        }
175
+                    }
176
+                    if (is_null($currentStorage)) {
177
+                        // create new
178
+                        $currentStorage = new StorageConfig($configId);
179
+                        $currentStorage->setMountPoint($relativeMountPath);
180
+                    }
181
+                    try {
182
+                        $this->populateStorageConfigWithLegacyOptions(
183
+                            $currentStorage,
184
+                            $mountType,
185
+                            $applicable,
186
+                            $storageOptions
187
+                        );
188
+                        if ($hasId) {
189
+                            $storages[$configId] = $currentStorage;
190
+                        } else {
191
+                            $storagesWithConfigHash[$configId] = $currentStorage;
192
+                        }
193
+                    } catch (\UnexpectedValueException $e) {
194
+                        // don't die if a storage backend doesn't exist
195
+                        \OC::$server->getLogger()->logException($e, [
196
+                            'message' => 'Could not load storage.',
197
+                            'level' => ILogger::ERROR,
198
+                            'app' => 'files_external',
199
+                        ]);
200
+                    }
201
+                }
202
+            }
203
+        }
204 204
 
205
-		// convert parameter values
206
-		foreach ($storages as $storage) {
207
-			$storage->getBackend()->validateStorageDefinition($storage);
208
-			$storage->getAuthMechanism()->validateStorageDefinition($storage);
209
-		}
210
-		return $storages;
211
-	}
205
+        // convert parameter values
206
+        foreach ($storages as $storage) {
207
+            $storage->getBackend()->validateStorageDefinition($storage);
208
+            $storage->getAuthMechanism()->validateStorageDefinition($storage);
209
+        }
210
+        return $storages;
211
+    }
212 212
 }
Please login to merge, or discard this patch.
lib/public/Group/Backend/IGroupDetailsBackend.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/public/Group/Backend/IIsAdminBackend.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@
 block discarded – undo
29 29
  */
30 30
 interface IIsAdminBackend {
31 31
 
32
-	/**
33
-	 * @since 14.0.0
34
-	 */
35
-	public function isAdmin(string $uid): bool;
32
+    /**
33
+     * @since 14.0.0
34
+     */
35
+    public function isAdmin(string $uid): bool;
36 36
 }
Please login to merge, or discard this patch.