@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | function propFind(PropFind $propFind, INode $node) { |
82 | 82 | if ($node instanceof IPrincipal) { |
83 | 83 | // overwrite Sabre/Dav's implementation |
84 | - $propFind->handle('{' . self::NS_CALDAV . '}calendar-user-type', function () use ($node) { |
|
84 | + $propFind->handle('{'.self::NS_CALDAV.'}calendar-user-type', function() use ($node) { |
|
85 | 85 | if ($node instanceof IProperties) { |
86 | - $calendarUserType = '{' . self::NS_CALDAV . '}calendar-user-type'; |
|
86 | + $calendarUserType = '{'.self::NS_CALDAV.'}calendar-user-type'; |
|
87 | 87 | $props = $node->getProperties([$calendarUserType]); |
88 | 88 | |
89 | 89 | if (isset($props[$calendarUserType])) { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | $dtstart = $vevent->DTSTART; |
192 | - $dtend = $this->getDTEndFromVEvent($vevent); |
|
192 | + $dtend = $this->getDTEndFromVEvent($vevent); |
|
193 | 193 | $uid = $vevent->UID->getValue(); |
194 | 194 | $sequence = isset($vevent->SEQUENCE) ? $vevent->SEQUENCE->getValue() : 0; |
195 | 195 | $recurrenceId = isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->serialize() : ''; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | */ |
262 | 262 | function propFindDefaultCalendarUrl(PropFind $propFind, INode $node) { |
263 | 263 | if ($node instanceof IPrincipal) { |
264 | - $propFind->handle('{' . self::NS_CALDAV . '}schedule-default-calendar-URL', function () use ($node) { |
|
264 | + $propFind->handle('{'.self::NS_CALDAV.'}schedule-default-calendar-URL', function() use ($node) { |
|
265 | 265 | /** @var \OCA\DAV\CalDAV\Plugin $caldavPlugin */ |
266 | 266 | $caldavPlugin = $this->server->getPlugin('caldav'); |
267 | 267 | $principalUrl = $node->getPrincipalUrl(); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | ]); |
293 | 293 | } |
294 | 294 | |
295 | - $result = $this->server->getPropertiesForPath($calendarHomePath . '/' . $uri, [], 1); |
|
295 | + $result = $this->server->getPropertiesForPath($calendarHomePath.'/'.$uri, [], 1); |
|
296 | 296 | if (empty($result)) { |
297 | 297 | return null; |
298 | 298 | } |
@@ -308,8 +308,8 @@ discard block |
||
308 | 308 | * @param string $principal |
309 | 309 | * @return string? |
310 | 310 | */ |
311 | - protected function getCalendarUserTypeForPrincipal($principal):?string { |
|
312 | - $calendarUserType = '{' . self::NS_CALDAV . '}calendar-user-type'; |
|
311 | + protected function getCalendarUserTypeForPrincipal($principal): ?string { |
|
312 | + $calendarUserType = '{'.self::NS_CALDAV.'}calendar-user-type'; |
|
313 | 313 | $properties = $this->server->getProperties( |
314 | 314 | $principal, |
315 | 315 | [$calendarUserType] |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @param ITip\Message $iTipMessage |
328 | 328 | * @return null|Property |
329 | 329 | */ |
330 | - private function getCurrentAttendee(ITip\Message $iTipMessage):?Property { |
|
330 | + private function getCurrentAttendee(ITip\Message $iTipMessage): ?Property { |
|
331 | 331 | /** @var VEvent $vevent */ |
332 | 332 | $vevent = $iTipMessage->message->VEVENT; |
333 | 333 | $attendees = $vevent->select('ATTENDEE'); |
@@ -405,8 +405,8 @@ discard block |
||
405 | 405 | ['{http://sabredav.org/ns}email-address' => $this->stripOffMailTo($email)], |
406 | 406 | [ |
407 | 407 | '{DAV:}principal-URL', |
408 | - '{' . self::NS_CALDAV . '}calendar-home-set', |
|
409 | - '{' . self::NS_CALDAV . '}schedule-inbox-URL', |
|
408 | + '{'.self::NS_CALDAV.'}calendar-home-set', |
|
409 | + '{'.self::NS_CALDAV.'}schedule-inbox-URL', |
|
410 | 410 | '{http://sabredav.org/ns}email-address', |
411 | 411 | |
412 | 412 | ] |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | $objects = []; |
419 | 419 | $calendarTimeZone = new DateTimeZone('UTC'); |
420 | 420 | |
421 | - $homePath = $result[0][200]['{' . self::NS_CALDAV . '}calendar-home-set']->getHref(); |
|
421 | + $homePath = $result[0][200]['{'.self::NS_CALDAV.'}calendar-home-set']->getHref(); |
|
422 | 422 | foreach ($this->server->tree->getNodeForPath($homePath)->getChildren() as $node) { |
423 | 423 | if (!$node instanceof ICalendar) { |
424 | 424 | continue; |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | } |
470 | 470 | |
471 | 471 | $inboxProps = $this->server->getProperties( |
472 | - $result[0][200]['{' . self::NS_CALDAV . '}schedule-inbox-URL']->getHref(), |
|
473 | - ['{' . self::NS_CALDAV . '}calendar-availability'] |
|
472 | + $result[0][200]['{'.self::NS_CALDAV.'}schedule-inbox-URL']->getHref(), |
|
473 | + ['{'.self::NS_CALDAV.'}calendar-availability'] |
|
474 | 474 | ); |
475 | 475 | |
476 | 476 | $vcalendar = new VCalendar(); |
@@ -482,10 +482,10 @@ discard block |
||
482 | 482 | $generator->setBaseObject($vcalendar); |
483 | 483 | $generator->setTimeZone($calendarTimeZone); |
484 | 484 | |
485 | - if (isset($inboxProps['{' . self::NS_CALDAV . '}calendar-availability'])) { |
|
485 | + if (isset($inboxProps['{'.self::NS_CALDAV.'}calendar-availability'])) { |
|
486 | 486 | $generator->setVAvailability( |
487 | 487 | Reader::read( |
488 | - $inboxProps['{' . self::NS_CALDAV . '}calendar-availability'] |
|
488 | + $inboxProps['{'.self::NS_CALDAV.'}calendar-availability'] |
|
489 | 489 | ) |
490 | 490 | ); |
491 | 491 | } |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * @return string |
530 | 530 | */ |
531 | 531 | private function stripOffMailTo(string $email): string { |
532 | - if (stripos($email, 'mailto:') === 0) { |
|
532 | + if (stripos($email, 'mailto:') === 0) { |
|
533 | 533 | return substr($email, 7); |
534 | 534 | } |
535 | 535 |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $calendarData = $vObject->serialize(); |
138 | 138 | try { |
139 | 139 | $this->calDavBackend->createCalendarObject($subscription['id'], $uri, $calendarData, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION); |
140 | - } catch(BadRequest $ex) { |
|
140 | + } catch (BadRequest $ex) { |
|
141 | 141 | $this->logger->logException($ex); |
142 | 142 | } |
143 | 143 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | $this->updateSubscription($subscription, $mutations); |
151 | - } catch(ParseException $ex) { |
|
151 | + } catch (ParseException $ex) { |
|
152 | 152 | $subscriptionId = $subscription['id']; |
153 | 153 | |
154 | 154 | $this->logger->logException($ex); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | public function getSubscription(string $principalUri, string $uri) { |
167 | 167 | $subscriptions = array_values(array_filter( |
168 | 168 | $this->calDavBackend->getSubscriptionsForUser($principalUri), |
169 | - function ($sub) use ($uri) { |
|
169 | + function($sub) use ($uri) { |
|
170 | 170 | return $sub['uri'] === $uri; |
171 | 171 | } |
172 | 172 | )); |
@@ -192,12 +192,12 @@ discard block |
||
192 | 192 | $latestLocation = null; |
193 | 193 | |
194 | 194 | $handlerStack = HandlerStack::create(); |
195 | - $handlerStack->push(Middleware::mapRequest(function (RequestInterface $request) { |
|
195 | + $handlerStack->push(Middleware::mapRequest(function(RequestInterface $request) { |
|
196 | 196 | return $request |
197 | 197 | ->withHeader('Accept', 'text/calendar, application/calendar+json, application/calendar+xml') |
198 | 198 | ->withHeader('User-Agent', 'Nextcloud Webcal Crawler'); |
199 | 199 | })); |
200 | - $handlerStack->push(Middleware::mapResponse(function (ResponseInterface $response) use (&$didBreak301Chain, &$latestLocation) { |
|
200 | + $handlerStack->push(Middleware::mapResponse(function(ResponseInterface $response) use (&$didBreak301Chain, &$latestLocation) { |
|
201 | 201 | if (!$didBreak301Chain) { |
202 | 202 | if ($response->getStatusCode() !== 301) { |
203 | 203 | $didBreak301Chain = true; |
@@ -234,13 +234,13 @@ discard block |
||
234 | 234 | return null; |
235 | 235 | } |
236 | 236 | |
237 | - if ((bool)filter_var($host, FILTER_VALIDATE_IP) && !filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { |
|
237 | + if ((bool) filter_var($host, FILTER_VALIDATE_IP) && !filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { |
|
238 | 238 | $this->logger->warning("Subscription $subscriptionId was not refreshed because it violates local access rules"); |
239 | 239 | return null; |
240 | 240 | } |
241 | 241 | |
242 | 242 | // Also check for IPv6 IPv4 nesting, because that's not covered by filter_var |
243 | - if ((bool)filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && substr_count($host, '.') > 0) { |
|
243 | + if ((bool) filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && substr_count($host, '.') > 0) { |
|
244 | 244 | $delimiter = strrpos($host, ':'); // Get last colon |
245 | 245 | $ipv4Address = substr($host, $delimiter + 1); |
246 | 246 | |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | |
275 | 275 | $contentType = $response->getHeader('Content-Type'); |
276 | 276 | $contentType = explode(';', $contentType, 2)[0]; |
277 | - switch($contentType) { |
|
277 | + switch ($contentType) { |
|
278 | 278 | case 'application/calendar+json': |
279 | 279 | try { |
280 | 280 | $jCalendar = Reader::readJson($body, Reader::OPTION_FORGIVING); |
281 | - } catch(Exception $ex) { |
|
281 | + } catch (Exception $ex) { |
|
282 | 282 | // In case of a parsing error return null |
283 | 283 | $this->logger->debug("Subscription $subscriptionId could not be parsed"); |
284 | 284 | return null; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | case 'application/calendar+xml': |
289 | 289 | try { |
290 | 290 | $xCalendar = Reader::readXML($body); |
291 | - } catch(Exception $ex) { |
|
291 | + } catch (Exception $ex) { |
|
292 | 292 | // In case of a parsing error return null |
293 | 293 | $this->logger->debug("Subscription $subscriptionId could not be parsed"); |
294 | 294 | return null; |
@@ -299,14 +299,14 @@ discard block |
||
299 | 299 | default: |
300 | 300 | try { |
301 | 301 | $vCalendar = Reader::read($body); |
302 | - } catch(Exception $ex) { |
|
302 | + } catch (Exception $ex) { |
|
303 | 303 | // In case of a parsing error return null |
304 | 304 | $this->logger->debug("Subscription $subscriptionId could not be parsed"); |
305 | 305 | return null; |
306 | 306 | } |
307 | 307 | return $vCalendar->serialize(); |
308 | 308 | } |
309 | - } catch(Exception $ex) { |
|
309 | + } catch (Exception $ex) { |
|
310 | 310 | $this->logger->logException($ex); |
311 | 311 | $this->logger->warning("Subscription $subscriptionId could not be refreshed due to a network error"); |
312 | 312 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | // check if new refresh rate is even valid |
350 | 350 | try { |
351 | 351 | DateTimeParser::parseDuration($newRefreshRate); |
352 | - } catch(InvalidDataException $ex) { |
|
352 | + } catch (InvalidDataException $ex) { |
|
353 | 353 | return null; |
354 | 354 | } |
355 | 355 | |
@@ -395,10 +395,10 @@ discard block |
||
395 | 395 | } |
396 | 396 | |
397 | 397 | $host = $parsed['host'] ?? ''; |
398 | - $port = isset($parsed['port']) ? ':' . $parsed['port'] : ''; |
|
398 | + $port = isset($parsed['port']) ? ':'.$parsed['port'] : ''; |
|
399 | 399 | $path = $parsed['path'] ?? ''; |
400 | - $query = isset($parsed['query']) ? '?' . $parsed['query'] : ''; |
|
401 | - $fragment = isset($parsed['fragment']) ? '#' . $parsed['fragment'] : ''; |
|
400 | + $query = isset($parsed['query']) ? '?'.$parsed['query'] : ''; |
|
401 | + $fragment = isset($parsed['fragment']) ? '#'.$parsed['fragment'] : ''; |
|
402 | 402 | |
403 | 403 | $cleanURL = "$scheme://$host$port$path$query$fragment"; |
404 | 404 | // parse_url is giving some weird results if no url and no :// is given, |
@@ -417,6 +417,6 @@ discard block |
||
417 | 417 | * @return string |
418 | 418 | */ |
419 | 419 | public function getRandomCalendarObjectUri():string { |
420 | - return UUIDUtil::getUUID() . '.ics'; |
|
420 | + return UUIDUtil::getUUID().'.ics'; |
|
421 | 421 | } |
422 | 422 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @return array |
138 | 138 | */ |
139 | 139 | public function getACL() { |
140 | - $acl = [ |
|
140 | + $acl = [ |
|
141 | 141 | [ |
142 | 142 | 'privilege' => '{DAV:}read', |
143 | 143 | 'principal' => $this->getOwner(), |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | ], |
146 | 146 | [ |
147 | 147 | 'privilege' => '{DAV:}read', |
148 | - 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
148 | + 'principal' => $this->getOwner().'/calendar-proxy-write', |
|
149 | 149 | 'protected' => true, |
150 | 150 | ], |
151 | 151 | [ |
152 | 152 | 'privilege' => '{DAV:}read', |
153 | - 'principal' => $this->getOwner() . '/calendar-proxy-read', |
|
153 | + 'principal' => $this->getOwner().'/calendar-proxy-read', |
|
154 | 154 | 'protected' => true, |
155 | 155 | ], |
156 | 156 | ]; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | ]; |
164 | 164 | $acl[] = [ |
165 | 165 | 'privilege' => '{DAV:}write', |
166 | - 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
166 | + 'principal' => $this->getOwner().'/calendar-proxy-write', |
|
167 | 167 | 'protected' => true, |
168 | 168 | ]; |
169 | 169 | } else { |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | ]; |
175 | 175 | $acl[] = [ |
176 | 176 | 'privilege' => '{DAV:}write-properties', |
177 | - 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
177 | + 'principal' => $this->getOwner().'/calendar-proxy-write', |
|
178 | 178 | 'protected' => true, |
179 | 179 | ]; |
180 | 180 | } |
181 | 181 | |
182 | 182 | $acl[] = [ |
183 | 183 | 'privilege' => '{DAV:}write-properties', |
184 | - 'principal' => $this->getOwner() . '/calendar-proxy-read', |
|
184 | + 'principal' => $this->getOwner().'/calendar-proxy-read', |
|
185 | 185 | 'protected' => true, |
186 | 186 | ]; |
187 | 187 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | if ($this->getOwner() !== parent::getOwner()) { |
193 | - $acl[] = [ |
|
193 | + $acl[] = [ |
|
194 | 194 | 'privilege' => '{DAV:}read', |
195 | 195 | 'principal' => parent::getOwner(), |
196 | 196 | 'protected' => true, |
@@ -220,12 +220,12 @@ discard block |
||
220 | 220 | $acl = $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl); |
221 | 221 | $allowedPrincipals = [ |
222 | 222 | $this->getOwner(), |
223 | - $this->getOwner(). '/calendar-proxy-read', |
|
224 | - $this->getOwner(). '/calendar-proxy-write', |
|
223 | + $this->getOwner().'/calendar-proxy-read', |
|
224 | + $this->getOwner().'/calendar-proxy-write', |
|
225 | 225 | parent::getOwner(), |
226 | 226 | 'principals/system/public' |
227 | 227 | ]; |
228 | - return array_filter($acl, function ($rule) use ($allowedPrincipals) { |
|
228 | + return array_filter($acl, function($rule) use ($allowedPrincipals) { |
|
229 | 229 | return \in_array($rule['principal'], $allowedPrincipals, true); |
230 | 230 | }); |
231 | 231 | } |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | public function delete() { |
245 | 245 | if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal']) && |
246 | 246 | $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']) { |
247 | - $principal = 'principal:' . parent::getOwner(); |
|
247 | + $principal = 'principal:'.parent::getOwner(); |
|
248 | 248 | $shares = $this->caldavBackend->getShares($this->getResourceId()); |
249 | - $shares = array_filter($shares, function ($share) use ($principal) { |
|
249 | + $shares = array_filter($shares, function($share) use ($principal) { |
|
250 | 250 | return $share['href'] === $principal; |
251 | 251 | }); |
252 | 252 | if (empty($shares)) { |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | |
344 | 344 | $uris = $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters); |
345 | 345 | if ($this->isShared()) { |
346 | - return array_filter($uris, function ($uri) { |
|
346 | + return array_filter($uris, function($uri) { |
|
347 | 347 | return $this->childExists($uri); |
348 | 348 | }); |
349 | 349 | } |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | $this->logger = $logger; |
89 | 89 | $this->proxyMapper = $proxyMapper; |
90 | 90 | $this->principalPrefix = $principalPrefix; |
91 | - $this->dbTableName = 'calendar_' . $dbPrefix . 's'; |
|
92 | - $this->dbMetaDataTableName = $this->dbTableName . '_md'; |
|
93 | - $this->dbForeignKeyName = $dbPrefix . '_id'; |
|
91 | + $this->dbTableName = 'calendar_'.$dbPrefix.'s'; |
|
92 | + $this->dbMetaDataTableName = $this->dbTableName.'_md'; |
|
93 | + $this->dbForeignKeyName = $dbPrefix.'_id'; |
|
94 | 94 | $this->cuType = $cuType; |
95 | 95 | } |
96 | 96 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC); |
126 | 126 | |
127 | 127 | $metaDataById = []; |
128 | - foreach($metaDataRows as $metaDataRow) { |
|
128 | + foreach ($metaDataRows as $metaDataRow) { |
|
129 | 129 | if (!isset($metaDataById[$metaDataRow[$this->dbForeignKeyName]])) { |
130 | 130 | $metaDataById[$metaDataRow[$this->dbForeignKeyName]] = []; |
131 | 131 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $metaDataRow['value']; |
135 | 135 | } |
136 | 136 | |
137 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
137 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
138 | 138 | $id = $row['id']; |
139 | 139 | |
140 | 140 | if (isset($metaDataById[$id])) { |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | list(, $name) = \Sabre\Uri\split($path); |
167 | 167 | |
168 | - list($backendId, $resourceId) = explode('-', $name, 2); |
|
168 | + list($backendId, $resourceId) = explode('-', $name, 2); |
|
169 | 169 | |
170 | 170 | $query = $this->db->getQueryBuilder(); |
171 | 171 | $query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname']) |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $stmt = $query->execute(); |
176 | 176 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
177 | 177 | |
178 | - if(!$row) { |
|
178 | + if (!$row) { |
|
179 | 179 | return null; |
180 | 180 | } |
181 | 181 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC); |
188 | 188 | $metadata = []; |
189 | 189 | |
190 | - foreach($metaDataRows as $metaDataRow) { |
|
190 | + foreach ($metaDataRows as $metaDataRow) { |
|
191 | 191 | $metadata[$metaDataRow['key']] = $metaDataRow['value']; |
192 | 192 | } |
193 | 193 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param int $id |
199 | 199 | * @return array|null |
200 | 200 | */ |
201 | - public function getPrincipalById($id):?array { |
|
201 | + public function getPrincipalById($id): ?array { |
|
202 | 202 | $query = $this->db->getQueryBuilder(); |
203 | 203 | $query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname']) |
204 | 204 | ->from($this->dbTableName) |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $stmt = $query->execute(); |
207 | 207 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
208 | 208 | |
209 | - if(!$row) { |
|
209 | + if (!$row) { |
|
210 | 210 | return null; |
211 | 211 | } |
212 | 212 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC); |
219 | 219 | $metadata = []; |
220 | 220 | |
221 | - foreach($metaDataRows as $metaDataRow) { |
|
221 | + foreach ($metaDataRows as $metaDataRow) { |
|
222 | 222 | $metadata[$metaDataRow['key']] = $metaDataRow['value']; |
223 | 223 | } |
224 | 224 | |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | $query = $this->db->getQueryBuilder(); |
262 | 262 | $query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) |
263 | 263 | ->from($this->dbTableName) |
264 | - ->where($query->expr()->iLike('email', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($value) . '%'))); |
|
264 | + ->where($query->expr()->iLike('email', $query->createNamedParameter('%'.$this->db->escapeLikeParameter($value).'%'))); |
|
265 | 265 | |
266 | 266 | $stmt = $query->execute(); |
267 | 267 | $principals = []; |
268 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
268 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
269 | 269 | if (!$this->isAllowedToAccessResource($row, $usersGroups)) { |
270 | 270 | continue; |
271 | 271 | } |
@@ -280,11 +280,11 @@ discard block |
||
280 | 280 | $query = $this->db->getQueryBuilder(); |
281 | 281 | $query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) |
282 | 282 | ->from($this->dbTableName) |
283 | - ->where($query->expr()->iLike('displayname', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($value) . '%'))); |
|
283 | + ->where($query->expr()->iLike('displayname', $query->createNamedParameter('%'.$this->db->escapeLikeParameter($value).'%'))); |
|
284 | 284 | |
285 | 285 | $stmt = $query->execute(); |
286 | 286 | $principals = []; |
287 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
287 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
288 | 288 | if (!$this->isAllowedToAccessResource($row, $usersGroups)) { |
289 | 289 | continue; |
290 | 290 | } |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | |
306 | 306 | default: |
307 | 307 | $rowsByMetadata = $this->searchPrincipalsByMetadataKey($prop, $value); |
308 | - $filteredRows = array_filter($rowsByMetadata, function ($row) use ($usersGroups) { |
|
308 | + $filteredRows = array_filter($rowsByMetadata, function($row) use ($usersGroups) { |
|
309 | 309 | return $this->isAllowedToAccessResource($row, $usersGroups); |
310 | 310 | }); |
311 | 311 | |
312 | - $results[] = array_map(function ($row) { |
|
312 | + $results[] = array_map(function($row) { |
|
313 | 313 | return $row['uri']; |
314 | 314 | }, $filteredRows); |
315 | 315 | |
@@ -348,11 +348,11 @@ discard block |
||
348 | 348 | $query->select([$this->dbForeignKeyName]) |
349 | 349 | ->from($this->dbMetaDataTableName) |
350 | 350 | ->where($query->expr()->eq('key', $query->createNamedParameter($key))) |
351 | - ->andWhere($query->expr()->iLike('value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($value) . '%'))); |
|
351 | + ->andWhere($query->expr()->iLike('value', $query->createNamedParameter('%'.$this->db->escapeLikeParameter($value).'%'))); |
|
352 | 352 | $stmt = $query->execute(); |
353 | 353 | |
354 | 354 | $rows = []; |
355 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
355 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
356 | 356 | $id = $row[$this->dbForeignKeyName]; |
357 | 357 | |
358 | 358 | $principalRow = $this->getPrincipalById($id); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $stmt = $query->execute(); |
389 | 389 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
390 | 390 | |
391 | - if(!$row) { |
|
391 | + if (!$row) { |
|
392 | 392 | return null; |
393 | 393 | } |
394 | 394 | if (!$this->isAllowedToAccessResource($row, $usersGroups)) { |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | list(, $name) = \Sabre\Uri\split($path); |
408 | - list($backendId, $resourceId) = explode('-', $name, 2); |
|
408 | + list($backendId, $resourceId) = explode('-', $name, 2); |
|
409 | 409 | |
410 | 410 | $query = $this->db->getQueryBuilder(); |
411 | 411 | $query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | $stmt = $query->execute(); |
416 | 416 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
417 | 417 | |
418 | - if(!$row) { |
|
418 | + if (!$row) { |
|
419 | 419 | return null; |
420 | 420 | } |
421 | 421 | if (!$this->isAllowedToAccessResource($row, $usersGroups)) { |
@@ -435,9 +435,9 @@ discard block |
||
435 | 435 | * @param String[] $metadata |
436 | 436 | * @return Array |
437 | 437 | */ |
438 | - private function rowToPrincipal(array $row, array $metadata=[]):array { |
|
438 | + private function rowToPrincipal(array $row, array $metadata = []):array { |
|
439 | 439 | return array_merge([ |
440 | - 'uri' => $this->principalPrefix . '/' . $row['backend_id'] . '-' . $row['resource_id'], |
|
440 | + 'uri' => $this->principalPrefix.'/'.$row['backend_id'].'-'.$row['resource_id'], |
|
441 | 441 | '{DAV:}displayname' => $row['displayname'], |
442 | 442 | '{http://sabredav.org/ns}email-address' => $row['email'], |
443 | 443 | '{urn:ietf:params:xml:ns:caldav}calendar-user-type' => $this->cuType, |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | // group restrictions contains something, but not parsable, deny access and log warning |
460 | 460 | $json = json_decode($row['group_restrictions']); |
461 | 461 | if (!\is_array($json)) { |
462 | - $this->logger->info('group_restrictions field could not be parsed for ' . $this->dbTableName . '::' . $row['id'] . ', denying access to resource'); |
|
462 | + $this->logger->info('group_restrictions field could not be parsed for '.$this->dbTableName.'::'.$row['id'].', denying access to resource'); |
|
463 | 463 | return false; |
464 | 464 | } |
465 | 465 |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | public function processReminders():void { |
112 | 112 | $reminders = $this->backend->getRemindersToProcess(); |
113 | 113 | |
114 | - foreach($reminders as $reminder) { |
|
114 | + foreach ($reminders as $reminder) { |
|
115 | 115 | $calendarData = is_resource($reminder['calendardata']) |
116 | 116 | ? stream_get_contents($reminder['calendardata']) |
117 | 117 | : $reminder['calendardata']; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - switch($action) { |
|
166 | + switch ($action) { |
|
167 | 167 | case '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject': |
168 | 168 | $this->onCalendarObjectCreate($objectData); |
169 | 169 | break; |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | $now = $this->timeFactory->getDateTime(); |
207 | 207 | $isRecurring = $masterItem ? $this->isRecurring($masterItem) : false; |
208 | 208 | |
209 | - foreach($recurrenceExceptions as $recurrenceException) { |
|
209 | + foreach ($recurrenceExceptions as $recurrenceException) { |
|
210 | 210 | $eventHash = $this->getEventHash($recurrenceException); |
211 | 211 | |
212 | 212 | if (!isset($recurrenceException->VALARM)) { |
213 | 213 | continue; |
214 | 214 | } |
215 | 215 | |
216 | - foreach($recurrenceException->VALARM as $valarm) { |
|
216 | + foreach ($recurrenceException->VALARM as $valarm) { |
|
217 | 217 | /** @var VAlarm $valarm */ |
218 | 218 | $alarmHash = $this->getAlarmHash($valarm); |
219 | 219 | $triggerTime = $valarm->getEffectiveTriggerTime(); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | return; |
238 | 238 | } |
239 | 239 | |
240 | - foreach($masterItem->VALARM as $valarm) { |
|
240 | + foreach ($masterItem->VALARM as $valarm) { |
|
241 | 241 | $masterAlarms[] = $this->getAlarmHash($valarm); |
242 | 242 | } |
243 | 243 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | return; |
251 | 251 | } |
252 | 252 | |
253 | - while($iterator->valid() && count($processedAlarms) < count($masterAlarms)) { |
|
253 | + while ($iterator->valid() && count($processedAlarms) < count($masterAlarms)) { |
|
254 | 254 | $event = $iterator->getEventObject(); |
255 | 255 | |
256 | 256 | // Recurrence-exceptions are handled separately, so just ignore them here |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | continue; |
260 | 260 | } |
261 | 261 | |
262 | - foreach($event->VALARM as $valarm) { |
|
262 | + foreach ($event->VALARM as $valarm) { |
|
263 | 263 | /** @var VAlarm $valarm */ |
264 | 264 | $alarmHash = $this->getAlarmHash($valarm); |
265 | 265 | if (\in_array($alarmHash, $processedAlarms, true)) { |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | */ |
330 | 330 | private function getRemindersForVAlarm(VAlarm $valarm, |
331 | 331 | array $objectData, |
332 | - string $eventHash=null, |
|
333 | - string $alarmHash=null, |
|
334 | - bool $isRecurring=false, |
|
335 | - bool $isRecurrenceException=false):array { |
|
332 | + string $eventHash = null, |
|
333 | + string $alarmHash = null, |
|
334 | + bool $isRecurring = false, |
|
335 | + bool $isRecurrenceException = false):array { |
|
336 | 336 | if ($eventHash === null) { |
337 | 337 | $eventHash = $this->getEventHash($valarm->parent); |
338 | 338 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | ]; |
366 | 366 | |
367 | 367 | $repeat = isset($valarm->REPEAT) ? (int) $valarm->REPEAT->getValue() : 0; |
368 | - for($i = 0; $i < $repeat; $i++) { |
|
368 | + for ($i = 0; $i < $repeat; $i++) { |
|
369 | 369 | if ($valarm->DURATION === null) { |
370 | 370 | continue; |
371 | 371 | } |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | * @param array $reminders |
395 | 395 | */ |
396 | 396 | private function writeRemindersToDatabase(array $reminders): void { |
397 | - foreach($reminders as $reminder) { |
|
397 | + foreach ($reminders as $reminder) { |
|
398 | 398 | $this->backend->insertReminder( |
399 | 399 | (int) $reminder['calendar_id'], |
400 | 400 | (int) $reminder['object_id'], |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | return; |
441 | 441 | } |
442 | 442 | |
443 | - while($iterator->valid()) { |
|
443 | + while ($iterator->valid()) { |
|
444 | 444 | $event = $iterator->getEventObject(); |
445 | 445 | |
446 | 446 | // Recurrence-exceptions are handled separately, so just ignore them here |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | continue; |
456 | 456 | } |
457 | 457 | |
458 | - foreach($event->VALARM as $valarm) { |
|
458 | + foreach ($event->VALARM as $valarm) { |
|
459 | 459 | /** @var VAlarm $valarm */ |
460 | 460 | $alarmHash = $this->getAlarmHash($valarm); |
461 | 461 | if ($alarmHash !== $reminder['alarm_hash']) { |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | */ |
597 | 597 | private function getVEventByRecurrenceId(VObject\Component\VCalendar $vcalendar, |
598 | 598 | int $recurrenceId, |
599 | - bool $isRecurrenceException):?VEvent { |
|
599 | + bool $isRecurrenceException): ?VEvent { |
|
600 | 600 | $vevents = $this->getAllVEventsFromVCalendar($vcalendar); |
601 | 601 | if (count($vevents) === 0) { |
602 | 602 | return null; |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | |
609 | 609 | // Handle recurrence-exceptions first, because recurrence-expansion is expensive |
610 | 610 | if ($isRecurrenceException) { |
611 | - foreach($recurrenceExceptions as $recurrenceException) { |
|
611 | + foreach ($recurrenceExceptions as $recurrenceException) { |
|
612 | 612 | if ($this->getEffectiveRecurrenceIdOfVEvent($recurrenceException) === $recurrenceId) { |
613 | 613 | return $recurrenceException; |
614 | 614 | } |
@@ -674,11 +674,11 @@ discard block |
||
674 | 674 | * @param string $calendarData |
675 | 675 | * @return VObject\Component\VCalendar|null |
676 | 676 | */ |
677 | - private function parseCalendarData(string $calendarData):?VObject\Component\VCalendar { |
|
677 | + private function parseCalendarData(string $calendarData): ?VObject\Component\VCalendar { |
|
678 | 678 | try { |
679 | 679 | return VObject\Reader::read($calendarData, |
680 | 680 | VObject\Reader::OPTION_FORGIVING); |
681 | - } catch(ParseException $ex) { |
|
681 | + } catch (ParseException $ex) { |
|
682 | 682 | return null; |
683 | 683 | } |
684 | 684 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | * @param string $principalUri |
688 | 688 | * @return IUser|null |
689 | 689 | */ |
690 | - private function getUserFromPrincipalURI(string $principalUri):?IUser { |
|
690 | + private function getUserFromPrincipalURI(string $principalUri): ?IUser { |
|
691 | 691 | if (!$principalUri) { |
692 | 692 | return null; |
693 | 693 | } |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | private function getAllVEventsFromVCalendar(VObject\Component\VCalendar $vcalendar):array { |
708 | 708 | $vevents = []; |
709 | 709 | |
710 | - foreach($vcalendar->children() as $child) { |
|
710 | + foreach ($vcalendar->children() as $child) { |
|
711 | 711 | if (!($child instanceof VObject\Component)) { |
712 | 712 | continue; |
713 | 713 | } |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | * @return VObject\Component\VEvent[] |
728 | 728 | */ |
729 | 729 | private function getRecurrenceExceptionFromListOfVEvents(array $vevents):array { |
730 | - return array_values(array_filter($vevents, function (VEvent $vevent) { |
|
730 | + return array_values(array_filter($vevents, function(VEvent $vevent) { |
|
731 | 731 | return $vevent->{'RECURRENCE-ID'} !== null; |
732 | 732 | })); |
733 | 733 | } |
@@ -736,8 +736,8 @@ discard block |
||
736 | 736 | * @param array $vevents |
737 | 737 | * @return VEvent|null |
738 | 738 | */ |
739 | - private function getMasterItemFromListOfVEvents(array $vevents):?VEvent { |
|
740 | - $elements = array_values(array_filter($vevents, function (VEvent $vevent) { |
|
739 | + private function getMasterItemFromListOfVEvents(array $vevents): ?VEvent { |
|
740 | + $elements = array_values(array_filter($vevents, function(VEvent $vevent) { |
|
741 | 741 | return $vevent->{'RECURRENCE-ID'} === null; |
742 | 742 | })); |
743 | 743 |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | $this->server = $server; |
114 | 114 | |
115 | 115 | $this->server->on('method:POST', [$this, 'httpPost']); |
116 | - $this->server->on('propFind', [$this, 'propFind']); |
|
116 | + $this->server->on('propFind', [$this, 'propFind']); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | public function propFind(PropFind $propFind, INode $node) { |
120 | 120 | if ($node instanceof Calendar) { |
121 | - $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node) { |
|
121 | + $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function() use ($node) { |
|
122 | 122 | if ($node->getPublishStatus()) { |
123 | 123 | // We return the publish-url only if the calendar is published. |
124 | 124 | $token = $node->getPublishStatus(); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | }); |
130 | 130 | |
131 | - $propFind->handle('{'.self::NS_CALENDARSERVER.'}allowed-sharing-modes', function () use ($node) { |
|
131 | + $propFind->handle('{'.self::NS_CALENDARSERVER.'}allowed-sharing-modes', function() use ($node) { |
|
132 | 132 | $canShare = (!$node->isSubscription() && $node->canWrite()); |
133 | 133 | $canPublish = (!$node->isSubscription() && $node->canWrite()); |
134 | 134 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | public function createFile($name, $data = null) { |
47 | - throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
47 | + throw new Forbidden('Permission denied to create file (filename '.$name.')'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function createDirectory($name) { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | public function getChildren(): array { |
62 | - return array_map(function ($node) { |
|
62 | + return array_map(function($node) { |
|
63 | 63 | return new UploadFolder($node, $this->cleanupService); |
64 | 64 | }, $this->impl()->getChildren()); |
65 | 65 | } |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | $rootView = new View(); |
93 | 93 | $user = \OC::$server->getUserSession()->getUser(); |
94 | 94 | Filesystem::initMountPoints($user->getUID()); |
95 | - if (!$rootView->file_exists('/' . $user->getUID() . '/uploads')) { |
|
96 | - $rootView->mkdir('/' . $user->getUID() . '/uploads'); |
|
95 | + if (!$rootView->file_exists('/'.$user->getUID().'/uploads')) { |
|
96 | + $rootView->mkdir('/'.$user->getUID().'/uploads'); |
|
97 | 97 | } |
98 | - $view = new View('/' . $user->getUID() . '/uploads'); |
|
98 | + $view = new View('/'.$user->getUID().'/uploads'); |
|
99 | 99 | $rootInfo = $view->getFileInfo(''); |
100 | 100 | return new Directory($view, $rootInfo); |
101 | 101 | } |
@@ -86,7 +86,7 @@ |
||
86 | 86 | */ |
87 | 87 | function getSize() { |
88 | 88 | $children = $this->root->getChildren(); |
89 | - $sizes = array_map(function ($node) { |
|
89 | + $sizes = array_map(function($node) { |
|
90 | 90 | /** @var IFile $node */ |
91 | 91 | return $node->getSize(); |
92 | 92 | }, $children); |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | * @return void |
90 | 90 | */ |
91 | 91 | function propFind(PropFind $propFind, INode $node) { |
92 | - $propFind->handle('{DAV:}supportedlock', function () { |
|
92 | + $propFind->handle('{DAV:}supportedlock', function() { |
|
93 | 93 | return new SupportedLock(true); |
94 | 94 | }); |
95 | - $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) { |
|
95 | + $propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) { |
|
96 | 96 | return new LockDiscovery([]); |
97 | 97 | }); |
98 | 98 | } |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | * @param array $conditions |
105 | 105 | */ |
106 | 106 | public function validateTokens(RequestInterface $request, &$conditions) { |
107 | - foreach($conditions as &$fileCondition) { |
|
108 | - if(isset($fileCondition['tokens'])) { |
|
109 | - foreach($fileCondition['tokens'] as &$token) { |
|
110 | - if(isset($token['token'])) { |
|
111 | - if(substr($token['token'], 0, 16) === 'opaquelocktoken:') { |
|
107 | + foreach ($conditions as &$fileCondition) { |
|
108 | + if (isset($fileCondition['tokens'])) { |
|
109 | + foreach ($fileCondition['tokens'] as &$token) { |
|
110 | + if (isset($token['token'])) { |
|
111 | + if (substr($token['token'], 0, 16) === 'opaquelocktoken:') { |
|
112 | 112 | $token['validToken'] = true; |
113 | 113 | } |
114 | 114 | } |