@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @package OCA\Federation\Controller |
49 | 49 | */ |
50 | -class OCSAuthAPIController extends OCSController{ |
|
50 | +class OCSAuthAPIController extends OCSController { |
|
51 | 51 | |
52 | 52 | /** @var ISecureRandom */ |
53 | 53 | private $secureRandom; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function requestSharedSecret($url, $token) { |
145 | 145 | if ($this->trustedServers->isTrustedServer($url) === false) { |
146 | - $this->logger->error('remote server not trusted (' . $url . ') while requesting shared secret', ['app' => 'federation']); |
|
146 | + $this->logger->error('remote server not trusted ('.$url.') while requesting shared secret', ['app' => 'federation']); |
|
147 | 147 | throw new OCSForbiddenException(); |
148 | 148 | } |
149 | 149 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $localToken = $this->dbHandler->getToken($url); |
153 | 153 | if (strcmp($localToken, $token) > 0) { |
154 | 154 | $this->logger->info( |
155 | - 'remote server (' . $url . ') presented lower token. We will initiate the exchange of the shared secret.', |
|
155 | + 'remote server ('.$url.') presented lower token. We will initiate the exchange of the shared secret.', |
|
156 | 156 | ['app' => 'federation'] |
157 | 157 | ); |
158 | 158 | throw new OCSForbiddenException(); |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | public function getSharedSecret($url, $token) { |
185 | 185 | |
186 | 186 | if ($this->trustedServers->isTrustedServer($url) === false) { |
187 | - $this->logger->error('remote server not trusted (' . $url . ') while getting shared secret', ['app' => 'federation']); |
|
187 | + $this->logger->error('remote server not trusted ('.$url.') while getting shared secret', ['app' => 'federation']); |
|
188 | 188 | throw new OCSForbiddenException(); |
189 | 189 | } |
190 | 190 | |
191 | 191 | if ($this->isValidToken($url, $token) === false) { |
192 | 192 | $expectedToken = $this->dbHandler->getToken($url); |
193 | 193 | $this->logger->error( |
194 | - 'remote server (' . $url . ') didn\'t send a valid token (got "' . $token . '" but expected "'. $expectedToken . '") while getting shared secret', |
|
194 | + 'remote server ('.$url.') didn\'t send a valid token (got "'.$token.'" but expected "'.$expectedToken.'") while getting shared secret', |
|
195 | 195 | ['app' => 'federation'] |
196 | 196 | ); |
197 | 197 | throw new OCSForbiddenException(); |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | * @param string[] $remove |
69 | 69 | */ |
70 | 70 | public function updateShares(IShareable $shareable, array $add, array $remove) { |
71 | - foreach($add as $element) { |
|
71 | + foreach ($add as $element) { |
|
72 | 72 | $principal = $this->principalBackend->findByUri($element['href'], ''); |
73 | 73 | if ($principal !== '') { |
74 | 74 | $this->shareWith($shareable, $element); |
75 | 75 | } |
76 | 76 | } |
77 | - foreach($remove as $element) { |
|
77 | + foreach ($remove as $element) { |
|
78 | 78 | $principal = $this->principalBackend->findByUri($element, ''); |
79 | 79 | if ($principal !== '') { |
80 | 80 | $this->unshare($shareable, $element); |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | ->execute(); |
194 | 194 | |
195 | 195 | $shares = []; |
196 | - while($row = $result->fetch()) { |
|
196 | + while ($row = $result->fetch()) { |
|
197 | 197 | $p = $this->principalBackend->getPrincipalByPath($row['principaluri']); |
198 | - $shares[]= [ |
|
198 | + $shares[] = [ |
|
199 | 199 | 'href' => "principal:${row['principaluri']}", |
200 | 200 | 'commonName' => isset($p['{DAV:}displayname']) ? $p['{DAV:}displayname'] : '', |
201 | 201 | 'status' => 1, |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | foreach ($shares as $share) { |
222 | 222 | $acl[] = [ |
223 | 223 | 'privilege' => '{DAV:}read', |
224 | - 'principal' => $share['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}principal'], |
|
224 | + 'principal' => $share['{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}principal'], |
|
225 | 225 | 'protected' => true, |
226 | 226 | ]; |
227 | 227 | if (!$share['readOnly']) { |
228 | 228 | $acl[] = [ |
229 | 229 | 'privilege' => '{DAV:}write', |
230 | - 'principal' => $share['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}principal'], |
|
230 | + 'principal' => $share['{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}principal'], |
|
231 | 231 | 'protected' => true, |
232 | 232 | ]; |
233 | 233 | } else if ($this->resourceType === 'calendar') { |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | // so users can change the visibility. |
236 | 236 | $acl[] = [ |
237 | 237 | 'privilege' => '{DAV:}write-properties', |
238 | - 'principal' => $share['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}principal'], |
|
238 | + 'principal' => $share['{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}principal'], |
|
239 | 239 | 'protected' => true, |
240 | 240 | ]; |
241 | 241 | } |
@@ -88,7 +88,7 @@ |
||
88 | 88 | * @param string $mode |
89 | 89 | * @return DataResponse|FileDisplayResponse |
90 | 90 | */ |
91 | - public function getPreview ( |
|
91 | + public function getPreview( |
|
92 | 92 | string $file = '', |
93 | 93 | int $x = 32, |
94 | 94 | int $y = 32, |
@@ -72,8 +72,8 @@ |
||
72 | 72 | |
73 | 73 | $convertedAddresses = []; |
74 | 74 | |
75 | - foreach($addresses as $email => $readableName) { |
|
76 | - if(!is_numeric($email)) { |
|
75 | + foreach ($addresses as $email => $readableName) { |
|
76 | + if (!is_numeric($email)) { |
|
77 | 77 | list($name, $domain) = explode('@', $email, 2); |
78 | 78 | $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); |
79 | 79 | $convertedAddresses[$name.'@'.$domain] = $readableName; |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | |
403 | 403 | $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]); |
404 | 404 | if ($plainTitle !== false) { |
405 | - $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL; |
|
405 | + $this->plainBody .= $plainTitle.PHP_EOL.PHP_EOL; |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | |
439 | 439 | $this->htmlBody .= vsprintf($this->bodyText, [$text]); |
440 | 440 | if ($plainText !== false) { |
441 | - $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; |
|
441 | + $this->plainBody .= $plainText.PHP_EOL.PHP_EOL; |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | |
@@ -468,18 +468,18 @@ discard block |
||
468 | 468 | |
469 | 469 | $htmlText = $text; |
470 | 470 | if ($metaInfo) { |
471 | - $htmlText = '<em style="color:#777;">' . $metaInfo . '</em><br>' . $htmlText; |
|
471 | + $htmlText = '<em style="color:#777;">'.$metaInfo.'</em><br>'.$htmlText; |
|
472 | 472 | } |
473 | 473 | if ($icon !== '') { |
474 | - $icon = '<img src="' . htmlspecialchars($icon) . '" alt="•">'; |
|
474 | + $icon = '<img src="'.htmlspecialchars($icon).'" alt="•">'; |
|
475 | 475 | } else { |
476 | 476 | $icon = '•'; |
477 | 477 | } |
478 | 478 | $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]); |
479 | 479 | if ($plainText !== false) { |
480 | - $this->plainBody .= ' * ' . $plainText; |
|
480 | + $this->plainBody .= ' * '.$plainText; |
|
481 | 481 | if ($plainMetaInfo !== false) { |
482 | - $this->plainBody .= ' (' . $plainMetaInfo . ')'; |
|
482 | + $this->plainBody .= ' ('.$plainMetaInfo.')'; |
|
483 | 483 | } |
484 | 484 | $this->plainBody .= PHP_EOL; |
485 | 485 | } |
@@ -540,8 +540,8 @@ discard block |
||
540 | 540 | $textColor = $this->themingDefaults->getTextColorPrimary(); |
541 | 541 | |
542 | 542 | $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, $textLeft, $urlRight, $textRight]); |
543 | - $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL; |
|
544 | - $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL; |
|
543 | + $this->plainBody .= $plainTextLeft.': '.$urlLeft.PHP_EOL; |
|
544 | + $this->plainBody .= $plainTextRight.': '.$urlRight.PHP_EOL.PHP_EOL; |
|
545 | 545 | |
546 | 546 | } |
547 | 547 | |
@@ -573,10 +573,10 @@ discard block |
||
573 | 573 | $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, $text]); |
574 | 574 | |
575 | 575 | if ($plainText !== false) { |
576 | - $this->plainBody .= $plainText . ': '; |
|
576 | + $this->plainBody .= $plainText.': '; |
|
577 | 577 | } |
578 | 578 | |
579 | - $this->plainBody .= $url . PHP_EOL; |
|
579 | + $this->plainBody .= $url.PHP_EOL; |
|
580 | 580 | |
581 | 581 | } |
582 | 582 | |
@@ -600,8 +600,8 @@ discard block |
||
600 | 600 | * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used |
601 | 601 | */ |
602 | 602 | public function addFooter(string $text = '') { |
603 | - if($text === '') { |
|
604 | - $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.'); |
|
603 | + if ($text === '') { |
|
604 | + $text = $this->themingDefaults->getName().' - '.$this->themingDefaults->getSlogan().'<br>'.$this->l10n->t('This is an automatically sent email, please do not reply.'); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | if ($this->footerAdded) { |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | |
614 | 614 | $this->htmlBody .= vsprintf($this->footer, [$text]); |
615 | 615 | $this->htmlBody .= $this->tail; |
616 | - $this->plainBody .= PHP_EOL . '-- ' . PHP_EOL; |
|
616 | + $this->plainBody .= PHP_EOL.'-- '.PHP_EOL; |
|
617 | 617 | $this->plainBody .= str_replace('<br>', PHP_EOL, $text); |
618 | 618 | } |
619 | 619 |
@@ -80,7 +80,7 @@ |
||
80 | 80 | */ |
81 | 81 | public function getCloudId(string $user, string $remote): ICloudId { |
82 | 82 | // TODO check what the correct url is for remote (asking the remote) |
83 | - return new CloudId($user. '@' . $remote, $user, $remote); |
|
83 | + return new CloudId($user.'@'.$remote, $user, $remote); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * Constructor |
55 | 55 | */ |
56 | - public function __construct(){ |
|
56 | + public function __construct() { |
|
57 | 57 | $this->middlewares = []; |
58 | 58 | $this->middlewareCounter = 0; |
59 | 59 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * Adds a new middleware |
64 | 64 | * @param Middleware $middleWare the middleware which will be added |
65 | 65 | */ |
66 | - public function registerMiddleware(Middleware $middleWare){ |
|
66 | + public function registerMiddleware(Middleware $middleWare) { |
|
67 | 67 | $this->middlewares[] = $middleWare; |
68 | 68 | } |
69 | 69 | |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | * @param string $methodName the name of the method that will be called on |
86 | 86 | * the controller |
87 | 87 | */ |
88 | - public function beforeController(Controller $controller, string $methodName){ |
|
88 | + public function beforeController(Controller $controller, string $methodName) { |
|
89 | 89 | // we need to count so that we know which middlewares we have to ask in |
90 | 90 | // case there is an exception |
91 | 91 | $middlewareCount = \count($this->middlewares); |
92 | - for($i = 0; $i < $middlewareCount; $i++){ |
|
92 | + for ($i = 0; $i < $middlewareCount; $i++) { |
|
93 | 93 | $this->middlewareCounter++; |
94 | 94 | $middleware = $this->middlewares[$i]; |
95 | 95 | $middleware->beforeController($controller, $methodName); |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | * @throws \Exception the passed in exception if it can't handle it |
114 | 114 | */ |
115 | 115 | public function afterException(Controller $controller, string $methodName, \Exception $exception): Response { |
116 | - for($i=$this->middlewareCounter-1; $i>=0; $i--){ |
|
116 | + for ($i = $this->middlewareCounter - 1; $i >= 0; $i--) { |
|
117 | 117 | $middleware = $this->middlewares[$i]; |
118 | 118 | try { |
119 | 119 | return $middleware->afterException($controller, $methodName, $exception); |
120 | - } catch(\Exception $exception){ |
|
120 | + } catch (\Exception $exception) { |
|
121 | 121 | continue; |
122 | 122 | } |
123 | 123 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @return Response a Response object |
137 | 137 | */ |
138 | 138 | public function afterController(Controller $controller, string $methodName, Response $response): Response { |
139 | - for($i= \count($this->middlewares)-1; $i>=0; $i--){ |
|
139 | + for ($i = \count($this->middlewares) - 1; $i >= 0; $i--) { |
|
140 | 140 | $middleware = $this->middlewares[$i]; |
141 | 141 | $response = $middleware->afterController($controller, $methodName, $response); |
142 | 142 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @return string the output that should be printed |
156 | 156 | */ |
157 | 157 | public function beforeOutput(Controller $controller, string $methodName, string $output): string { |
158 | - for($i= \count($this->middlewares)-1; $i>=0; $i--){ |
|
158 | + for ($i = \count($this->middlewares) - 1; $i >= 0; $i--) { |
|
159 | 159 | $middleware = $this->middlewares[$i]; |
160 | 160 | $output = $middleware->beforeOutput($controller, $methodName, $output); |
161 | 161 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param object $object an object or classname |
44 | 44 | * @param string $method the method which we want to inspect |
45 | 45 | */ |
46 | - public function reflect($object, string $method){ |
|
46 | + public function reflect($object, string $method) { |
|
47 | 47 | $reflection = new \ReflectionMethod($object, $method); |
48 | 48 | $docs = $reflection->getDocComment(); |
49 | 49 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | $default = null; |
85 | - if($param->isOptional()) { |
|
85 | + if ($param->isOptional()) { |
|
86 | 86 | $default = $param->getDefaultValue(); |
87 | 87 | } |
88 | 88 | $this->parameters[$param->name] = $default; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * would return int or null if not existing |
98 | 98 | */ |
99 | 99 | public function getType(string $parameter) { |
100 | - if(array_key_exists($parameter, $this->types)) { |
|
100 | + if (array_key_exists($parameter, $this->types)) { |
|
101 | 101 | return $this->types[$parameter]; |
102 | 102 | } |
103 | 103 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return string |
129 | 129 | */ |
130 | 130 | public function getAnnotationParameter(string $name, string $key): string { |
131 | - if(isset($this->annotations[$name][$key])) { |
|
131 | + if (isset($this->annotations[$name][$key])) { |
|
132 | 132 | return $this->annotations[$name][$key]; |
133 | 133 | } |
134 | 134 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | public function discover(string $remote, string $service, bool $skipCache = false): array { |
66 | 66 | // Check the cache first |
67 | 67 | if ($skipCache === false) { |
68 | - $cacheData = $this->cache->get($remote . '#' . $service); |
|
68 | + $cacheData = $this->cache->get($remote.'#'.$service); |
|
69 | 69 | if ($cacheData) { |
70 | 70 | $data = json_decode($cacheData, true); |
71 | 71 | if (\is_array($data)) { |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | |
79 | 79 | // query the remote server for available services |
80 | 80 | try { |
81 | - $response = $this->client->get($remote . '/ocs-provider/', [ |
|
81 | + $response = $this->client->get($remote.'/ocs-provider/', [ |
|
82 | 82 | 'timeout' => 10, |
83 | 83 | 'connect_timeout' => 10, |
84 | 84 | ]); |
85 | - if($response->getStatusCode() === Http::STATUS_OK) { |
|
85 | + if ($response->getStatusCode() === Http::STATUS_OK) { |
|
86 | 86 | $decodedServices = json_decode($response->getBody(), true); |
87 | 87 | if (\is_array($decodedServices)) { |
88 | 88 | $discoveredServices = $this->getEndpoints($decodedServices, $service); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | // Write into cache |
96 | - $this->cache->set($remote . '#' . $service, json_encode($discoveredServices), 60*60*24); |
|
96 | + $this->cache->set($remote.'#'.$service, json_encode($discoveredServices), 60 * 60 * 24); |
|
97 | 97 | return $discoveredServices; |
98 | 98 | } |
99 | 99 | |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | |
109 | 109 | $discoveredServices = []; |
110 | 110 | |
111 | - if(isset($decodedServices['services'][$service]['endpoints'])) { |
|
111 | + if (isset($decodedServices['services'][$service]['endpoints'])) { |
|
112 | 112 | foreach ($decodedServices['services'][$service]['endpoints'] as $endpoint => $url) { |
113 | - if($this->isSafeUrl($url)) { |
|
113 | + if ($this->isSafeUrl($url)) { |
|
114 | 114 | $discoveredServices[$endpoint] = $url; |
115 | 115 | } |
116 | 116 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @return bool |
128 | 128 | */ |
129 | 129 | protected function isSafeUrl(string $url): bool { |
130 | - return (bool)preg_match('/^[\/\.\-A-Za-z0-9]+$/', $url); |
|
130 | + return (bool) preg_match('/^[\/\.\-A-Za-z0-9]+$/', $url); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | } |