Completed
Pull Request — master (#3643)
by Christoph
12:28
created
apps/federatedfilesharing/lib/DiscoveryManager.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @return bool
63 63
 	 */
64 64
 	private function isSafeUrl($url) {
65
-		return (bool)preg_match('/^[\/\.A-Za-z0-9]+$/', $url);
65
+		return (bool) preg_match('/^[\/\.A-Za-z0-9]+$/', $url);
66 66
 	}
67 67
 
68 68
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	private function discover($remote) {
78 78
 		// Check if something is in the cache
79
-		if($cacheData = $this->cache->get($remote)) {
79
+		if ($cacheData = $this->cache->get($remote)) {
80 80
 			return json_decode($cacheData, true);
81 81
 		}
82 82
 
@@ -88,22 +88,22 @@  discard block
 block discarded – undo
88 88
 
89 89
 		// Read the data from the response body
90 90
 		try {
91
-			$response = $this->client->get($remote . '/ocs-provider/', [
91
+			$response = $this->client->get($remote.'/ocs-provider/', [
92 92
 				'timeout' => 10,
93 93
 				'connect_timeout' => 10,
94 94
 			]);
95
-			if($response->getStatusCode() === 200) {
95
+			if ($response->getStatusCode() === 200) {
96 96
 				$decodedService = json_decode($response->getBody(), true);
97
-				if(is_array($decodedService)) {
97
+				if (is_array($decodedService)) {
98 98
 					$endpoints = [
99 99
 						'webdav',
100 100
 						'share',
101 101
 					];
102 102
 
103
-					foreach($endpoints as $endpoint) {
104
-						if(isset($decodedService['services']['FEDERATED_SHARING']['endpoints'][$endpoint])) {
105
-							$endpointUrl = (string)$decodedService['services']['FEDERATED_SHARING']['endpoints'][$endpoint];
106
-							if($this->isSafeUrl($endpointUrl)) {
103
+					foreach ($endpoints as $endpoint) {
104
+						if (isset($decodedService['services']['FEDERATED_SHARING']['endpoints'][$endpoint])) {
105
+							$endpointUrl = (string) $decodedService['services']['FEDERATED_SHARING']['endpoints'][$endpoint];
106
+							if ($this->isSafeUrl($endpointUrl)) {
107 107
 								$discoveredServices[$endpoint] = $endpointUrl;
108 108
 							}
109 109
 						}
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 		$storedPassword = $share->getPassword();
148 148
 		$authenticated = $this->session->get('public_link_authenticated') === $share->getId() ||
149 149
 			$this->shareManager->checkPassword($share, $password);
150
-		if (!empty($storedPassword) && !$authenticated ) {
150
+		if (!empty($storedPassword) && !$authenticated) {
151 151
 			return new JSONResponse(
152 152
 				['message' => 'No permission to access the share'],
153 153
 				Http::STATUS_BAD_REQUEST
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		$httpClient = $this->clientService->newClient();
190 190
 
191 191
 		try {
192
-			$response = $httpClient->post($remote . '/index.php/apps/federatedfilesharing/createFederatedShare',
192
+			$response = $httpClient->post($remote.'/index.php/apps/federatedfilesharing/createFederatedShare',
193 193
 				[
194 194
 					'body' =>
195 195
 						[
@@ -287,14 +287,14 @@  discard block
 block discarded – undo
287 287
 			// note: checkStorageAvailability will already remove the invalid share
288 288
 			Util::writeLog(
289 289
 				'federatedfilesharing',
290
-				'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
290
+				'Invalid remote storage: '.get_class($e).': '.$e->getMessage(),
291 291
 				Util::DEBUG
292 292
 			);
293 293
 			return new JSONResponse(['message' => $this->l->t('Could not authenticate to remote share, password might be wrong')], Http::STATUS_BAD_REQUEST);
294 294
 		} catch (\Exception $e) {
295 295
 			Util::writeLog(
296 296
 				'federatedfilesharing',
297
-				'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
297
+				'Invalid remote storage: '.get_class($e).': '.$e->getMessage(),
298 298
 				Util::DEBUG
299 299
 			);
300 300
 			$externalManager->removeShare($mount->getMountPoint());
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
 			} catch (StorageInvalidException $e) {
314 314
 				Util::writeLog(
315 315
 					'federatedfilesharing',
316
-					'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
316
+					'Invalid remote storage: '.get_class($e).': '.$e->getMessage(),
317 317
 					Util::DEBUG
318 318
 				);
319 319
 				return new JSONResponse(['message' => $this->l->t('Storage not valid')], Http::STATUS_BAD_REQUEST);
320 320
 			} catch (\Exception $e) {
321 321
 				Util::writeLog(
322 322
 					'federatedfilesharing',
323
-					'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
323
+					'Invalid remote storage: '.get_class($e).': '.$e->getMessage(),
324 324
 					Util::DEBUG
325 325
 				);
326 326
 				return new JSONResponse(['message' => $this->l->t('Couldn\'t add remote share')], Http::STATUS_BAD_REQUEST);
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/Controller/RequestHandlerController.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -127,24 +127,24 @@  discard block
 block discarded – undo
127 127
 		$owner = isset($_POST['owner']) ? $_POST['owner'] : null;
128 128
 		$sharedBy = isset($_POST['sharedBy']) ? $_POST['sharedBy'] : null;
129 129
 		$shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null;
130
-		$remoteId = isset($_POST['remoteId']) ? (int)$_POST['remoteId'] : null;
130
+		$remoteId = isset($_POST['remoteId']) ? (int) $_POST['remoteId'] : null;
131 131
 		$sharedByFederatedId = isset($_POST['sharedByFederatedId']) ? $_POST['sharedByFederatedId'] : null;
132 132
 		$ownerFederatedId = isset($_POST['ownerFederatedId']) ? $_POST['ownerFederatedId'] : null;
133 133
 
134 134
 		if ($remote && $token && $name && $owner && $remoteId && $shareWith) {
135 135
 
136
-			if(!\OCP\Util::isValidFileName($name)) {
136
+			if (!\OCP\Util::isValidFileName($name)) {
137 137
 				throw new OCSException('The mountpoint name contains invalid characters.', 400);
138 138
 			}
139 139
 
140 140
 			// FIXME this should be a method in the user management instead
141
-			\OCP\Util::writeLog('files_sharing', 'shareWith before, ' . $shareWith, \OCP\Util::DEBUG);
141
+			\OCP\Util::writeLog('files_sharing', 'shareWith before, '.$shareWith, \OCP\Util::DEBUG);
142 142
 			\OCP\Util::emitHook(
143 143
 				'\OCA\Files_Sharing\API\Server2Server',
144 144
 				'preLoginNameUsedAsUserName',
145 145
 				array('uid' => &$shareWith)
146 146
 			);
147
-			\OCP\Util::writeLog('files_sharing', 'shareWith after, ' . $shareWith, \OCP\Util::DEBUG);
147
+			\OCP\Util::writeLog('files_sharing', 'shareWith after, '.$shareWith, \OCP\Util::DEBUG);
148 148
 
149 149
 			if (!\OCP\User::userExists($shareWith)) {
150 150
 				throw new OCSException('User does not exists', 400);
@@ -199,20 +199,20 @@  discard block
 block discarded – undo
199 199
 
200 200
 				$declineAction = $notification->createAction();
201 201
 				$declineAction->setLabel('decline')
202
-					->setLink($urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE');
202
+					->setLink($urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'DELETE');
203 203
 				$notification->addAction($declineAction);
204 204
 
205 205
 				$acceptAction = $notification->createAction();
206 206
 				$acceptAction->setLabel('accept')
207
-					->setLink($urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST');
207
+					->setLink($urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'POST');
208 208
 				$notification->addAction($acceptAction);
209 209
 
210 210
 				$notificationManager->notify($notification);
211 211
 
212 212
 				return new Http\DataResponse();
213 213
 			} catch (\Exception $e) {
214
-				\OCP\Util::writeLog('files_sharing', 'server can not add remote share, ' . $e->getMessage(), \OCP\Util::ERROR);
215
-				throw new OCSException('internal server error, was not able to add share from ' . $remote, 500);
214
+				\OCP\Util::writeLog('files_sharing', 'server can not add remote share, '.$e->getMessage(), \OCP\Util::ERROR);
215
+				throw new OCSException('internal server error, was not able to add share from '.$remote, 500);
216 216
 			}
217 217
 		}
218 218
 
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 
236 236
 		$token = $this->request->getParam('token', null);
237 237
 		$shareWith = $this->request->getParam('shareWith', null);
238
-		$permission = (int)$this->request->getParam('permission', null);
239
-		$remoteId = (int)$this->request->getParam('remoteId', null);
238
+		$permission = (int) $this->request->getParam('permission', null);
239
+		$remoteId = (int) $this->request->getParam('remoteId', null);
240 240
 
241 241
 		if ($id === null ||
242 242
 			$token === null ||
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 		list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith);
258 258
 		$owner = $share->getShareOwner();
259 259
 		$currentServer = $this->addressHandler->generateRemoteURL();
260
-		if ($this->addressHandler->compareAddresses($user, $remote,$owner , $currentServer)) {
260
+		if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) {
261 261
 			throw new OCSForbiddenException();
262 262
 		}
263 263
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 				$share->setSharedWith($shareWith);
272 272
 				try {
273 273
 					$result = $this->federatedShareProvider->create($share);
274
-					$this->federatedShareProvider->storeRemoteId((int)$result->getId(), $remoteId);
274
+					$this->federatedShareProvider->storeRemoteId((int) $result->getId(), $remoteId);
275 275
 					return new Http\DataResponse([
276 276
 						'token' => $result->getToken(),
277 277
 						'remoteId' => $result->getId()
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 			return new Http\DataResponse();
360 360
 		}
361 361
 
362
-		if($this->verifyShare($share, $token)) {
362
+		if ($this->verifyShare($share, $token)) {
363 363
 			if ($share->getShareOwner() !== $share->getSharedBy()) {
364 364
 				list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
365 365
 				$remoteId = $this->federatedShareProvider->getRemoteId($share);
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 * @return string
399 399
 	 */
400 400
 	protected function getCorrectUid(Share\IShare $share) {
401
-		if($this->userManager->userExists($share->getShareOwner())) {
401
+		if ($this->userManager->userExists($share->getShareOwner())) {
402 402
 			return $share->getShareOwner();
403 403
 		}
404 404
 
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 		$validPermission = ctype_digit($permissions);
599 599
 		$validToken = $this->verifyShare($share, $token);
600 600
 		if ($validPermission && $validToken) {
601
-			$this->updatePermissionsInDatabase($share, (int)$permissions);
601
+			$this->updatePermissionsInDatabase($share, (int) $permissions);
602 602
 		} else {
603 603
 			throw new OCSBadRequestException();
604 604
 		}
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		$token = $argument['token'];
106 106
 		$action = $argument['action'];
107 107
 		$data = json_decode($argument['data'], true);
108
-		$try = (int)$argument['try'] + 1;
108
+		$try = (int) $argument['try'] + 1;
109 109
 
110 110
 		$result = $this->notifications->sendUpdateToRemote($remote, $remoteId, $token, $action, $data, $try);
111 111
 		
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				'token' => $argument['token'],
129 129
 				'data' => $argument['data'],
130 130
 				'action' => $argument['action'],
131
-				'try' => (int)$argument['try'] + 1,
131
+				'try' => (int) $argument['try'] + 1,
132 132
 				'lastRun' => time()
133 133
 			]
134 134
 		);
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @return bool
142 142
 	 */
143 143
 	protected function shouldRun(array $argument) {
144
-		$lastRun = (int)$argument['lastRun'];
144
+		$lastRun = (int) $argument['lastRun'];
145 145
 		return ((time() - $lastRun) > $this->interval);
146 146
 	}
147 147
 
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/TokenHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 	public function generateToken() {
56 56
 		$token = $this->secureRandom->generate(
57 57
 			self::TOKEN_LENGTH,
58
-			ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
58
+			ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_DIGITS);
59 59
 		return $token;
60 60
 	}
61 61
 
Please login to merge, or discard this patch.
apps/federation/templates/settings-admin.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	<em><?php p($l->t('Federation allows you to connect with other trusted servers to exchange the user directory. For example this will be used to auto-complete external users for federated sharing.')); ?></em>
12 12
 
13 13
 	<p>
14
-		<input id="autoAddServers" type="checkbox" class="checkbox" <?php if($_['autoAddServers']) p('checked'); ?> />
14
+		<input id="autoAddServers" type="checkbox" class="checkbox" <?php if ($_['autoAddServers']) p('checked'); ?> />
15 15
 		<label for="autoAddServers"><?php p($l->t('Add server automatically once a federated share was created successfully')); ?></label>
16 16
 	</p>
17 17
 
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 		<span class="msg"></span>
24 24
 	</p>
25 25
 	<ul id="listOfTrustedServers">
26
-		<?php foreach($_['trustedServers'] as $trustedServer) { ?>
26
+		<?php foreach ($_['trustedServers'] as $trustedServer) { ?>
27 27
 			<li id="<?php p($trustedServer['id']); ?>">
28
-				<?php if((int)$trustedServer['status'] === TrustedServers::STATUS_OK) { ?>
28
+				<?php if ((int) $trustedServer['status'] === TrustedServers::STATUS_OK) { ?>
29 29
 					<span class="status success"></span>
30 30
 				<?php
31
-				} elseif(
32
-					(int)$trustedServer['status'] === TrustedServers::STATUS_PENDING ||
33
-					(int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED
31
+				} elseif (
32
+					(int) $trustedServer['status'] === TrustedServers::STATUS_PENDING ||
33
+					(int) $trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED
34 34
 				) { ?>
35 35
 					<span class="status indeterminate"></span>
36 36
 				<?php } else {?>
Please login to merge, or discard this patch.
apps/federation/lib/Controller/OCSAuthAPIController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @package OCA\Federation\Controller
46 46
  */
47
-class OCSAuthAPIController extends OCSController{
47
+class OCSAuthAPIController extends OCSController {
48 48
 
49 49
 	/** @var ISecureRandom  */
50 50
 	private $secureRandom;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	public function requestSharedSecret($url, $token) {
105 105
 		if ($this->trustedServers->isTrustedServer($url) === false) {
106
-			$this->logger->error('remote server not trusted (' . $url . ') while requesting shared secret', ['app' => 'federation']);
106
+			$this->logger->error('remote server not trusted ('.$url.') while requesting shared secret', ['app' => 'federation']);
107 107
 			throw new OCSForbiddenException();
108 108
 		}
109 109
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		$localToken = $this->dbHandler->getToken($url);
113 113
 		if (strcmp($localToken, $token) > 0) {
114 114
 			$this->logger->info(
115
-				'remote server (' . $url . ') presented lower token. We will initiate the exchange of the shared secret.',
115
+				'remote server ('.$url.') presented lower token. We will initiate the exchange of the shared secret.',
116 116
 				['app' => 'federation']
117 117
 			);
118 118
 			throw new OCSForbiddenException();
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	public function getSharedSecret($url, $token) {
153 153
 		if ($this->trustedServers->isTrustedServer($url) === false) {
154
-			$this->logger->error('remote server not trusted (' . $url . ') while getting shared secret', ['app' => 'federation']);
154
+			$this->logger->error('remote server not trusted ('.$url.') while getting shared secret', ['app' => 'federation']);
155 155
 			throw new OCSForbiddenException();
156 156
 		}
157 157
 
158 158
 		if ($this->isValidToken($url, $token) === false) {
159 159
 			$expectedToken = $this->dbHandler->getToken($url);
160 160
 			$this->logger->error(
161
-				'remote server (' . $url . ') didn\'t send a valid token (got "' . $token . '" but expected "'. $expectedToken . '") while getting shared secret',
161
+				'remote server ('.$url.') didn\'t send a valid token (got "'.$token.'" but expected "'.$expectedToken.'") while getting shared secret',
162 162
 				['app' => 'federation']
163 163
 			);
164 164
 			throw new OCSForbiddenException();
Please login to merge, or discard this patch.
apps/federation/lib/AppInfo/Application.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
 			);
83 83
 		});
84 84
 
85
-		$container->registerService('SettingsController', function (IAppContainer $c) {
85
+		$container->registerService('SettingsController', function(IAppContainer $c) {
86 86
 			$server = $c->getServer();
87 87
 			return new SettingsController(
88 88
 				$c->getAppName(),
Please login to merge, or discard this patch.
apps/federation/lib/Command/SyncFederationAddressBooks.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
 		$progress->start();
61 61
 		$this->syncService->syncThemAll(function($url, $ex) use ($progress, $output) {
62 62
 			if ($ex instanceof \Exception) {
63
-				$output->writeln("Error while syncing $url : " . $ex->getMessage());
63
+				$output->writeln("Error while syncing $url : ".$ex->getMessage());
64 64
 
65 65
 			} else {
66 66
 				$progress->advance();
Please login to merge, or discard this patch.