Passed
Push — master ( 4908d8...fbbdc6 )
by Joas
16:12 queued 12s
created
apps/dav/lib/Comments/CommentsPlugin.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 		$this->server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
93 93
 
94
-		$this->server->xml->classMap['DateTime'] = function (Writer $writer, \DateTime $value) {
94
+		$this->server->xml->classMap['DateTime'] = function(Writer $writer, \DateTime $value) {
95 95
 			$writer->write(\Sabre\HTTP\toDate($value));
96 96
 		};
97 97
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		// having their own comments marked as unread
126 126
 		$node->setReadMarker(null);
127 127
 
128
-		$url = rtrim($request->getUrl(), '/') . '/' . urlencode($comment->getId());
128
+		$url = rtrim($request->getUrl(), '/').'/'.urlencode($comment->getId());
129 129
 
130 130
 		$response->setHeader('Content-Location', $url);
131 131
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 			$this::REPORT_PARAM_OFFSET,
168 168
 			$this::REPORT_PARAM_TIMESTAMP
169 169
 		];
170
-		$ns = '{' . $this::NS_OWNCLOUD . '}';
170
+		$ns = '{'.$this::NS_OWNCLOUD.'}';
171 171
 		foreach ($report as $parameter) {
172 172
 			if (!in_array($parameter['name'], $acceptableParameters) || empty($parameter['value'])) {
173 173
 				continue;
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$responses = [];
185 185
 		foreach ($results as $node) {
186
-			$nodePath = $this->server->getRequestUri() . '/' . $node->comment->getId();
186
+			$nodePath = $this->server->getRequestUri().'/'.$node->comment->getId();
187 187
 			$resultSet = $this->server->getPropertiesForPath($nodePath, CommentNode::getPropertyNames());
188 188
 			if (isset($resultSet[0]) && isset($resultSet[0][200])) {
189 189
 				$responses[] = new Response(
190
-					$this->server->getBaseUri() . $nodePath,
190
+					$this->server->getBaseUri().$nodePath,
191 191
 					[200 => $resultSet[0][200]],
192 192
 					200
193 193
 				);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 			}
235 235
 		}
236 236
 		if (is_null($actorId)) {
237
-			throw new BadRequest('Invalid actor "' .  $actorType .'"');
237
+			throw new BadRequest('Invalid actor "'.$actorType.'"');
238 238
 		}
239 239
 
240 240
 		try {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 			throw new BadRequest('Invalid input values', 0, $e);
248 248
 		} catch (\OCP\Comments\MessageTooLongException $e) {
249 249
 			$msg = 'Message exceeds allowed character limit of ';
250
-			throw new BadRequest($msg . \OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0,	$e);
250
+			throw new BadRequest($msg.\OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0, $e);
251 251
 		}
252 252
 	}
253 253
 }
Please login to merge, or discard this patch.
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -44,210 +44,210 @@
 block discarded – undo
44 44
  * Sabre plugin to handle comments:
45 45
  */
