Completed
Push — master ( 43a8fc...7ac4eb )
by Joas
25:05 queued 05:06
created
lib/private/AppFramework/Middleware/OCSMiddleware.php 1 patch
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -39,123 +39,123 @@
 block discarded – undo
39 39
 use OCP\IRequest;
40 40
 
41 41
 class OCSMiddleware extends Middleware {
42
-	/** @var IRequest */
43
-	private $request;
44
-
45
-	/** @var int */
46
-	private $ocsVersion;
47
-
48
-	/**
49
-	 * @param IRequest $request
50
-	 */
51
-	public function __construct(IRequest $request) {
52
-		$this->request = $request;
53
-	}
54
-
55
-	/**
56
-	 * @param Controller $controller
57
-	 * @param string $methodName
58
-	 */
59
-	public function beforeController($controller, $methodName) {
60
-		if ($controller instanceof OCSController) {
61
-			if (substr_compare($this->request->getScriptName(), '/ocs/v2.php', -strlen('/ocs/v2.php')) === 0) {
62
-				$this->ocsVersion = 2;
63
-			} else {
64
-				$this->ocsVersion = 1;
65
-			}
66
-			$controller->setOCSVersion($this->ocsVersion);
67
-		}
68
-	}
69
-
70
-	/**
71
-	 * @param Controller $controller
72
-	 * @param string $methodName
73
-	 * @param \Exception $exception
74
-	 * @throws \Exception
75
-	 * @return BaseResponse
76
-	 */
77
-	public function afterException($controller, $methodName, \Exception $exception) {
78
-		if ($controller instanceof OCSController && $exception instanceof OCSException) {
79
-			$code = $exception->getCode();
80
-			if ($code === 0) {
81
-				$code = \OCP\AppFramework\OCSController::RESPOND_UNKNOWN_ERROR;
82
-			}
83
-
84
-			return $this->buildNewResponse($controller, $code, $exception->getMessage());
85
-		}
86
-
87
-		throw $exception;
88
-	}
89
-
90
-	/**
91
-	 * @param Controller $controller
92
-	 * @param string $methodName
93
-	 * @param Response $response
94
-	 * @return \OCP\AppFramework\Http\Response
95
-	 */
96
-	public function afterController($controller, $methodName, Response $response) {
97
-		/*
42
+    /** @var IRequest */
43
+    private $request;
44
+
45
+    /** @var int */
46
+    private $ocsVersion;
47
+
48
+    /**
49
+     * @param IRequest $request
50
+     */
51
+    public function __construct(IRequest $request) {
52
+        $this->request = $request;
53
+    }
54
+
55
+    /**
56
+     * @param Controller $controller
57
+     * @param string $methodName
58
+     */
59
+    public function beforeController($controller, $methodName) {
60
+        if ($controller instanceof OCSController) {
61
+            if (substr_compare($this->request->getScriptName(), '/ocs/v2.php', -strlen('/ocs/v2.php')) === 0) {
62
+                $this->ocsVersion = 2;
63
+            } else {
64
+                $this->ocsVersion = 1;
65
+            }
66
+            $controller->setOCSVersion($this->ocsVersion);
67
+        }
68
+    }
69
+
70
+    /**
71
+     * @param Controller $controller
72
+     * @param string $methodName
73
+     * @param \Exception $exception
74
+     * @throws \Exception
75
+     * @return BaseResponse
76
+     */
77
+    public function afterException($controller, $methodName, \Exception $exception) {
78
+        if ($controller instanceof OCSController && $exception instanceof OCSException) {
79
+            $code = $exception->getCode();
80
+            if ($code === 0) {
81
+                $code = \OCP\AppFramework\OCSController::RESPOND_UNKNOWN_ERROR;
82
+            }
83
+
84
+            return $this->buildNewResponse($controller, $code, $exception->getMessage());
85
+        }
86
+
87
+        throw $exception;
88
+    }
89
+
90
+    /**
91
+     * @param Controller $controller
92
+     * @param string $methodName
93
+     * @param Response $response
94
+     * @return \OCP\AppFramework\Http\Response
95
+     */
96
+    public function afterController($controller, $methodName, Response $response) {
97
+        /*
98 98
 		 * If a different middleware has detected that a request unauthorized or forbidden
99 99
 		 * we need to catch the response and convert it to a proper OCS response.
100 100
 		 */
101
-		if ($controller instanceof OCSController && !($response instanceof BaseResponse)) {
102
-			if ($response->getStatus() === Http::STATUS_UNAUTHORIZED) {
103
-				$message = '';
104
-				if ($response instanceof JSONResponse) {
105
-					/** @var DataResponse $response */
106
-					$message = $response->getData()['message'];
107
-				}
108
-
109
-				return $this->buildNewResponse($controller, OCSController::RESPOND_UNAUTHORISED, $message);
110
-			}
111
-			if ($response->getStatus() === Http::STATUS_FORBIDDEN) {
112
-				$message = '';
113
-				if ($response instanceof JSONResponse) {
114
-					/** @var DataResponse $response */
115
-					$message = $response->getData()['message'];
116
-				}
117
-
118
-				return $this->buildNewResponse($controller, Http::STATUS_FORBIDDEN, $message);
119
-			}
120
-		}
121
-
122
-		return $response;
123
-	}
124
-
125
-	/**
126
-	 * @param Controller $controller
127
-	 * @param int $code
128
-	 * @param string $message
129
-	 * @return V1Response|V2Response
130
-	 */
131
-	private function buildNewResponse(Controller $controller, $code, $message) {
132
-		$format = $this->getFormat($controller);
133
-
134
-		$data = new DataResponse();
135
-		$data->setStatus($code);
136
-		if ($this->ocsVersion === 1) {
137
-			$response = new V1Response($data, $format, $message);
138
-		} else {
139
-			$response = new V2Response($data, $format, $message);
140
-		}
141
-
142
-		return $response;
143
-	}
144
-
145
-	/**
146
-	 * @param Controller $controller
147
-	 * @return string
148
-	 */
149
-	private function getFormat(Controller $controller) {
150
-		// get format from the url format or request format parameter
151
-		$format = $this->request->getParam('format');
152
-
153
-		// if none is given try the first Accept header
154
-		if ($format === null) {
155
-			$headers = $this->request->getHeader('Accept');
156
-			$format = $controller->getResponderByHTTPHeader($headers, 'xml');
157
-		}
158
-
159
-		return $format;
160
-	}
101
+        if ($controller instanceof OCSController && !($response instanceof BaseResponse)) {
102
+            if ($response->getStatus() === Http::STATUS_UNAUTHORIZED) {
103
+                $message = '';
104
+                if ($response instanceof JSONResponse) {
105
+                    /** @var DataResponse $response */
106
+                    $message = $response->getData()['message'];
107
+                }
108
+
109
+                return $this->buildNewResponse($controller, OCSController::RESPOND_UNAUTHORISED, $message);
110
+            }
111
+            if ($response->getStatus() === Http::STATUS_FORBIDDEN) {
112
+                $message = '';
113
+                if ($response instanceof JSONResponse) {
114
+                    /** @var DataResponse $response */
115
+                    $message = $response->getData()['message'];
116
+                }
117
+
118
+                return $this->buildNewResponse($controller, Http::STATUS_FORBIDDEN, $message);
119
+            }
120
+        }
121
+
122
+        return $response;
123
+    }
124
+
125
+    /**
126
+     * @param Controller $controller
127
+     * @param int $code
128
+     * @param string $message
129
+     * @return V1Response|V2Response
130
+     */
131
+    private function buildNewResponse(Controller $controller, $code, $message) {
132
+        $format = $this->getFormat($controller);
133
+
134
+        $data = new DataResponse();
135
+        $data->setStatus($code);
136
+        if ($this->ocsVersion === 1) {
137
+            $response = new V1Response($data, $format, $message);
138
+        } else {
139
+            $response = new V2Response($data, $format, $message);
140
+        }
141
+
142
+        return $response;
143
+    }
144
+
145
+    /**
146
+     * @param Controller $controller
147
+     * @return string
148
+     */
149
+    private function getFormat(Controller $controller) {
150
+        // get format from the url format or request format parameter
151
+        $format = $this->request->getParam('format');
152
+
153
+        // if none is given try the first Accept header
154
+        if ($format === null) {
155
+            $headers = $this->request->getHeader('Accept');
156
+            $format = $controller->getResponderByHTTPHeader($headers, 'xml');
157
+        }
158
+
159
+        return $format;
160
+    }
161 161
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Bootstrap/BootContext.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -31,22 +31,22 @@
 block discarded – undo
31 31
 use OCP\IServerContainer;
32 32
 
33 33
 class BootContext implements IBootContext {
34
-	/** @var IAppContainer */
35
-	private $appContainer;
34
+    /** @var IAppContainer */
35
+    private $appContainer;
36 36
 
37
-	public function __construct(IAppContainer $appContainer) {
38
-		$this->appContainer = $appContainer;
39
-	}
37
+    public function __construct(IAppContainer $appContainer) {
38
+        $this->appContainer = $appContainer;
39
+    }
40 40
 
41
-	public function getAppContainer(): IAppContainer {
42
-		return $this->appContainer;
43
-	}
41
+    public function getAppContainer(): IAppContainer {
42
+        return $this->appContainer;
43
+    }
44 44
 
45
-	public function getServerContainer(): IServerContainer {
46
-		return $this->appContainer->get(IServerContainer::class);
47
-	}
45
+    public function getServerContainer(): IServerContainer {
46
+        return $this->appContainer->get(IServerContainer::class);
47
+    }
48 48
 
49
-	public function injectFn(callable $fn) {
50
-		return (new FunctionInjector($this->appContainer))->injectFn($fn);
51
-	}
49
+    public function injectFn(callable $fn) {
50
+        return (new FunctionInjector($this->appContainer))->injectFn($fn);
51
+    }
52 52
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Bootstrap/ARegistration.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,17 +29,17 @@
 block discarded – undo
29 29
  * @psalm-immutable
30 30
  */
31 31
 abstract class ARegistration {
32
-	/** @var string */
33
-	private $appId;
32
+    /** @var string */
33
+    private $appId;
34 34
 
35
-	public function __construct(string $appId) {
36
-		$this->appId = $appId;
37
-	}
35
+    public function __construct(string $appId) {
36
+        $this->appId = $appId;
37
+    }
38 38
 
39
-	/**
40
-	 * @return string
41
-	 */
42
-	public function getAppId(): string {
43
-		return $this->appId;
44
-	}
39
+    /**
40
+     * @return string
41
+     */
42
+    public function getAppId(): string {
43
+        return $this->appId;
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Bootstrap/FunctionInjector.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -33,36 +33,36 @@
 block discarded – undo
33 33
 use function array_map;
34 34
 
35 35
 class FunctionInjector {
36
-	/** @var ContainerInterface */
37
-	private $container;
36
+    /** @var ContainerInterface */
37
+    private $container;
38 38
 
39
-	public function __construct(ContainerInterface $container) {
40
-		$this->container = $container;
41
-	}
39
+    public function __construct(ContainerInterface $container) {
40
+        $this->container = $container;
41
+    }
42 42
 
43
-	public function injectFn(callable $fn) {
44
-		$reflected = new ReflectionFunction(Closure::fromCallable($fn));
45
-		return $fn(...array_map(function (ReflectionParameter $param) {
46
-			// First we try by type (more likely these days)
47
-			if (($type = $param->getType()) !== null) {
48
-				try {
49
-					return $this->container->get($type->getName());
50
-				} catch (QueryException $ex) {
51
-					// Ignore and try name as well
52
-				}
53
-			}
54
-			// Second we try by name (mostly for primitives)
55
-			try {
56
-				return $this->container->get($param->getName());
57
-			} catch (QueryException $ex) {
58
-				// As a last resort we pass `null` if allowed
59
-				if ($type !== null && $type->allowsNull()) {
60
-					return null;
61
-				}
43
+    public function injectFn(callable $fn) {
44
+        $reflected = new ReflectionFunction(Closure::fromCallable($fn));
45
+        return $fn(...array_map(function (ReflectionParameter $param) {
46
+            // First we try by type (more likely these days)
47
+            if (($type = $param->getType()) !== null) {
48
+                try {
49
+                    return $this->container->get($type->getName());
50
+                } catch (QueryException $ex) {
51
+                    // Ignore and try name as well
52
+                }
53
+            }
54
+            // Second we try by name (mostly for primitives)
55
+            try {
56
+                return $this->container->get($param->getName());
57
+            } catch (QueryException $ex) {
58
+                // As a last resort we pass `null` if allowed
59
+                if ($type !== null && $type->allowsNull()) {
60
+                    return null;
61
+                }
62 62
 
63
-				// Nothing worked, time to bail out
64
-				throw $ex;
65
-			}
66
-		}, $reflected->getParameters()));
67
-	}
63
+                // Nothing worked, time to bail out
64
+                throw $ex;
65
+            }
66
+        }, $reflected->getParameters()));
67
+    }
68 68
 }
Please login to merge, or discard this patch.
lib/private/Share20/ShareHelper.php 1 patch
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -31,187 +31,187 @@
 block discarded – undo
31 31
 use OCP\Share\IShareHelper;
32 32
 
33 33
 class ShareHelper implements IShareHelper {
34
-	/** @var IManager */
35
-	private $shareManager;
36
-
37
-	public function __construct(IManager $shareManager) {
38
-		$this->shareManager = $shareManager;
39
-	}
40
-
41
-	/**
42
-	 * @param Node $node
43
-	 * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]]
44
-	 */
45
-	public function getPathsForAccessList(Node $node) {
46
-		$result = [
47
-			'users' => [],
48
-			'remotes' => [],
49
-		];
50
-
51
-		$accessList = $this->shareManager->getAccessList($node, true, true);
52
-		if (!empty($accessList['users'])) {
53
-			$result['users'] = $this->getPathsForUsers($node, $accessList['users']);
54
-		}
55
-		if (!empty($accessList['remote'])) {
56
-			$result['remotes'] = $this->getPathsForRemotes($node, $accessList['remote']);
57
-		}
58
-
59
-		return $result;
60
-	}
61
-
62
-	/**
63
-	 * Sample:
64
-	 * $users = [
65
-	 *   'test1' => ['node_id' => 16, 'node_path' => '/foo'],
66
-	 *   'test2' => ['node_id' => 23, 'node_path' => '/bar'],
67
-	 *   'test3' => ['node_id' => 42, 'node_path' => '/cat'],
68
-	 *   'test4' => ['node_id' => 48, 'node_path' => '/dog'],
69
-	 * ];
70
-	 *
71
-	 * Node tree:
72
-	 * - SixTeen is the parent of TwentyThree
73
-	 * - TwentyThree is the parent of FortyTwo
74
-	 * - FortyEight does not exist
75
-	 *
76
-	 * $return = [
77
-	 *   'test1' => '/foo/TwentyThree/FortyTwo',
78
-	 *   'test2' => '/bar/FortyTwo',
79
-	 *   'test3' => '/cat',
80
-	 * ],
81
-	 *
82
-	 * @param Node $node
83
-	 * @param array[] $users
84
-	 * @return array
85
-	 */
86
-	protected function getPathsForUsers(Node $node, array $users) {
87
-		/** @var array[] $byId */
88
-		$byId = [];
89
-		/** @var array[] $results */
90
-		$results = [];
91
-
92
-		foreach ($users as $uid => $info) {
93
-			if (!isset($byId[$info['node_id']])) {
94
-				$byId[$info['node_id']] = [];
95
-			}
96
-			$byId[$info['node_id']][$uid] = $info['node_path'];
97
-		}
98
-
99
-		try {
100
-			if (isset($byId[$node->getId()])) {
101
-				foreach ($byId[$node->getId()] as $uid => $path) {
102
-					$results[$uid] = $path;
103
-				}
104
-				unset($byId[$node->getId()]);
105
-			}
106
-		} catch (NotFoundException $e) {
107
-			return $results;
108
-		} catch (InvalidPathException $e) {
109
-			return $results;
110
-		}
111
-
112
-		if (empty($byId)) {
113
-			return $results;
114
-		}
115
-
116
-		$item = $node;
117
-		$appendix = '/' . $node->getName();
118
-		while (!empty($byId)) {
119
-			try {
120
-				/** @var Node $item */
121
-				$item = $item->getParent();
122
-
123
-				if (!empty($byId[$item->getId()])) {
124
-					foreach ($byId[$item->getId()] as $uid => $path) {
125
-						$results[$uid] = $path . $appendix;
126
-					}
127
-					unset($byId[$item->getId()]);
128
-				}
129
-
130
-				$appendix = '/' . $item->getName() . $appendix;
131
-			} catch (NotFoundException $e) {
132
-				return $results;
133
-			} catch (InvalidPathException $e) {
134
-				return $results;
135
-			} catch (NotPermittedException $e) {
136
-				return $results;
137
-			}
138
-		}
139
-
140
-		return $results;
141
-	}
142
-
143
-	/**
144
-	 * Sample:
145
-	 * $remotes = [
146
-	 *   'test1' => ['node_id' => 16, 'token' => 't1'],
147
-	 *   'test2' => ['node_id' => 23, 'token' => 't2'],
148
-	 *   'test3' => ['node_id' => 42, 'token' => 't3'],
149
-	 *   'test4' => ['node_id' => 48, 'token' => 't4'],
150
-	 * ];
151
-	 *
152
-	 * Node tree:
153
-	 * - SixTeen is the parent of TwentyThree
154
-	 * - TwentyThree is the parent of FortyTwo
155
-	 * - FortyEight does not exist
156
-	 *
157
-	 * $return = [
158
-	 *   'test1' => ['token' => 't1', 'node_path' => '/SixTeen'],
159
-	 *   'test2' => ['token' => 't2', 'node_path' => '/SixTeen/TwentyThree'],
160
-	 *   'test3' => ['token' => 't3', 'node_path' => '/SixTeen/TwentyThree/FortyTwo'],
161
-	 * ],
162
-	 *
163
-	 * @param Node $node
164
-	 * @param array[] $remotes
165
-	 * @return array
166
-	 */
167
-	protected function getPathsForRemotes(Node $node, array $remotes) {
168
-		/** @var array[] $byId */
169
-		$byId = [];
170
-		/** @var array[] $results */
171
-		$results = [];
172
-
173
-		foreach ($remotes as $cloudId => $info) {
174
-			if (!isset($byId[$info['node_id']])) {
175
-				$byId[$info['node_id']] = [];
176
-			}
177
-			$byId[$info['node_id']][$cloudId] = $info['token'];
178
-		}
179
-
180
-		$item = $node;
181
-		while (!empty($byId)) {
182
-			try {
183
-				if (!empty($byId[$item->getId()])) {
184
-					$path = $this->getMountedPath($item);
185
-					foreach ($byId[$item->getId()] as $uid => $token) {
186
-						$results[$uid] = [
187
-							'node_path' => $path,
188
-							'token' => $token,
189
-						];
190
-					}
191
-					unset($byId[$item->getId()]);
192
-				}
193
-
194
-				/** @var Node $item */
195
-				$item = $item->getParent();
196
-			} catch (NotFoundException $e) {
197
-				return $results;
198
-			} catch (InvalidPathException $e) {
199
-				return $results;
200
-			} catch (NotPermittedException $e) {
201
-				return $results;
202
-			}
203
-		}
204
-
205
-		return $results;
206
-	}
207
-
208
-	/**
209
-	 * @param Node $node
210
-	 * @return string
211
-	 */
212
-	protected function getMountedPath(Node $node) {
213
-		$path = $node->getPath();
214
-		$sections = explode('/', $path, 4);
215
-		return '/' . $sections[3];
216
-	}
34
+    /** @var IManager */
35
+    private $shareManager;
36
+
37
+    public function __construct(IManager $shareManager) {
38
+        $this->shareManager = $shareManager;
39
+    }
40
+
41
+    /**
42
+     * @param Node $node
43
+     * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]]
44
+     */
45
+    public function getPathsForAccessList(Node $node) {
46
+        $result = [
47
+            'users' => [],
48
+            'remotes' => [],
49
+        ];
50
+
51
+        $accessList = $this->shareManager->getAccessList($node, true, true);
52
+        if (!empty($accessList['users'])) {
53
+            $result['users'] = $this->getPathsForUsers($node, $accessList['users']);
54
+        }
55
+        if (!empty($accessList['remote'])) {
56
+            $result['remotes'] = $this->getPathsForRemotes($node, $accessList['remote']);
57
+        }
58
+
59
+        return $result;
60
+    }
61
+
62
+    /**
63
+     * Sample:
64
+     * $users = [
65
+     *   'test1' => ['node_id' => 16, 'node_path' => '/foo'],
66
+     *   'test2' => ['node_id' => 23, 'node_path' => '/bar'],
67
+     *   'test3' => ['node_id' => 42, 'node_path' => '/cat'],
68
+     *   'test4' => ['node_id' => 48, 'node_path' => '/dog'],
69
+     * ];
70
+     *
71
+     * Node tree:
72
+     * - SixTeen is the parent of TwentyThree
73
+     * - TwentyThree is the parent of FortyTwo
74
+     * - FortyEight does not exist
75
+     *
76
+     * $return = [
77
+     *   'test1' => '/foo/TwentyThree/FortyTwo',
78
+     *   'test2' => '/bar/FortyTwo',
79
+     *   'test3' => '/cat',
80
+     * ],
81
+     *
82
+     * @param Node $node
83
+     * @param array[] $users
84
+     * @return array
85
+     */
86
+    protected function getPathsForUsers(Node $node, array $users) {
87
+        /** @var array[] $byId */
88
+        $byId = [];
89
+        /** @var array[] $results */
90
+        $results = [];
91
+
92
+        foreach ($users as $uid => $info) {
93
+            if (!isset($byId[$info['node_id']])) {
94
+                $byId[$info['node_id']] = [];
95
+            }
96
+            $byId[$info['node_id']][$uid] = $info['node_path'];
97
+        }
98
+
99
+        try {
100
+            if (isset($byId[$node->getId()])) {
101
+                foreach ($byId[$node->getId()] as $uid => $path) {
102
+                    $results[$uid] = $path;
103
+                }
104
+                unset($byId[$node->getId()]);
105
+            }
106
+        } catch (NotFoundException $e) {
107
+            return $results;
108
+        } catch (InvalidPathException $e) {
109
+            return $results;
110
+        }
111
+
112
+        if (empty($byId)) {
113
+            return $results;
114
+        }
115
+
116
+        $item = $node;
117
+        $appendix = '/' . $node->getName();
118
+        while (!empty($byId)) {
119
+            try {
120
+                /** @var Node $item */
121
+                $item = $item->getParent();
122
+
123
+                if (!empty($byId[$item->getId()])) {
124
+                    foreach ($byId[$item->getId()] as $uid => $path) {
125
+                        $results[$uid] = $path . $appendix;
126
+                    }
127
+                    unset($byId[$item->getId()]);
128
+                }
129
+
130
+                $appendix = '/' . $item->getName() . $appendix;
131
+            } catch (NotFoundException $e) {
132
+                return $results;
133
+            } catch (InvalidPathException $e) {
134
+                return $results;
135
+            } catch (NotPermittedException $e) {
136
+                return $results;
137
+            }
138
+        }
139
+
140
+        return $results;
141
+    }
142
+
143
+    /**
144
+     * Sample:
145
+     * $remotes = [
146
+     *   'test1' => ['node_id' => 16, 'token' => 't1'],
147
+     *   'test2' => ['node_id' => 23, 'token' => 't2'],
148
+     *   'test3' => ['node_id' => 42, 'token' => 't3'],
149
+     *   'test4' => ['node_id' => 48, 'token' => 't4'],
150
+     * ];
151
+     *
152
+     * Node tree:
153
+     * - SixTeen is the parent of TwentyThree
154
+     * - TwentyThree is the parent of FortyTwo
155
+     * - FortyEight does not exist
156
+     *
157
+     * $return = [
158
+     *   'test1' => ['token' => 't1', 'node_path' => '/SixTeen'],
159
+     *   'test2' => ['token' => 't2', 'node_path' => '/SixTeen/TwentyThree'],
160
+     *   'test3' => ['token' => 't3', 'node_path' => '/SixTeen/TwentyThree/FortyTwo'],
161
+     * ],
162
+     *
163
+     * @param Node $node
164
+     * @param array[] $remotes
165
+     * @return array
166
+     */
167
+    protected function getPathsForRemotes(Node $node, array $remotes) {
168
+        /** @var array[] $byId */
169
+        $byId = [];
170
+        /** @var array[] $results */
171
+        $results = [];
172
+
173
+        foreach ($remotes as $cloudId => $info) {
174
+            if (!isset($byId[$info['node_id']])) {
175
+                $byId[$info['node_id']] = [];
176
+            }
177
+            $byId[$info['node_id']][$cloudId] = $info['token'];
178
+        }
179
+
180
+        $item = $node;
181
+        while (!empty($byId)) {
182
+            try {
183
+                if (!empty($byId[$item->getId()])) {
184
+                    $path = $this->getMountedPath($item);
185
+                    foreach ($byId[$item->getId()] as $uid => $token) {
186
+                        $results[$uid] = [
187
+                            'node_path' => $path,
188
+                            'token' => $token,
189
+                        ];
190
+                    }
191
+                    unset($byId[$item->getId()]);
192
+                }
193
+
194
+                /** @var Node $item */
195
+                $item = $item->getParent();
196
+            } catch (NotFoundException $e) {
197
+                return $results;
198
+            } catch (InvalidPathException $e) {
199
+                return $results;
200
+            } catch (NotPermittedException $e) {
201
+                return $results;
202
+            }
203
+        }
204
+
205
+        return $results;
206
+    }
207
+
208
+    /**
209
+     * @param Node $node
210
+     * @return string
211
+     */
212
+    protected function getMountedPath(Node $node) {
213
+        $path = $node->getPath();
214
+        $sections = explode('/', $path, 4);
215
+        return '/' . $sections[3];
216
+    }
217 217
 }
Please login to merge, or discard this patch.
lib/private/Share20/UserRemovedListener.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -34,18 +34,18 @@
 block discarded – undo
34 34
  * @template-implements IEventListener<UserRemovedEvent>
35 35
  */
36 36
 class UserRemovedListener implements IEventListener {
37
-	/** @var IManager */
38
-	protected $shareManager;
37
+    /** @var IManager */
38
+    protected $shareManager;
39 39
 
40
-	public function __construct(IManager $shareManager) {
41
-		$this->shareManager = $shareManager;
42
-	}
40
+    public function __construct(IManager $shareManager) {
41
+        $this->shareManager = $shareManager;
42
+    }
43 43
 
44
-	public function handle(Event $event): void {
45
-		if (!$event instanceof UserRemovedEvent) {
46
-			return;
47
-		}
44
+    public function handle(Event $event): void {
45
+        if (!$event instanceof UserRemovedEvent) {
46
+            return;
47
+        }
48 48
 
49
-		$this->shareManager->userDeletedFromGroup($event->getUser()->getUID(), $event->getGroup()->getGID());
50
-	}
49
+        $this->shareManager->userDeletedFromGroup($event->getUser()->getUID(), $event->getGroup()->getGID());
50
+    }
51 51
 }
Please login to merge, or discard this patch.
lib/private/Comments/ManagerFactory.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -30,29 +30,29 @@
 block discarded – undo
30 30
 use OCP\IServerContainer;
31 31
 
32 32
 class ManagerFactory implements ICommentsManagerFactory {
33
-	/**
34
-	 * Server container
35
-	 *
36
-	 * @var IServerContainer
37
-	 */
38
-	private $serverContainer;
33
+    /**
34
+     * Server container
35
+     *
36
+     * @var IServerContainer
37
+     */
38
+    private $serverContainer;
39 39
 
40
-	/**
41
-	 * Constructor for the comments manager factory
42
-	 *
43
-	 * @param IServerContainer $serverContainer server container
44
-	 */
45
-	public function __construct(IServerContainer $serverContainer) {
46
-		$this->serverContainer = $serverContainer;
47
-	}
40
+    /**
41
+     * Constructor for the comments manager factory
42
+     *
43
+     * @param IServerContainer $serverContainer server container
44
+     */
45
+    public function __construct(IServerContainer $serverContainer) {
46
+        $this->serverContainer = $serverContainer;
47
+    }
48 48
 
49
-	/**
50
-	 * creates and returns an instance of the ICommentsManager
51
-	 *
52
-	 * @return ICommentsManager
53
-	 * @since 9.0.0
54
-	 */
55
-	public function getManager() {
56
-		return $this->serverContainer->get(Manager::class);
57
-	}
49
+    /**
50
+     * creates and returns an instance of the ICommentsManager
51
+     *
52
+     * @return ICommentsManager
53
+     * @since 9.0.0
54
+     */
55
+    public function getManager() {
56
+        return $this->serverContainer->get(Manager::class);
57
+    }
58 58
 }
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/ActionFactory.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -27,22 +27,22 @@
 block discarded – undo
27 27
 use OCP\Contacts\ContactsMenu\ILinkAction;
28 28
 
29 29
 class ActionFactory implements IActionFactory {
30
-	/**
31
-	 * {@inheritDoc}
32
-	 */
33
-	public function newLinkAction(string $icon, string $name, string $href, string $appId = ''): ILinkAction {
34
-		$action = new LinkAction();
35
-		$action->setName($name);
36
-		$action->setIcon($icon);
37
-		$action->setHref($href);
38
-		$action->setAppId($appId);
39
-		return $action;
40
-	}
30
+    /**
31
+     * {@inheritDoc}
32
+     */
33
+    public function newLinkAction(string $icon, string $name, string $href, string $appId = ''): ILinkAction {
34
+        $action = new LinkAction();
35
+        $action->setName($name);
36
+        $action->setIcon($icon);
37
+        $action->setHref($href);
38
+        $action->setAppId($appId);
39
+        return $action;
40
+    }
41 41
 
42
-	/**
43
-	 * {@inheritDoc}
44
-	 */
45
-	public function newEMailAction(string $icon, string $name, string $email, string $appId = ''): ILinkAction {
46
-		return $this->newLinkAction($icon, $name, 'mailto:' . $email, $appId);
47
-	}
42
+    /**
43
+     * {@inheritDoc}
44
+     */
45
+    public function newEMailAction(string $icon, string $name, string $email, string $appId = ''): ILinkAction {
46
+        return $this->newLinkAction($icon, $name, 'mailto:' . $email, $appId);
47
+    }
48 48
 }
Please login to merge, or discard this patch.
lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,18 +31,18 @@
 block discarded – undo
31 31
 use OCP\Migration\IRepairStep;
32 32
 
33 33
 class AddPreviewBackgroundCleanupJob implements IRepairStep {
34
-	/** @var IJobList */
35
-	private $jobList;
34
+    /** @var IJobList */
35
+    private $jobList;
36 36
 
37
-	public function __construct(IJobList $jobList) {
38
-		$this->jobList = $jobList;
39
-	}
37
+    public function __construct(IJobList $jobList) {
38
+        $this->jobList = $jobList;
39
+    }
40 40
 
41
-	public function getName(): string {
42
-		return 'Add preview background cleanup job';
43
-	}
41
+    public function getName(): string {
42
+        return 'Add preview background cleanup job';
43
+    }
44 44
 
45
-	public function run(IOutput $output) {
46
-		$this->jobList->add(BackgroundCleanupJob::class);
47
-	}
45
+    public function run(IOutput $output) {
46
+        $this->jobList->add(BackgroundCleanupJob::class);
47
+    }
48 48
 }
Please login to merge, or discard this patch.