Completed
Pull Request — master (#3233)
by Christoph
14:41
created
apps/testing/lib/AlternativeHomeUserBackend.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 			if ($uid !== 'admin') {
49 49
 				$uid = md5($uid);
50 50
 			}
51
-			return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid;
51
+			return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/'.$uid;
52 52
 		}
53 53
 
54 54
 		return false;
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/Notifications.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 			'remoteId' => $shareId
134 134
 		);
135 135
 
136
-		$result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $id . '/reshare', $fields);
136
+		$result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/'.$id.'/reshare', $fields);
137 137
 		$status = json_decode($result['result'], true);
138 138
 
139 139
 		$httpRequestSuccessful = $result['success'];
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		if ($httpRequestSuccessful && $ocsCallSuccessful && $validToken && $validRemoteId) {
145 145
 			return [
146 146
 				$status['ocs']['data']['token'],
147
-				(int)$status['ocs']['data']['remoteId']
147
+				(int) $status['ocs']['data']['remoteId']
148 148
 			];
149 149
 		}
150 150
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 			$fields[$key] = $value;
229 229
 		}
230 230
 
231
-		$result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $remoteId . '/' . $action, $fields);
231
+		$result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/'.$remoteId.'/'.$action, $fields);
232 232
 		$status = json_decode($result['result'], true);
233 233
 