46 46
 class CommentsPlugin extends ServerPlugin {
47
-	// namespace
48
-	public const NS_OWNCLOUD = 'http://owncloud.org/ns';
49
-
50
-	public const REPORT_NAME = '{http://owncloud.org/ns}filter-comments';
51
-	public const REPORT_PARAM_LIMIT = '{http://owncloud.org/ns}limit';
52
-	public const REPORT_PARAM_OFFSET = '{http://owncloud.org/ns}offset';
53
-	public const REPORT_PARAM_TIMESTAMP = '{http://owncloud.org/ns}datetime';
54
-
55
-	/** @var ICommentsManager  */
56
-	protected $commentsManager;
57
-
58
-	/** @var \Sabre\DAV\Server $server */
59
-	private $server;
60
-
61
-	/** @var  \OCP\IUserSession */
62
-	protected $userSession;
63
-
64
-	/**
65
-	 * Comments plugin
66
-	 *
67
-	 * @param ICommentsManager $commentsManager
68
-	 * @param IUserSession $userSession
69
-	 */
70
-	public function __construct(ICommentsManager $commentsManager, IUserSession $userSession) {
71
-		$this->commentsManager = $commentsManager;
72
-		$this->userSession = $userSession;
73
-	}
74
-
75
-	/**
76
-	 * This initializes the plugin.
77
-	 *
78
-	 * This function is called by Sabre\DAV\Server, after
79
-	 * addPlugin is called.
80
-	 *
81
-	 * This method should set up the required event subscriptions.
82
-	 *
83
-	 * @param Server $server
84
-	 * @return void
85
-	 */
86
-	public function initialize(Server $server) {
87
-		$this->server = $server;
88
-		if (strpos($this->server->getRequestUri(), 'comments/') !== 0) {
89
-			return;
90
-		}
91
-
92
-		$this->server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
93
-
94
-		$this->server->xml->classMap['DateTime'] = function (Writer $writer, \DateTime $value) {
95
-			$writer->write(\Sabre\HTTP\toDate($value));
96
-		};
97
-
98
-		$this->server->on('report', [$this, 'onReport']);
99
-		$this->server->on('method:POST', [$this, 'httpPost']);
100
-	}
101
-
102
-	/**
103
-	 * POST operation on Comments collections
104
-	 *
105
-	 * @param RequestInterface $request request object
106
-	 * @param ResponseInterface $response response object
107
-	 * @return null|false
108
-	 */
109
-	public function httpPost(RequestInterface $request, ResponseInterface $response) {
110
-		$path = $request->getPath();
111
-		$node = $this->server->tree->getNodeForPath($path);
112
-		if (!$node instanceof EntityCollection) {
113
-			return null;
114
-		}
115
-
116
-		$data = $request->getBodyAsString();
117
-		$comment = $this->createComment(
118
-			$node->getName(),
119
-			$node->getId(),
120
-			$data,
121
-			$request->getHeader('Content-Type')
122
-		);
123
-
124
-		// update read marker for the current user/poster to avoid
125
-		// having their own comments marked as unread
126
-		$node->setReadMarker(null);
127
-
128
-		$url = rtrim($request->getUrl(), '/') . '/' . urlencode($comment->getId());
129
-
130
-		$response->setHeader('Content-Location', $url);
131
-
132
-		// created
133
-		$response->setStatus(201);
134
-		return false;
135
-	}
136
-
137
-	/**
138
-	 * Returns a list of reports this plugin supports.
139
-	 *
140
-	 * This will be used in the {DAV:}supported-report-set property.
141
-	 *
142
-	 * @param string $uri
143
-	 * @return array
144
-	 */
145
-	public function getSupportedReportSet($uri) {
146
-		return [self::REPORT_NAME];
147
-	}
148
-
149
-	/**
150
-	 * REPORT operations to look for comments
151
-	 *
152
-	 * @param string $reportName
153
-	 * @param array $report
154
-	 * @param string $uri
155
-	 * @return bool
156
-	 * @throws NotFound
157
-	 * @throws ReportNotSupported
158
-	 */
159
-	public function onReport($reportName, $report, $uri) {
160
-		$node = $this->server->tree->getNodeForPath($uri);
161
-		if (!$node instanceof EntityCollection || $reportName !== self::REPORT_NAME) {
162
-			throw new ReportNotSupported();
163
-		}
164
-		$args = ['limit' => 0, 'offset' => 0, 'datetime' => null];
165
-		$acceptableParameters = [
166
-			$this::REPORT_PARAM_LIMIT,
167
-			$this::REPORT_PARAM_OFFSET,
168
-			$this::REPORT_PARAM_TIMESTAMP
169
-		];
170
-		$ns = '{' . $this::NS_OWNCLOUD . '}';
171
-		foreach ($report as $parameter) {
172
-			if (!in_array($parameter['name'], $acceptableParameters) || empty($parameter['value'])) {
173
-				continue;
174
-			}
175
-			$args[str_replace($ns, '', $parameter['name'])] = $parameter['value'];
176
-		}
177
-
178
-		if (!is_null($args['datetime'])) {
179
-			$args['datetime'] = new \DateTime($args['datetime']);
180
-		}
181
-
182
-		$results = $node->findChildren($args['limit'], $args['offset'], $args['datetime']);
183
-
184
-		$responses = [];
185
-		foreach ($results as $node) {
186
-			$nodePath = $this->server->getRequestUri() . '/' . $node->comment->getId();
187
-			$resultSet = $this->server->getPropertiesForPath($nodePath, CommentNode::getPropertyNames());
188
-			if (isset($resultSet[0]) && isset($resultSet[0][200])) {
189
-				$responses[] = new Response(
190
-					$this->server->getBaseUri() . $nodePath,
191
-					[200 => $resultSet[0][200]],
192
-					200
193
-				);
194
-			}
195
-		}
196
-
197
-		$xml = $this->server->xml->write(
198
-			'{DAV:}multistatus',
199
-			new MultiStatus($responses)
200
-		);
201
-
202
-		$this->server->httpResponse->setStatus(207);
203
-		$this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
204
-		$this->server->httpResponse->setBody($xml);
205
-
206
-		return false;
207
-	}
208
-
209
-	/**
210
-	 * Creates a new comment
211
-	 *
212
-	 * @param string $objectType e.g. "files"
213
-	 * @param string $objectId e.g. the file id
214
-	 * @param string $data JSON encoded string containing the properties of the tag to create
215
-	 * @param string $contentType content type of the data
216
-	 * @return IComment newly created comment
217
-	 *
218
-	 * @throws BadRequest if a field was missing
219
-	 * @throws UnsupportedMediaType if the content type is not supported
220
-	 */
221
-	private function createComment($objectType, $objectId, $data, $contentType = 'application/json') {
222
-		if (explode(';', $contentType)[0] === 'application/json') {
223
-			$data = json_decode($data, true, 512, JSON_THROW_ON_ERROR);
224
-		} else {
225
-			throw new UnsupportedMediaType();
226
-		}
227
-
228
-		$actorType = $data['actorType'];
229
-		$actorId = null;
230
-		if ($actorType === 'users') {
231
-			$user = $this->userSession->getUser();
232
-			if (!is_null($user)) {
233
-				$actorId = $user->getUID();
234
-			}
235
-		}
236
-		if (is_null($actorId)) {
237
-			throw new BadRequest('Invalid actor "' .  $actorType .'"');
238
-		}
239
-
240
-		try {
241
-			$comment = $this->commentsManager->create($actorType, $actorId, $objectType, $objectId);
242
-			$comment->setMessage($data['message']);
243
-			$comment->setVerb($data['verb']);
244
-			$this->commentsManager->save($comment);
245
-			return $comment;
246
-		} catch (\InvalidArgumentException $e) {
247
-			throw new BadRequest('Invalid input values', 0, $e);
248
-		} catch (\OCP\Comments\MessageTooLongException $e) {
249
-			$msg = 'Message exceeds allowed character limit of ';
250
-			throw new BadRequest($msg . \OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0,	$e);
251
-		}
252
-	}
47
+    // namespace
48
+    public const NS_OWNCLOUD = 'http://owncloud.org/ns';
49
+
50
+    public const REPORT_NAME = '{http://owncloud.org/ns}filter-comments';
51
+    public const REPORT_PARAM_LIMIT = '{http://owncloud.org/ns}limit';
52
+    public const REPORT_PARAM_OFFSET = '{http://owncloud.org/ns}offset';
53
+    public const REPORT_PARAM_TIMESTAMP = '{http://owncloud.org/ns}datetime';
54
+
55
+    /** @var ICommentsManager  */
56
+    protected $commentsManager;
57
+
58
+    /** @var \Sabre\DAV\Server $server */
59
+    private $server;
60
+
61
+    /** @var  \OCP\IUserSession */
62
+    protected $userSession;
63
+
64
+    /**
65
+     * Comments plugin
66
+     *
67
+     * @param ICommentsManager $commentsManager
68
+     * @param IUserSession $userSession
69
+     */
70
+    public function __construct(ICommentsManager $commentsManager, IUserSession $userSession) {
71
+        $this->commentsManager = $commentsManager;
72
+        $this->userSession = $userSession;
73
+    }
74
+
75
+    /**
76
+     * This initializes the plugin.
77
+     *
78
+     * This function is called by Sabre\DAV\Server, after
79
+     * addPlugin is called.
80
+     *
81
+     * This method should set up the required event subscriptions.
82
+     *
83
+     * @param Server $server
84
+     * @return void
85
+     */
86
+    public function initialize(Server $server) {
87
+        $this->server = $server;
88
+        if (strpos($this->server->getRequestUri(), 'comments/') !== 0) {
89
+            return;
90
+        }
91
+
92
+        $this->server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
93
+
94
+        $this->server->xml->classMap['DateTime'] = function (Writer $writer, \DateTime $value) {
95
+            $writer->write(\Sabre\HTTP\toDate($value));
96
+        };
97
+
98
+        $this->server->on('report', [$this, 'onReport']);
99
+        $this->server->on('method:POST', [$this, 'httpPost']);
100
+    }
101
+
102
+    /**
103
+     * POST operation on Comments collections
104
+     *
105
+     * @param RequestInterface $request request object
106
+     * @param ResponseInterface $response response object
107
+     * @return null|false
108
+     */
109
+    public function httpPost(RequestInterface $request, ResponseInterface $response) {
110
+        $path = $request->getPath();
111
+        $node = $this->server->tree->getNodeForPath($path);
112
+        if (!$node instanceof EntityCollection) {
113
+            return null;
114
+        }
115
+
116
+        $data = $request->getBodyAsString();
117
+        $comment = $this->createComment(
118
+            $node->getName(),
119
+            $node->getId(),
120
+            $data,
121
+            $request->getHeader('Content-Type')
122
+        );
123
+
124
+        // update read marker for the current user/poster to avoid
125
+        // having their own comments marked as unread
126
+        $node->setReadMarker(null);
127
+
128
+        $url = rtrim($request->getUrl(), '/') . '/' . urlencode($comment->getId());
129
+
130
+        $response->setHeader('Content-Location', $url);
131
+
132
+        // created
133
+        $response->setStatus(201);
134
+        return false;
135
+    }
136
+
137
+    /**
138
+     * Returns a list of reports this plugin supports.
139
+     *
140
+     * This will be used in the {DAV:}supported-report-set property.
141
+     *
142
+     * @param string $uri
143
+     * @return array
144
+     */
145
+    public function getSupportedReportSet($uri) {
146
+        return [self::REPORT_NAME];
147
+    }
148
+
149
+    /**
150
+     * REPORT operations to look for comments
151
+     *
152
+     * @param string $reportName
153
+     * @param array $report
154
+     * @param string $uri
155
+     * @return bool
156
+     * @throws NotFound
157
+     * @throws ReportNotSupported
158
+     */
159
+    public function onReport($reportName, $report, $uri) {
160
+        $node = $this->server->tree->getNodeForPath($uri);
161
+        if (!$node instanceof EntityCollection || $reportName !== self::REPORT_NAME) {
162
+            throw new ReportNotSupported();
163
+        }
164
+        $args = ['limit' => 0, 'offset' => 0, 'datetime' => null];
165
+        $acceptableParameters = [
166
+            $this::REPORT_PARAM_LIMIT,
167
+            $this::REPORT_PARAM_OFFSET,
168
+            $this::REPORT_PARAM_TIMESTAMP
169
+        ];
170
+        $ns = '{' . $this::NS_OWNCLOUD . '}';
171
+        foreach ($report as $parameter) {
172
+            if (!in_array($parameter['name'], $acceptableParameters) || empty($parameter['value'])) {
173
+                continue;
174
+            }
175
+            $args[str_replace($ns, '', $parameter['name'])] = $parameter['value'];
176
+        }
177
+
178
+        if (!is_null($args['datetime'])) {
179
+            $args['datetime'] = new \DateTime($args['datetime']);
180
+        }
181
+
182
+        $results = $node->findChildren($args['limit'], $args['offset'], $args['datetime']);
183
+
184
+        $responses = [];
185
+        foreach ($results as $node) {
186
+            $nodePath = $this->server->getRequestUri() . '/' . $node->comment->getId();
187
+            $resultSet = $this->server->getPropertiesForPath($nodePath, CommentNode::getPropertyNames());
188
+            if (isset($resultSet[0]) && isset($resultSet[0][200])) {
189
+                $responses[] = new Response(
190
+                    $this->server->getBaseUri() . $nodePath,
191
+                    [200 => $resultSet[0][200]],
192
+                    200
193
+                );
194
+            }
195
+        }
196
+
197
+        $xml = $this->server->xml->write(
198
+            '{DAV:}multistatus',
199
+            new MultiStatus($responses)
200
+        );
201
+
202
+        $this->server->httpResponse->setStatus(207);
203
+        $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
204
+        $this->server->httpResponse->setBody($xml);
205
+
206
+        return false;
207
+    }
208
+
209
+    /**
210
+     * Creates a new comment
211
+     *
212
+     * @param string $objectType e.g. "files"
213
+     * @param string $objectId e.g. the file id
214
+     * @param string $data JSON encoded string containing the properties of the tag to create
215
+     * @param string $contentType content type of the data
216
+     * @return IComment newly created comment
217
+     *
218
+     * @throws BadRequest if a field was missing
219
+     * @throws UnsupportedMediaType if the content type is not supported
220
+     */
221
+    private function createComment($objectType, $objectId, $data, $contentType = 'application/json') {
222
+        if (explode(';', $contentType)[0] === 'application/json') {
223
+            $data = json_decode($data, true, 512, JSON_THROW_ON_ERROR);
224
+        } else {
225
+            throw new UnsupportedMediaType();
226
+        }
227
+
228
+        $actorType = $data['actorType'];
229
+        $actorId = null;
230
+        if ($actorType === 'users') {
231
+            $user = $this->userSession->getUser();
232
+            if (!is_null($user)) {
233
+                $actorId = $user->getUID();
234
+            }
235
+        }
236
+        if (is_null($actorId)) {
237
+            throw new BadRequest('Invalid actor "' .  $actorType .'"');
238
+        }
239
+
240
+        try {
241
+            $comment = $this->commentsManager->create($actorType, $actorId, $objectType, $objectId);
242
+            $comment->setMessage($data['message']);
243
+            $comment->setVerb($data['verb']);
244
+            $this->commentsManager->save($comment);
245
+            return $comment;
246
+        } catch (\InvalidArgumentException $e) {
247
+            throw new BadRequest('Invalid input values', 0, $e);
248
+        } catch (\OCP\Comments\MessageTooLongException $e) {
249
+            $msg = 'Message exceeds allowed character limit of ';
250
+            throw new BadRequest($msg . \OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0,	$e);
251
+        }
252
+    }
253 253
 }
