@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @throws ShareNotFound |
95 | 95 | */ |
96 | 96 | public function beforeController($controller, $methodName) { |
97 | - if(!$this->isSharingEnabled()) { |
|
97 | + if (!$this->isSharingEnabled()) { |
|
98 | 98 | throw new NotFoundException('Sharing is disabled.'); |
99 | 99 | } |
100 | 100 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @throws \Exception |
115 | 115 | */ |
116 | 116 | public function afterException($controller, $methodName, \Exception $exception) { |
117 | - if(is_a($exception, NotFoundException::class)) { |
|
117 | + if (is_a($exception, NotFoundException::class)) { |
|
118 | 118 | return new NotFoundResponse(); |
119 | 119 | } |
120 | 120 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | private function isSharingEnabled() { |
152 | 152 | // FIXME: This check is done here since the route is globally defined and not inside the files_sharing app |
153 | 153 | // Check whether the sharing application is enabled |
154 | - if(!$this->appManager->isEnabledForUser($this->appName)) { |
|
154 | + if (!$this->appManager->isEnabledForUser($this->appName)) { |
|
155 | 155 | return false; |
156 | 156 | } |
157 | 157 |
@@ -83,7 +83,7 @@ |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | // Check whether public sharing is enabled |
86 | - if($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { |
|
86 | + if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $owner = isset($_POST['owner']) ? $_POST['owner'] : null; |
146 | 146 | $sharedBy = isset($_POST['sharedBy']) ? $_POST['sharedBy'] : null; |
147 | 147 | $shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null; |
148 | - $remoteId = isset($_POST['remoteId']) ? (int)$_POST['remoteId'] : null; |
|
148 | + $remoteId = isset($_POST['remoteId']) ? (int) $_POST['remoteId'] : null; |
|
149 | 149 | $sharedByFederatedId = isset($_POST['sharedByFederatedId']) ? $_POST['sharedByFederatedId'] : null; |
150 | 150 | $ownerFederatedId = isset($_POST['ownerFederatedId']) ? $_POST['ownerFederatedId'] : null; |
151 | 151 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | } catch (ProviderCouldNotAddShareException $e) { |
181 | 181 | throw new OCSException($e->getMessage(), 400); |
182 | 182 | } catch (\Exception $e) { |
183 | - throw new OCSException('internal server error, was not able to add share from ' . $remote, 500); |
|
183 | + throw new OCSException('internal server error, was not able to add share from '.$remote, 500); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | return new Http\DataResponse(); |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | |
203 | 203 | $token = $this->request->getParam('token', null); |
204 | 204 | $shareWith = $this->request->getParam('shareWith', null); |
205 | - $permission = (int)$this->request->getParam('permission', null); |
|
206 | - $remoteId = (int)$this->request->getParam('remoteId', null); |
|
205 | + $permission = (int) $this->request->getParam('permission', null); |
|
206 | + $remoteId = (int) $this->request->getParam('remoteId', null); |
|
207 | 207 | |
208 | 208 | if ($id === null || |
209 | 209 | $token === null || |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | } catch (ProviderDoesNotExistsException $e) { |
232 | 232 | throw new OCSException('Server does not support federated cloud sharing', 503); |
233 | 233 | } catch (ShareNotFound $e) { |
234 | - $this->logger->debug('Share not found: ' . $e->getMessage()); |
|
234 | + $this->logger->debug('Share not found: '.$e->getMessage()); |
|
235 | 235 | } catch (\Exception $e) { |
236 | - $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); |
|
236 | + $this->logger->debug('internal server error, can not process notification: '.$e->getMessage()); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | throw new OCSBadRequestException(); |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | } catch (ProviderDoesNotExistsException $e) { |
268 | 268 | throw new OCSException('Server does not support federated cloud sharing', 503); |
269 | 269 | } catch (ShareNotFound $e) { |
270 | - $this->logger->debug('Share not found: ' . $e->getMessage()); |
|
270 | + $this->logger->debug('Share not found: '.$e->getMessage()); |
|
271 | 271 | } catch (\Exception $e) { |
272 | - $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); |
|
272 | + $this->logger->debug('internal server error, can not process notification: '.$e->getMessage()); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return new Http\DataResponse(); |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | } catch (ProviderDoesNotExistsException $e) { |
301 | 301 | throw new OCSException('Server does not support federated cloud sharing', 503); |
302 | 302 | } catch (ShareNotFound $e) { |
303 | - $this->logger->debug('Share not found: ' . $e->getMessage()); |
|
303 | + $this->logger->debug('Share not found: '.$e->getMessage()); |
|
304 | 304 | } catch (\Exception $e) { |
305 | - $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); |
|
305 | + $this->logger->debug('internal server error, can not process notification: '.$e->getMessage()); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | return new Http\DataResponse(); |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | $notification = ['sharedSecret' => $token]; |
332 | 332 | $provider->notificationReceived('SHARE_UNSHARED', $id, $notification); |
333 | 333 | } catch (\Exception $e) { |
334 | - $this->logger->debug('processing unshare notification failed: ' . $e->getMessage()); |
|
334 | + $this->logger->debug('processing unshare notification failed: '.$e->getMessage()); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | return new Http\DataResponse(); |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | |
405 | 405 | try { |
406 | 406 | $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); |
407 | - $ocmPermissions = $this->ncPermissions2ocmPermissions((int)$ncPermissions); |
|
407 | + $ocmPermissions = $this->ncPermissions2ocmPermissions((int) $ncPermissions); |
|
408 | 408 | $notification = ['sharedSecret' => $token, 'permission' => $ocmPermissions]; |
409 | 409 | $provider->notificationReceived('RESHARE_CHANGE_PERMISSION', $id, $notification); |
410 | 410 | } catch (\Exception $e) { |
@@ -43,21 +43,21 @@ discard block |
||
43 | 43 | * |
44 | 44 | */ |
45 | 45 | public function run($arguments) { |
46 | - $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); |
|
46 | + $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data'); |
|
47 | 47 | $instanceId = $this->config->getSystemValue('instanceid', null); |
48 | 48 | |
49 | - if(!is_string($instanceId) || empty($instanceId)) { |
|
49 | + if (!is_string($instanceId) || empty($instanceId)) { |
|
50 | 50 | return; |
51 | 51 | } |
52 | 52 | |
53 | - $updaterFolderPath = $dataDir . '/updater-' . $instanceId; |
|
54 | - $backupFolderPath = $updaterFolderPath . '/backups'; |
|
55 | - if(file_exists($backupFolderPath)) { |
|
53 | + $updaterFolderPath = $dataDir.'/updater-'.$instanceId; |
|
54 | + $backupFolderPath = $updaterFolderPath.'/backups'; |
|
55 | + if (file_exists($backupFolderPath)) { |
|
56 | 56 | $this->log->info("$backupFolderPath exists - start to clean it up"); |
57 | 57 | |
58 | 58 | $dirList = []; |
59 | 59 | $dirs = new \DirectoryIterator($backupFolderPath); |
60 | - foreach($dirs as $dir) { |
|
60 | + foreach ($dirs as $dir) { |
|
61 | 61 | // skip files and dot dirs |
62 | 62 | if ($dir->isFile() || $dir->isDot()) { |
63 | 63 | continue; |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | ksort($dirList); |
77 | 77 | // drop the newest 3 directories |
78 | 78 | $dirList = array_slice($dirList, 0, -3); |
79 | - $this->log->info("List of all directories that will be deleted: " . json_encode($dirList)); |
|
79 | + $this->log->info("List of all directories that will be deleted: ".json_encode($dirList)); |
|
80 | 80 | |
81 | - foreach($dirList as $dir) { |
|
81 | + foreach ($dirList as $dir) { |
|
82 | 82 | $this->log->info("Removing $dir ..."); |
83 | 83 | \OC_Helper::rmdirr($dir); |
84 | 84 | } |
@@ -162,7 +162,7 @@ |
||
162 | 162 | $app = strtolower($this->appName); |
163 | 163 | $class = strtolower((new \ReflectionClass($this))->getShortName()); |
164 | 164 | |
165 | - return $app . '.' . $class . '.' . $function; |
|
165 | + return $app.'.'.$class.'.'.$function; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -184,7 +184,7 @@ |
||
184 | 184 | if (is_array($scope)) { |
185 | 185 | parent::setScope(json_encode($scope)); |
186 | 186 | } else { |
187 | - parent::setScope((string)$scope); |
|
187 | + parent::setScope((string) $scope); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | /** |
5 | 5 | * @copyright Copyright (c) 2016, ownCloud, Inc. |
6 | 6 | * |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | if (!empty($missing)) { |
201 | 201 | // There was at least one provider missing |
202 | - $this->logger->alert(count($missing) . " two-factor auth providers failed to load", ['app' => 'core']); |
|
202 | + $this->logger->alert(count($missing)." two-factor auth providers failed to load", ['app' => 'core']); |
|
203 | 203 | |
204 | 204 | return true; |
205 | 205 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $fixedStates = $this->fixMissingProviderStates($providerStates, $providers, $user); |
222 | 222 | $isProviderMissing = $this->isProviderMissing($fixedStates, $providers); |
223 | 223 | |
224 | - $enabled = array_filter($providers, function (IProvider $provider) use ($fixedStates) { |
|
224 | + $enabled = array_filter($providers, function(IProvider $provider) use ($fixedStates) { |
|
225 | 225 | return $fixedStates[$provider->getId()]; |
226 | 226 | }); |
227 | 227 | return new ProviderSet($enabled, $isProviderMissing); |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare (strict_types = 1); |
|
2 | +declare(strict_types=1); |
|
3 | 3 | /** |
4 | 4 | * @copyright Copyright (c) 2018 John Molakvoæ <[email protected]> |
5 | 5 | * |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $secure = $protocol === 'https'; |
80 | 80 | $federatedSharingEndpoints = $discoveryService->discover($this->cloudId->getRemote(), 'FEDERATED_SHARING'); |
81 | 81 | $webDavEndpoint = isset($federatedSharingEndpoints['webdav']) ? $federatedSharingEndpoints['webdav'] : '/public.php/webdav'; |
82 | - $root = rtrim($root, '/') . $webDavEndpoint; |
|
82 | + $root = rtrim($root, '/').$webDavEndpoint; |
|
83 | 83 | $this->mountPoint = $options['mountpoint']; |
84 | 84 | $this->token = $options['token']; |
85 | 85 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | 'host' => $host, |
89 | 89 | 'root' => $root, |
90 | 90 | 'user' => $options['token'], |
91 | - 'password' => (string)$options['password'] |
|
91 | + 'password' => (string) $options['password'] |
|
92 | 92 | )); |
93 | 93 | } |
94 | 94 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return string |
129 | 129 | */ |
130 | 130 | public function getId() { |
131 | - return 'shared::' . md5($this->token . '@' . $this->getRemote()); |
|
131 | + return 'shared::'.md5($this->token.'@'.$this->getRemote()); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | public function getCache($path = '', $storage = null) { |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | */ |
250 | 250 | protected function testRemote() { |
251 | 251 | try { |
252 | - return $this->testRemoteUrl($this->getRemote() . '/ocs-provider/index.php') |
|
253 | - || $this->testRemoteUrl($this->getRemote() . '/ocs-provider/') |
|
254 | - || $this->testRemoteUrl($this->getRemote() . '/status.php'); |
|
252 | + return $this->testRemoteUrl($this->getRemote().'/ocs-provider/index.php') |
|
253 | + || $this->testRemoteUrl($this->getRemote().'/ocs-provider/') |
|
254 | + || $this->testRemoteUrl($this->getRemote().'/status.php'); |
|
255 | 255 | } catch (\Exception $e) { |
256 | 256 | return false; |
257 | 257 | } |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | */ |
264 | 264 | private function testRemoteUrl($url) { |
265 | 265 | $cache = $this->memcacheFactory->createDistributed('files_sharing_remote_url'); |
266 | - if($cache->hasKey($url)) { |
|
267 | - return (bool)$cache->get($url); |
|
266 | + if ($cache->hasKey($url)) { |
|
267 | + return (bool) $cache->get($url); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | $client = $this->httpClient->newClient(); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $returnValue = false; |
282 | 282 | } |
283 | 283 | |
284 | - $cache->set($url, $returnValue, 60*60*24); |
|
284 | + $cache->set($url, $returnValue, 60 * 60 * 24); |
|
285 | 285 | return $returnValue; |
286 | 286 | } |
287 | 287 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @return bool |
293 | 293 | */ |
294 | 294 | public function remoteIsOwnCloud() { |
295 | - if(defined('PHPUNIT_RUN') || !$this->testRemoteUrl($this->getRemote() . '/status.php')) { |
|
295 | + if (defined('PHPUNIT_RUN') || !$this->testRemoteUrl($this->getRemote().'/status.php')) { |
|
296 | 296 | return false; |
297 | 297 | } |
298 | 298 | return true; |
@@ -310,11 +310,11 @@ discard block |
||
310 | 310 | $password = $this->getPassword(); |
311 | 311 | |
312 | 312 | // If remote is not an ownCloud do not try to get any share info |
313 | - if(!$this->remoteIsOwnCloud()) { |
|
313 | + if (!$this->remoteIsOwnCloud()) { |
|
314 | 314 | return ['status' => 'unsupported']; |
315 | 315 | } |
316 | 316 | |
317 | - $url = rtrim($remote, '/') . '/index.php/apps/files_sharing/shareinfo?t=' . $token; |
|
317 | + $url = rtrim($remote, '/').'/index.php/apps/files_sharing/shareinfo?t='.$token; |
|
318 | 318 | |
319 | 319 | // TODO: DI |
320 | 320 | $client = \OC::$server->getHTTPClientService()->newClient(); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | try { |
383 | 383 | $ocmPermissions = json_decode($ocmPermissions); |
384 | 384 | $ncPermissions = 0; |
385 | - foreach($ocmPermissions as $permission) { |
|
385 | + foreach ($ocmPermissions as $permission) { |
|
386 | 386 | switch (strtolower($permission)) { |
387 | 387 | case 'read': |
388 | 388 | $ncPermissions += Constants::PERMISSION_READ; |