234 234
 		if ($result['success'] &&
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		$client = $this->httpClientService->newClient();
280 280
 
281 281
 		if ($this->addressHandler->urlContainProtocol($remoteDomain) === false) {
282
-			$remoteDomain = 'https://' . $remoteDomain;
282
+			$remoteDomain = 'https://'.$remoteDomain;
283 283
 		}
284 284
 
285 285
 		$result = [
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 
290 290
 		$endpoint = $this->discoveryManager->getShareEndpoint($remoteDomain);
291 291
 		try {
292
-			$response = $client->post($remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, [
292
+			$response = $client->post($remoteDomain.$endpoint.$urlSuffix.'?format='.self::RESPONSE_FORMAT, [
293 293
 				'body' => $fields,
294 294
 				'timeout' => 10,
295 295
 				'connect_timeout' => 10,
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/Notifier.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -184,12 +184,12 @@
 block discarded – undo
184 184
 		}
185 185
 
186 186
 		try {
187
-			$this->getDisplayNameFromContact($user . '@http://' . $server);
187
+			$this->getDisplayNameFromContact($user.'@http://'.$server);
188 188
 		} catch (\OutOfBoundsException $e) {
189 189
 		}
190 190
 
191 191
 		try {
192
-			$this->getDisplayNameFromContact($user . '@https://' . $server);
192
+			$this->getDisplayNameFromContact($user.'@https://'.$server);
193 193
 		} catch (\OutOfBoundsException $e) {
194 194
 		}
195 195
 
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/FederatedShareProvider.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		if ($remoteShare) {
183 183
 			try {
184 184
 				$ownerCloudId = $this->cloudIdManager->getCloudId($remoteShare['owner'], $remoteShare['remote']);
185
-				$shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_' . time());
185
+				$shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_'.time());
186 186
 				$share->setId($shareId);
187 187
 				list($token, $remoteId) = $this->askOwnerToReShare($shareWith, $share, $shareId);
188 188
 				// remote share was create successfully if we get a valid token as return
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
 				$failure = true;
255 255
 			}
256 256
 		} catch (\Exception $e) {
257
-			$this->logger->error('Failed to notify remote server of federated share, removing share (' . $e->getMessage() . ')');
257
+			$this->logger->error('Failed to notify remote server of federated share, removing share ('.$e->getMessage().')');
258 258
 			$failure = true;
259 259
 		}
260 260
 
261
-		if($failure) {
261
+		if ($failure) {
262 262
 			$this->removeShareFromTableById($shareId);
263 263
 			$message_t = $this->l->t('Sharing %s failed, could not find %s, maybe the server is currently unreachable or uses a self-signed certificate.',
264 264
 				[$share->getNode()->getName(), $share->getSharedWith()]);
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 			->andWhere($query->expr()->eq('mountpoint', $query->createNamedParameter($share->getTarget())));
310 310
 		$result = $query->execute()->fetchAll();
311 311
 
312
-		if (isset($result[0]) && (int)$result[0]['remote_id'] > 0) {
312
+		if (isset($result[0]) && (int) $result[0]['remote_id'] > 0) {
313 313
 			return $result[0];
314 314
 		}
315 315
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 		$qb->execute();
352 352
 		$id = $qb->getLastInsertId();
353 353
 
354
-		return (int)$id;
354
+		return (int) $id;
355 355
 	}
356 356
 
357 357
 	/**
@@ -441,14 +441,14 @@  discard block
 block discarded – undo
441 441
 	public function getRemoteId(IShare $share) {
442 442
 		$query = $this->dbConnection->getQueryBuilder();
443 443
 		$query->select('remote_id')->from('federated_reshares')
444
-			->where($query->expr()->eq('share_id', $query->createNamedParameter((int)$share->getId())));
444
+			->where($query->expr()->eq('share_id', $query->createNamedParameter((int) $share->getId())));
445 445
 		$data = $query->execute()->fetch();
446 446
 
447 447
 		if (!is_array($data) || !isset($data['remote_id'])) {
448 448
 			throw new ShareNotFound();
449 449
 		}
450 450
 
451
-		return (int)$data['remote_id'];
451
+		return (int) $data['remote_id'];
452 452
 	}
453 453
 
454 454
 	/**
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 			->orderBy('id');
480 480
 
481 481
 		$cursor = $qb->execute();
482
-		while($data = $cursor->fetch()) {
482
+		while ($data = $cursor->fetch()) {
483 483
 			$children[] = $this->createShareObject($data);
484 484
 		}
485 485
 		$cursor->closeCursor();
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 			);
609 609
 		}
610 610
 
611
-		$qb->innerJoin('s', 'filecache' ,'f', 's.file_source = f.fileid');
611
+		$qb->innerJoin('s', 'filecache', 'f', 's.file_source = f.fileid');
612 612
 		$qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId())));
613 613
 
614 614
 		$qb->orderBy('id');
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 
672 672
 		$cursor = $qb->execute();
673 673
 		$shares = [];
674
-		while($data = $cursor->fetch()) {
674
+		while ($data = $cursor->fetch()) {
675 675
 			$shares[] = $this->createShareObject($data);
676 676
 		}
677 677
 		$cursor->closeCursor();
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 			->execute();
724 724
 
725 725
 		$shares = [];
726
-		while($data = $cursor->fetch()) {
726
+		while ($data = $cursor->fetch()) {
727 727
 			$shares[] = $this->createShareObject($data);
728 728
 		}
729 729
 		$cursor->closeCursor();
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 
763 763
 		$cursor = $qb->execute();
764 764
 
765
-		while($data = $cursor->fetch()) {
765
+		while ($data = $cursor->fetch()) {
766 766
 			$shares[] = $this->createShareObject($data);
767 767
 		}
768 768
 		$cursor->closeCursor();
@@ -839,15 +839,15 @@  discard block
 block discarded – undo
839 839
 	private function createShareObject($data) {
840 840
 
841 841
 		$share = new Share($this->rootFolder, $this->userManager);
842
-		$share->setId((int)$data['id'])
843
-			->setShareType((int)$data['share_type'])
844
-			->setPermissions((int)$data['permissions'])
842
+		$share->setId((int) $data['id'])
843
+			->setShareType((int) $data['share_type'])
844
+			->setPermissions((int) $data['permissions'])
845 845
 			->setTarget($data['file_target'])
846
-			->setMailSend((bool)$data['mail_send'])
846
+			->setMailSend((bool) $data['mail_send'])
847 847
 			->setToken($data['token']);
848 848
 
849 849
 		$shareTime = new \DateTime();
850
-		$shareTime->setTimestamp((int)$data['stime']);
850
+		$shareTime->setTimestamp((int) $data['stime']);
851 851
 		$share->setShareTime($shareTime);
852 852
 		$share->setSharedWith($data['share_with']);
853 853
 
@@ -857,13 +857,13 @@  discard block
 block discarded – undo
857 857
 		} else {
858 858
 			//OLD SHARE
859 859
 			$share->setSharedBy($data['uid_owner']);
860
-			$path = $this->getNode($share->getSharedBy(), (int)$data['file_source']);
860
+			$path = $this->getNode($share->getSharedBy(), (int) $data['file_source']);
861 861
 
862 862
 			$owner = $path->getOwner();
863 863
 			$share->setShareOwner($owner->getUID());
864 864
 		}
865 865
 
866
-		$share->setNodeId((int)$data['file_source']);
866
+		$share->setNodeId((int) $data['file_source']);
867 867
 		$share->setNodeType($data['item_type']);
868 868
 
869 869
 		$share->setProviderId($this->identifier());
Please login to merge, or discard this patch.
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/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.