Please login to merge, or discard this patch.
apps/dav/lib/Files/BrowserErrorPagePlugin.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@
 block discarded – undo
99 99
 
100 100
 		$templateName = 'exception';
101 101
 		if ($httpCode === 403 || $httpCode === 404) {
102
-			$templateName = (string)$httpCode;
102
+			$templateName = (string) $httpCode;
103 103
 		}
104 104
 
105 105
 		$content = new OC_Template('core', $templateName, 'guest');
Please login to merge, or discard this patch.
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -34,86 +34,86 @@
 block discarded – undo
34 34
 use Sabre\DAV\ServerPlugin;
35 35
 
36 36
 class BrowserErrorPagePlugin extends ServerPlugin {
37
-	/** @var Server */
38
-	private $server;
37
+    /** @var Server */
38
+    private $server;
39 39
 
40
-	/**
41
-	 * This initializes the plugin.
42
-	 *
43
-	 * This function is called by Sabre\DAV\Server, after
44
-	 * addPlugin is called.
45
-	 *
46
-	 * This method should set up the required event subscriptions.
47
-	 *
48
-	 * @param Server $server
49
-	 * @return void
50
-	 */
51
-	public function initialize(Server $server) {
52
-		$this->server = $server;
53
-		$server->on('exception', [$this, 'logException'], 1000);
54
-	}
40
+    /**
41
+     * This initializes the plugin.
42
+     *
43
+     * This function is called by Sabre\DAV\Server, after
44
+     * addPlugin is called.
45
+     *
46
+     * This method should set up the required event subscriptions.
47
+     *
48
+     * @param Server $server
49
+     * @return void
50
+     */
51
+    public function initialize(Server $server) {
52
+        $this->server = $server;
53
+        $server->on('exception', [$this, 'logException'], 1000);
54
+    }
55 55
 
56
-	/**
57
-	 * @param IRequest $request
58
-	 * @return bool
59
-	 */
60
-	public static function isBrowserRequest(IRequest $request) {
61
-		if ($request->getMethod() !== 'GET') {
62
-			return false;
63
-		}
64
-		return $request->isUserAgent([
65
-			Request::USER_AGENT_IE,
66
-			Request::USER_AGENT_MS_EDGE,
67
-			Request::USER_AGENT_CHROME,
68
-			Request::USER_AGENT_FIREFOX,
69
-			Request::USER_AGENT_SAFARI,
70
-		]);
71
-	}
56
+    /**
57
+     * @param IRequest $request
58
+     * @return bool
59
+     */
60
+    public static function isBrowserRequest(IRequest $request) {
61
+        if ($request->getMethod() !== 'GET') {
62
+            return false;
63
+        }
64
+        return $request->isUserAgent([
65
+            Request::USER_AGENT_IE,
66
+            Request::USER_AGENT_MS_EDGE,
67
+            Request::USER_AGENT_CHROME,
68
+            Request::USER_AGENT_FIREFOX,
69
+            Request::USER_AGENT_SAFARI,
70
+        ]);
71
+    }
72 72
 
73
-	/**
74
-	 * @param \Exception $ex
75
-	 */
76
-	public function logException(\Exception $ex) {
77
-		if ($ex instanceof Exception) {
78
-			$httpCode = $ex->getHTTPCode();
79
-			$headers = $ex->getHTTPHeaders($this->server);
80
-		} else {
81
-			$httpCode = 500;
82
-			$headers = [];
83
-		}
84
-		$this->server->httpResponse->addHeaders($headers);
85
-		$this->server->httpResponse->setStatus($httpCode);
86
-		$body = $this->generateBody($httpCode);
87
-		$this->server->httpResponse->setBody($body);
88
-		$csp = new ContentSecurityPolicy();
89
-		$this->server->httpResponse->addHeader('Content-Security-Policy', $csp->buildPolicy());
90
-		$this->sendResponse();
91
-	}
73
+    /**
74
+     * @param \Exception $ex
75
+     */
76
+    public function logException(\Exception $ex) {
77
+        if ($ex instanceof Exception) {
78
+            $httpCode = $ex->getHTTPCode();
79
+            $headers = $ex->getHTTPHeaders($this->server);
80
+        } else {
81
+            $httpCode = 500;
82
+            $headers = [];
83
+        }
84
+        $this->server->httpResponse->addHeaders($headers);
85
+        $this->server->httpResponse->setStatus($httpCode);
86
+        $body = $this->generateBody($httpCode);
87
+        $this->server->httpResponse->setBody($body);
88
+        $csp = new ContentSecurityPolicy();
89
+        $this->server->httpResponse->addHeader('Content-Security-Policy', $csp->buildPolicy());
90
+        $this->sendResponse();
91
+    }
92 92
 
93
-	/**
94
-	 * @codeCoverageIgnore
95
-	 * @return bool|string
96
-	 */
97
-	public function generateBody(int $httpCode) {
98
-		$request = \OC::$server->getRequest();
93
+    /**
94
+     * @codeCoverageIgnore
95
+     * @return bool|string
96
+     */
97
+    public function generateBody(int $httpCode) {
98
+        $request = \OC::$server->getRequest();
99 99
 
100
-		$templateName = 'exception';
101
-		if ($httpCode === 403 || $httpCode === 404) {
102
-			$templateName = (string)$httpCode;
103
-		}
100
+        $templateName = 'exception';
101
+        if ($httpCode === 403 || $httpCode === 404) {
102
+            $templateName = (string)$httpCode;
103
+        }
104 104
 
105
-		$content = new OC_Template('core', $templateName, 'guest');
106
-		$content->assign('title', $this->server->httpResponse->getStatusText());
107
-		$content->assign('remoteAddr', $request->getRemoteAddress());
108
-		$content->assign('requestID', $request->getId());
109
-		return $content->fetchPage();
110
-	}
105
+        $content = new OC_Template('core', $templateName, 'guest');
106
+        $content->assign('title', $this->server->httpResponse->getStatusText());
107
+        $content->assign('remoteAddr', $request->getRemoteAddress());
108
+        $content->assign('requestID', $request->getId());
109
+        return $content->fetchPage();
110
+    }
111 111
 
112
-	/**
113
-	 * @codeCoverageIgnore
114
-	 */
115
-	public function sendResponse() {
116
-		$this->server->sapi->sendResponse($this->server->httpResponse);
117
-		exit();
118
-	}
112
+    /**
113
+     * @codeCoverageIgnore
114
+     */
115
+    public function sendResponse() {
116
+        $this->server->sapi->sendResponse($this->server->httpResponse);
117
+        exit();
118
+    }
119 119
 }
Please login to merge, or discard this patch.
apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -34,52 +34,52 @@
 block discarded – undo
34 34
 
35 35
 class RefreshWebcalJobRegistrar implements IRepairStep {
36 36
 
37
-	/** @var IDBConnection */
38
-	private $connection;
37
+    /** @var IDBConnection */
38
+    private $connection;
39 39
 
40
-	/** @var IJobList */
41
-	private $jobList;
40
+    /** @var IJobList */
41
+    private $jobList;
42 42
 
43
-	/**
44
-	 * FixBirthdayCalendarComponent constructor.
45
-	 *
46
-	 * @param IDBConnection $connection
47
-	 * @param IJobList $jobList
48
-	 */
49
-	public function __construct(IDBConnection $connection, IJobList $jobList) {
50
-		$this->connection = $connection;
51
-		$this->jobList = $jobList;
52
-	}
43
+    /**
44
+     * FixBirthdayCalendarComponent constructor.
45
+     *
46
+     * @param IDBConnection $connection
47
+     * @param IJobList $jobList
48
+     */
49
+    public function __construct(IDBConnection $connection, IJobList $jobList) {
50
+        $this->connection = $connection;
51
+        $this->jobList = $jobList;
52
+    }
53 53
 
54
-	/**
55
-	 * @inheritdoc
56
-	 */
57
-	public function getName() {
58
-		return 'Registering background jobs to update cache for webcal calendars';
59
-	}
54
+    /**
55
+     * @inheritdoc
56
+     */
57
+    public function getName() {
58
+        return 'Registering background jobs to update cache for webcal calendars';
59
+    }
60 60
 
61
-	/**
62
-	 * @inheritdoc
63
-	 */
64
-	public function run(IOutput $output) {
65
-		$query = $this->connection->getQueryBuilder();
66
-		$query->select(['principaluri', 'uri'])
67
-			->from('calendarsubscriptions');
68
-		$stmt = $query->execute();
61
+    /**
62
+     * @inheritdoc
63
+     */
64
+    public function run(IOutput $output) {
65
+        $query = $this->connection->getQueryBuilder();
66
+        $query->select(['principaluri', 'uri'])
67
+            ->from('calendarsubscriptions');
68
+        $stmt = $query->execute();
69 69
 
70
-		$count = 0;
71
-		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
72
-			$args = [
73
-				'principaluri' => $row['principaluri'],
74
-				'uri' => $row['uri'],
75
-			];
70
+        $count = 0;
71
+        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
72
+            $args = [
73
+                'principaluri' => $row['principaluri'],
74
+                'uri' => $row['uri'],
75
+            ];
76 76
 
77
-			if (!$this->jobList->has(RefreshWebcalJob::class, $args)) {
78
-				$this->jobList->add(RefreshWebcalJob::class, $args);
79
-				$count++;
80
-			}
81
-		}
77
+            if (!$this->jobList->has(RefreshWebcalJob::class, $args)) {
78
+                $this->jobList->add(RefreshWebcalJob::class, $args);
79
+                $count++;
80
+            }
81
+        }
82 82
 
83
-		$output->info("Added $count background jobs to update webcal calendars");
84
-	}
83
+        $output->info("Added $count background jobs to update webcal calendars");
84
+    }
85 85
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Helper/ScopeContext.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -28,51 +28,51 @@
 block discarded – undo
28 28
 use OCP\WorkflowEngine\IManager;
29 29
 
30 30
 class ScopeContext {
31
-	/** @var int */
32
-	private $scope;
33
-	/** @var string */
34
-	private $scopeId;
35
-	/** @var string */
36
-	private $hash;
31
+    /** @var int */
32
+    private $scope;
33
+    /** @var string */
34
+    private $scopeId;
35
+    /** @var string */
36
+    private $hash;
37 37
 
38
-	public function __construct(int $scope, string $scopeId = null) {
39
-		$this->scope = $this->evaluateScope($scope);
40
-		$this->scopeId = $this->evaluateScopeId($scopeId);
41
-	}
38
+    public function __construct(int $scope, string $scopeId = null) {
39
+        $this->scope = $this->evaluateScope($scope);
40
+        $this->scopeId = $this->evaluateScopeId($scopeId);
41
+    }
42 42
 
43
-	private function evaluateScope(int $scope): int {
44
-		if (in_array($scope, [IManager::SCOPE_ADMIN, IManager::SCOPE_USER], true)) {
45
-			return $scope;
46
-		}
47
-		throw new \InvalidArgumentException('Invalid scope');
48
-	}
43
+    private function evaluateScope(int $scope): int {
44
+        if (in_array($scope, [IManager::SCOPE_ADMIN, IManager::SCOPE_USER], true)) {
45
+            return $scope;
46
+        }
47
+        throw new \InvalidArgumentException('Invalid scope');
48
+    }
49 49
 
50
-	private function evaluateScopeId(string $scopeId = null): string {
51
-		if ($this->scope === IManager::SCOPE_USER
52
-			&& trim((string)$scopeId) === '') {
53
-			throw new \InvalidArgumentException('user scope requires a user id');
54
-		}
55
-		return trim((string)$scopeId);
56
-	}
50
+    private function evaluateScopeId(string $scopeId = null): string {
51
+        if ($this->scope === IManager::SCOPE_USER
52
+            && trim((string)$scopeId) === '') {
53
+            throw new \InvalidArgumentException('user scope requires a user id');
54
+        }
55
+        return trim((string)$scopeId);
56
+    }
57 57
 
58
-	/**
59
-	 * @return int
60
-	 */
61
-	public function getScope(): int {
62
-		return $this->scope;
63
-	}
58
+    /**
59
+     * @return int
60
+     */
61
+    public function getScope(): int {
62
+        return $this->scope;
63
+    }
64 64
 
65
-	/**
66
-	 * @return string
67
-	 */
68
-	public function getScopeId(): string {
69
-		return $this->scopeId;
70
-	}
65
+    /**
66
+     * @return string
67
+     */
68
+    public function getScopeId(): string {
69
+        return $this->scopeId;
70
+    }
71 71
 
72
-	public function getHash(): string {
73
-		if ($this->hash === null) {
74
-			$this->hash = \hash('sha256', $this->getScope() . '::' . $this->getScopeId());
75
-		}
76
-		return $this->hash;
77
-	}
72
+    public function getHash(): string {
73
+        if ($this->hash === null) {
74
+            $this->hash = \hash('sha256', $this->getScope() . '::' . $this->getScopeId());
75
+        }
76
+        return $this->hash;
77
+    }
78 78
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 
50 50
 	private function evaluateScopeId(string $scopeId = null): string {
51 51
 		if ($this->scope === IManager::SCOPE_USER
52
-			&& trim((string)$scopeId) === '') {
52
+			&& trim((string) $scopeId) === '') {
53 53
 			throw new \InvalidArgumentException('user scope requires a user id');
54 54
 		}
55
-		return trim((string)$scopeId);
55
+		return trim((string) $scopeId);
56 56
 	}
57 57
 
58 58
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
 	public function getHash(): string {
73 73
 		if ($this->hash === null) {
74
-			$this->hash = \hash('sha256', $this->getScope() . '::' . $this->getScopeId());
74
+			$this->hash = \hash('sha256', $this->getScope().'::'.$this->getScopeId());
75 75
 		}
76 76
 		return $this->hash;
77 77
 	}
Please login to merge, or discard this patch.
apps/workflowengine/lib/Helper/LogContext.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -30,67 +30,67 @@
 block discarded – undo
30 30
 use OCP\WorkflowEngine\IOperation;
31 31
 
32 32
 class LogContext {
33
-	/** @var array */
34
-	protected $details;
33
+    /** @var array */
34
+    protected $details;
35 35
 
36
-	public function setDescription(string $description): LogContext {
37
-		$this->details['message'] = $description;
38
-		return $this;
39
-	}
36
+    public function setDescription(string $description): LogContext {
37
+        $this->details['message'] = $description;
38
+        return $this;
39
+    }
40 40
 
41
-	public function setScopes(array $scopes): LogContext {
42
-		$this->details['scopes'] = [];
43
-		foreach ($scopes as $scope) {
44
-			if ($scope instanceof ScopeContext) {
45
-				switch ($scope->getScope()) {
46
-					case IManager::SCOPE_ADMIN:
47
-						$this->details['scopes'][] = ['scope' => 'admin'];
48
-						break;
49
-					case IManager::SCOPE_USER:
50
-						$this->details['scopes'][] = [
51
-							'scope' => 'user',
52
-							'uid' => $scope->getScopeId(),
53
-						];
54
-						break;
55
-					default:
56
-						continue 2;
57
-				}
58
-			}
59
-		}
60
-		return $this;
61
-	}
41
+    public function setScopes(array $scopes): LogContext {
42
+        $this->details['scopes'] = [];
43
+        foreach ($scopes as $scope) {
44
+            if ($scope instanceof ScopeContext) {
45
+                switch ($scope->getScope()) {
46
+                    case IManager::SCOPE_ADMIN:
47
+                        $this->details['scopes'][] = ['scope' => 'admin'];
48
+                        break;
49
+                    case IManager::SCOPE_USER:
50
+                        $this->details['scopes'][] = [
51
+                            'scope' => 'user',
52
+                            'uid' => $scope->getScopeId(),
53
+                        ];
54
+                        break;
55
+                    default:
56
+                        continue 2;
57
+                }
58
+            }
59
+        }
60
+        return $this;
61
+    }
62 62
 
63
-	public function setOperation(?IOperation $operation): LogContext {
64
-		if ($operation instanceof IOperation) {
65
-			$this->details['operation'] = [
66
-				'class' => get_class($operation),
67
-				'name' => $operation->getDisplayName(),
68
-			];
69
-		}
70
-		return $this;
71
-	}
63
+    public function setOperation(?IOperation $operation): LogContext {
64
+        if ($operation instanceof IOperation) {
65
+            $this->details['operation'] = [
66
+                'class' => get_class($operation),
67
+                'name' => $operation->getDisplayName(),
68
+            ];
69
+        }
70
+        return $this;
71
+    }
72 72
 
73
-	public function setEntity(?IEntity $entity): LogContext {
74
-		if ($entity instanceof IEntity) {
75
-			$this->details['entity'] = [
76
-				'class' => get_class($entity),
77
-				'name' => $entity->getName(),
78
-			];
79
-		}
80
-		return $this;
81
-	}
73
+    public function setEntity(?IEntity $entity): LogContext {
74
+        if ($entity instanceof IEntity) {
75
+            $this->details['entity'] = [
76
+                'class' => get_class($entity),
77
+                'name' => $entity->getName(),
78
+            ];
79
+        }
80
+        return $this;
81
+    }
82 82
 
83
-	public function setConfiguration(array $configuration): LogContext {
84
-		$this->details['configuration'] = $configuration;
85
-		return $this;
86
-	}
83
+    public function setConfiguration(array $configuration): LogContext {
84
+        $this->details['configuration'] = $configuration;
85
+        return $this;
86
+    }
87 87
 
88
-	public function setEventName(string $eventName): LogContext {
89
-		$this->details['eventName'] = $eventName;
90
-		return $this;
91
-	}
88
+    public function setEventName(string $eventName): LogContext {
89
+        $this->details['eventName'] = $eventName;
90
+        return $this;
91
+    }
92 92
 
93
-	public function getDetails(): array {
94
-		return $this->details;
95
-	}
93
+    public function getDetails(): array {
94
+        return $this->details;
95
+    }
96 96
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Controller/GlobalWorkflowsController.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@
 block discarded – undo
30 30
 
31 31
 class GlobalWorkflowsController extends AWorkflowController {
32 32
 
33
-	/** @var ScopeContext */
34
-	private $scopeContext;
33
+    /** @var ScopeContext */
34
+    private $scopeContext;
35 35
 
36
-	protected function getScopeContext(): ScopeContext {
37
-		if ($this->scopeContext === null) {
38
-			$this->scopeContext = new ScopeContext(IManager::SCOPE_ADMIN);
39
-		}
40
-		return $this->scopeContext;
41
-	}
36
+    protected function getScopeContext(): ScopeContext {
37
+        if ($this->scopeContext === null) {
38
+            $this->scopeContext = new ScopeContext(IManager::SCOPE_ADMIN);
39
+        }
40
+        return $this->scopeContext;
41
+    }
42 42
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/ShareBackend/Folder.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@
 block discarded – undo
111 111
 		while (!empty($parents)) {
112 112
 			$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
113 113
 
114
-			$parents = array_map(function ($parent) use ($qb) {
114
+			$parents = array_map(function($parent) use ($qb) {
115 115
 				return $qb->createNamedParameter($parent);
116 116
 			}, $parents);
117 117
 
Please login to merge, or discard this patch.
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -30,108 +30,108 @@
 block discarded – undo
30 30
 
31 31
 class Folder extends File implements \OCP\Share_Backend_Collection {
32 32
 
33
-	/**
34
-	 * get shared parents
35
-	 *
36
-	 * @param int $itemSource item source ID
37
-	 * @param string $shareWith with whom should the item be shared
38
-	 * @param string $owner owner of the item
39
-	 * @return array with shares
40
-	 */
41
-	public function getParents($itemSource, $shareWith = null, $owner = null) {
42
-		$result = [];
43
-		$parent = $this->getParentId($itemSource);
33
+    /**
34
+     * get shared parents
35
+     *
36
+     * @param int $itemSource item source ID
37
+     * @param string $shareWith with whom should the item be shared
38
+     * @param string $owner owner of the item
39
+     * @return array with shares
40
+     */
41
+    public function getParents($itemSource, $shareWith = null, $owner = null) {
42
+        $result = [];
43
+        $parent = $this->getParentId($itemSource);
44 44
 
45
-		$userManager = \OC::$server->getUserManager();
45
+        $userManager = \OC::$server->getUserManager();
46 46
 
47
-		while ($parent) {
48
-			$shares = \OCP\Share::getItemSharedWithUser('folder', $parent, $shareWith, $owner);
49
-			if ($shares) {
50
-				foreach ($shares as $share) {
51
-					$name = basename($share['path']);
52
-					$share['collection']['path'] = $name;
53
-					$share['collection']['item_type'] = 'folder';
54
-					$share['file_path'] = $name;
47
+        while ($parent) {
48
+            $shares = \OCP\Share::getItemSharedWithUser('folder', $parent, $shareWith, $owner);
49
+            if ($shares) {
50
+                foreach ($shares as $share) {
51
+                    $name = basename($share['path']);
52
+                    $share['collection']['path'] = $name;
53
+                    $share['collection']['item_type'] = 'folder';
54
+                    $share['file_path'] = $name;
55 55
 
56
-					$ownerUser = $userManager->get($share['uid_owner']);
57
-					$displayNameOwner = $ownerUser === null ? $share['uid_owner'] : $ownerUser->getDisplayName();
58
-					$shareWithUser = $userManager->get($share['share_with']);
59
-					$displayNameShareWith = $shareWithUser === null ? $share['share_with'] : $shareWithUser->getDisplayName();
60
-					$share['displayname_owner'] = $displayNameOwner ? $displayNameOwner : $share['uid_owner'];
61
-					$share['share_with_displayname'] = $displayNameShareWith ? $displayNameShareWith : $share['uid_owner'];
56
+                    $ownerUser = $userManager->get($share['uid_owner']);
57
+                    $displayNameOwner = $ownerUser === null ? $share['uid_owner'] : $ownerUser->getDisplayName();
58
+                    $shareWithUser = $userManager->get($share['share_with']);
59
+                    $displayNameShareWith = $shareWithUser === null ? $share['share_with'] : $shareWithUser->getDisplayName();
60
+                    $share['displayname_owner'] = $displayNameOwner ? $displayNameOwner : $share['uid_owner'];
61
+                    $share['share_with_displayname'] = $displayNameShareWith ? $displayNameShareWith : $share['uid_owner'];
62 62
 
63
-					$result[] = $share;
64
-				}
65
-			}
66
-			$parent = $this->getParentId($parent);
67
-		}
63
+                    $result[] = $share;
64
+                }
65
+            }
66
+            $parent = $this->getParentId($parent);
67
+        }
68 68
 
69
-		return $result;
70
-	}
69
+        return $result;
70
+    }
71 71
 
72
-	/**
73
-	 * get file cache ID of parent
74
-	 *
75
-	 * @param int $child file cache ID of child
76
-	 * @return mixed parent ID or null
77
-	 */
78
-	private function getParentId($child) {
79
-		$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
80
-		$qb->select('parent')
81
-			->from('filecache')
82
-			->where(
83
-				$qb->expr()->eq('fileid', $qb->createNamedParameter($child))
84
-			);
85
-		$result = $qb->execute();
86
-		$row = $result->fetch();
87
-		$result->closeCursor();
88
-		return $row ? $row['parent'] : null;
89
-	}
72
+    /**
73
+     * get file cache ID of parent
74
+     *
75
+     * @param int $child file cache ID of child
76
+     * @return mixed parent ID or null
77
+     */
78
+    private function getParentId($child) {
79
+        $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
80
+        $qb->select('parent')
81
+            ->from('filecache')
82
+            ->where(
83
+                $qb->expr()->eq('fileid', $qb->createNamedParameter($child))
84
+            );
85
+        $result = $qb->execute();
86
+        $row = $result->fetch();
87
+        $result->closeCursor();
88
+        return $row ? $row['parent'] : null;
89
+    }
90 90
 
91
-	public function getChildren($itemSource) {
92
-		$children = [];
93
-		$parents = [$itemSource];
91
+    public function getChildren($itemSource) {
92
+        $children = [];
93
+        $parents = [$itemSource];
94 94
 
95
-		$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
96
-		$qb->select('id')
97
-			->from('mimetypes')
98
-			->where(
99
-				$qb->expr()->eq('mimetype', $qb->createNamedParameter('httpd/unix-directory'))
100
-			);
101
-		$result = $qb->execute();
102
-		$row = $result->fetch();
103
-		$result->closeCursor();
95
+        $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
96
+        $qb->select('id')
97
+            ->from('mimetypes')
98
+            ->where(
99
+                $qb->expr()->eq('mimetype', $qb->createNamedParameter('httpd/unix-directory'))
100
+            );
101
+        $result = $qb->execute();
102
+        $row = $result->fetch();
103
+        $result->closeCursor();
104 104
 
105
-		if ($row = $result->fetchRow()) {
106
-			$mimetype = (int) $row['id'];
107
-		} else {
108
-			$mimetype = -1;
109
-		}
110
-		while (!empty($parents)) {
111
-			$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
105
+        if ($row = $result->fetchRow()) {
106
+            $mimetype = (int) $row['id'];
107
+        } else {
108
+            $mimetype = -1;
109
+        }
110
+        while (!empty($parents)) {
111
+            $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
112 112
 
113
-			$parents = array_map(function ($parent) use ($qb) {
114
-				return $qb->createNamedParameter($parent);
115
-			}, $parents);
113
+            $parents = array_map(function ($parent) use ($qb) {
114
+                return $qb->createNamedParameter($parent);
115
+            }, $parents);
116 116
 
117
-			$qb->select('`fileid', 'name', '`mimetype')
118
-				->from('filecache')
119
-				->where(
120
-					$qb->expr()->in('parent', $parents)
121
-				);
117
+            $qb->select('`fileid', 'name', '`mimetype')
118
+                ->from('filecache')
119
+                ->where(
120
+                    $qb->expr()->in('parent', $parents)
121
+                );
122 122
 
123
-			$result = $qb->execute();
123
+            $result = $qb->execute();
124 124
 
125
-			$parents = [];
126
-			while ($file = $result->fetch()) {
127
-				$children[] = ['source' => $file['fileid'], 'file_path' => $file['name']];
128
-				// If a child folder is found look inside it
129
-				if ((int) $file['mimetype'] === $mimetype) {
130
-					$parents[] = $file['fileid'];
131
-				}
132
-			}
133
-			$result->closeCursor();
134
-		}
135
-		return $children;
136
-	}
125
+            $parents = [];
126
+            while ($file = $result->fetch()) {
127
+                $children[] = ['source' => $file['fileid'], 'file_path' => $file['name']];
128
+                // If a child folder is found look inside it
129
+                if ((int) $file['mimetype'] === $mimetype) {
130
+                    $parents[] = $file['fileid'];
131
+                }
132
+            }
133
+            $result->closeCursor();
134
+        }
135
+        return $children;
136
+    }
137 137
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		}
61 61
 		$userFolder = $this->rootFolder->getUserFolder($user->getUID());
62 62
 		/** @var Node[] $nodes */
63
-		$nodes = $userFolder->getById((int)$context['itemId']);
63
+		$nodes = $userFolder->getById((int) $context['itemId']);
64 64
 		if (count($nodes) === 0) {
65 65
 			return;
66 66
 		}
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
 			// at least on PHP 5.6 usort turned out to be not stable. So we add
75 75
 			// the current index to the value and compare it on a draw
76 76
 			$i = 0;
77
-			$workArray = array_map(function ($element) use (&$i) {
77
+			$workArray = array_map(function($element) use (&$i) {
78 78
 				return [$i++, $element];
79 79
 			}, $byType);
80 80
 
81
-			usort($workArray, function ($a, $b) use ($al, $type) {
81
+			usort($workArray, function($a, $b) use ($al, $type) {
82 82
 				$result = $this->compare($a[1], $b[1], $al[$type]);
83 83
 				if ($result === 0) {
84 84
 					$result = $a[0] - $b[0];
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 		$a = $a['value']['shareWith'];
102 102
 		$b = $b['value']['shareWith'];
103 103
 
104
-		$valueA = (int)in_array($a, $al, true);
105
-		$valueB = (int)in_array($b, $al, true);
104
+		$valueA = (int) in_array($a, $al, true);
105
+		$valueB = (int) in_array($b, $al, true);
106 106
 
107 107
 		return $valueB - $valueA;
108 108
 	}
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -32,75 +32,75 @@
 block discarded – undo
32 32
 
33 33
 class ShareRecipientSorter implements ISorter {
34 34
 
35
-	private IManager $shareManager;
36
-	private IRootFolder $rootFolder;
37
-	private IUserSession $userSession;
35
+    private IManager $shareManager;
36
+    private IRootFolder $rootFolder;
37
+    private IUserSession $userSession;
38 38
 
39
-	public function __construct(IManager $shareManager, IRootFolder $rootFolder, IUserSession $userSession) {
40
-		$this->shareManager = $shareManager;
41
-		$this->rootFolder = $rootFolder;
42
-		$this->userSession = $userSession;
43
-	}
39
+    public function __construct(IManager $shareManager, IRootFolder $rootFolder, IUserSession $userSession) {
40
+        $this->shareManager = $shareManager;
41
+        $this->rootFolder = $rootFolder;
42
+        $this->userSession = $userSession;
43
+    }
44 44
 
45
-	public function getId(): string {
46
-		return 'share-recipients';
47
-	}
45
+    public function getId(): string {
46
+        return 'share-recipients';
47
+    }
48 48
 
49
-	public function sort(array &$sortArray, array $context) {
50
-		// let's be tolerant. Comments  uses "files" by default, other usages are often singular
51
-		if ($context['itemType'] !== 'files' && $context['itemType'] !== 'file') {
52
-			return;
53
-		}
54
-		$user = $this->userSession->getUser();
55
-		if ($user === null) {
56
-			return;
57
-		}
58
-		$userFolder = $this->rootFolder->getUserFolder($user->getUID());
59
-		/** @var Node[] $nodes */
60
-		$nodes = $userFolder->getById((int)$context['itemId']);
61
-		if (count($nodes) === 0) {
62
-			return;
63
-		}
64
-		$al = $this->shareManager->getAccessList($nodes[0]);
49
+    public function sort(array &$sortArray, array $context) {
50
+        // let's be tolerant. Comments  uses "files" by default, other usages are often singular
51
+        if ($context['itemType'] !== 'files' && $context['itemType'] !== 'file') {
52
+            return;
53
+        }
54
+        $user = $this->userSession->getUser();
55
+        if ($user === null) {
56
+            return;
57
+        }
58
+        $userFolder = $this->rootFolder->getUserFolder($user->getUID());
59
+        /** @var Node[] $nodes */
60
+        $nodes = $userFolder->getById((int)$context['itemId']);
61
+        if (count($nodes) === 0) {
62
+            return;
63
+        }
64
+        $al = $this->shareManager->getAccessList($nodes[0]);
65 65
 
66
-		foreach ($sortArray as $type => &$byType) {
67
-			if (!isset($al[$type]) || !is_array($al[$type])) {
68
-				continue;
69
-			}
66
+        foreach ($sortArray as $type => &$byType) {
67
+            if (!isset($al[$type]) || !is_array($al[$type])) {
68
+                continue;
69
+            }
70 70
 
71
-			// at least on PHP 5.6 usort turned out to be not stable. So we add
72
-			// the current index to the value and compare it on a draw
73
-			$i = 0;
74
-			$workArray = array_map(function ($element) use (&$i) {
75
-				return [$i++, $element];
76
-			}, $byType);
71
+            // at least on PHP 5.6 usort turned out to be not stable. So we add
72
+            // the current index to the value and compare it on a draw
73
+            $i = 0;
74
+            $workArray = array_map(function ($element) use (&$i) {
75
+                return [$i++, $element];
76
+            }, $byType);
77 77
 
78
-			usort($workArray, function ($a, $b) use ($al, $type) {
79
-				$result = $this->compare($a[1], $b[1], $al[$type]);
80
-				if ($result === 0) {
81
-					$result = $a[0] - $b[0];
82
-				}
83
-				return $result;
84
-			});
78
+            usort($workArray, function ($a, $b) use ($al, $type) {
79
+                $result = $this->compare($a[1], $b[1], $al[$type]);
80
+                if ($result === 0) {
81
+                    $result = $a[0] - $b[0];
82
+                }
83
+                return $result;
84
+            });
85 85
 
86
-			// and remove the index values again
87
-			$byType = array_column($workArray, 1);
88
-		}
89
-	}
86
+            // and remove the index values again
87
+            $byType = array_column($workArray, 1);
88
+        }
89
+    }
90 90
 
91
-	/**
92
-	 * @param array $a
93
-	 * @param array $b
94
-	 * @param array $al
95
-	 * @return int
96
-	 */
97
-	protected function compare(array $a, array $b, array $al) {
98
-		$a = $a['value']['shareWith'];
99
-		$b = $b['value']['shareWith'];
91
+    /**
92
+     * @param array $a
93
+     * @param array $b
94
+     * @param array $al
95
+     * @return int
96
+     */
97
+    protected function compare(array $a, array $b, array $al) {
98
+        $a = $a['value']['shareWith'];
99
+        $b = $b['value']['shareWith'];
100 100
 
101
-		$valueA = (int)in_array($a, $al, true);
102
-		$valueB = (int)in_array($b, $al, true);
101
+        $valueA = (int)in_array($a, $al, true);
102
+        $valueB = (int)in_array($b, $al, true);
103 103
 
104
-		return $valueB - $valueA;
105
-	}
104
+        return $valueB - $valueA;
105
+    }
106 106
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -38,47 +38,47 @@
 block discarded – undo
38 38
 
39 39
 class UserShareAcceptanceListener implements IEventListener {
40 40
 
41
-	/** @var IConfig */
42
-	private $config;
43
-	/** @var IManager */
44
-	private $shareManager;
45
-	/** @var IGroupManager */
46
-	private $groupManager;
41
+    /** @var IConfig */
42
+    private $config;
43
+    /** @var IManager */
44
+    private $shareManager;
45
+    /** @var IGroupManager */
46
+    private $groupManager;
47 47
 
48
-	public function __construct(IConfig $config, IManager $shareManager, IGroupManager $groupManager) {
49
-		$this->config = $config;
50
-		$this->shareManager = $shareManager;
51
-		$this->groupManager = $groupManager;
52
-	}
48
+    public function __construct(IConfig $config, IManager $shareManager, IGroupManager $groupManager) {
49
+        $this->config = $config;
50
+        $this->shareManager = $shareManager;
51
+        $this->groupManager = $groupManager;
52
+    }
53 53
 
54
-	public function handle(Event $event): void {
55
-		if (!($event instanceof ShareCreatedEvent)) {
56
-			return;
57
-		}
54
+    public function handle(Event $event): void {
55
+        if (!($event instanceof ShareCreatedEvent)) {
56
+            return;
57
+        }
58 58
 
59
-		$share = $event->getShare();
59
+        $share = $event->getShare();
60 60
 
61
-		if ($share->getShareType() === IShare::TYPE_USER) {
62
-			$this->handleAutoAccept($share, $share->getSharedWith());
63
-		} elseif ($share->getShareType() === IShare::TYPE_GROUP) {
64
-			$group = $this->groupManager->get($share->getSharedWith());
61
+        if ($share->getShareType() === IShare::TYPE_USER) {
62
+            $this->handleAutoAccept($share, $share->getSharedWith());
63
+        } elseif ($share->getShareType() === IShare::TYPE_GROUP) {
64
+            $group = $this->groupManager->get($share->getSharedWith());
65 65
 
66
-			if ($group === null) {
67
-				return;
68
-			}
66
+            if ($group === null) {
67
+                return;
68
+            }
69 69
 
70
-			$users = $group->getUsers();
71
-			foreach ($users as $user) {
72
-				$this->handleAutoAccept($share, $user->getUID());
73
-			}
74
-		}
75
-	}
70
+            $users = $group->getUsers();
71
+            foreach ($users as $user) {
72
+                $this->handleAutoAccept($share, $user->getUID());
73
+            }
74
+        }
75
+    }
76 76
 
77
-	private function handleAutoAccept(IShare $share, string $userId) {
78
-		$defaultAcceptSystemConfig = $this->config->getSystemValueBool('sharing.enable_share_accept', false) ? 'no' : 'yes';
79
-		$acceptDefault = $this->config->getUserValue($userId, Application::APP_ID, 'default_accept', $defaultAcceptSystemConfig) === 'yes';
80
-		if (!$this->config->getSystemValueBool('sharing.force_share_accept', false) && $acceptDefault) {
81
-			$this->shareManager->acceptShare($share, $userId);
82
-		}
83
-	}
77
+    private function handleAutoAccept(IShare $share, string $userId) {
78
+        $defaultAcceptSystemConfig = $this->config->getSystemValueBool('sharing.enable_share_accept', false) ? 'no' : 'yes';
79
+        $acceptDefault = $this->config->getUserValue($userId, Application::APP_ID, 'default_accept', $defaultAcceptSystemConfig) === 'yes';
80
+        if (!$this->config->getSystemValueBool('sharing.force_share_accept', false) && $acceptDefault) {
81
+            $this->shareManager->acceptShare($share, $userId);
82
+        }
83
+    }
84 84
 }
Please login to merge, or discard this patch.