Passed
Push — master ( 7fa061...fde4c5 )
by Morris
12:18
created
apps/files_sharing/lib/External/Manager.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -148,18 +148,18 @@  discard block
 block discarded – undo
148 148
 	 * @return Mount|null
149 149
 	 * @throws \Doctrine\DBAL\DBALException
150 150
 	 */
151
-	public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted=false, $user = null, $remoteId = -1, $parent = -1) {
151
+	public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted = false, $user = null, $remoteId = -1, $parent = -1) {
152 152
 
153 153
 		$user = $user ? $user : $this->uid;
154 154
 		$accepted = $accepted ? 1 : 0;
155
-		$name = Filesystem::normalizePath('/' . $name);
155
+		$name = Filesystem::normalizePath('/'.$name);
156 156
 
157 157
 		if (!$accepted) {
158 158
 			// To avoid conflicts with the mount point generation later,
159 159
 			// we only use a temporary mount point name here. The real
160 160
 			// mount point name will be generated when accepting the share,
161 161
 			// using the original share item name.
162
-			$tmpMountPointName = '{{TemporaryMountPointName#' . $name . '}}';
162
+			$tmpMountPointName = '{{TemporaryMountPointName#'.$name.'}}';
163 163
 			$mountPoint = $tmpMountPointName;
164 164
 			$hash = md5($tmpMountPointName);
165 165
 			$data = [
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			$i = 1;
180 180
 			while (!$this->connection->insertIfNotExist('*PREFIX*share_external', $data, ['user', 'mountpoint_hash'])) {
181 181
 				// The external share already exists for the user
182
-				$data['mountpoint'] = $tmpMountPointName . '-' . $i;
182
+				$data['mountpoint'] = $tmpMountPointName.'-'.$i;
183 183
 				$data['mountpoint_hash'] = md5($data['mountpoint']);
184 184
 				$i++;
185 185
 			}
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		}
188 188
 
189 189
 		$mountPoint = Files::buildNotExistingFileName('/', $name);
190
-		$mountPoint = Filesystem::normalizePath('/' . $mountPoint);
190
+		$mountPoint = Filesystem::normalizePath('/'.$mountPoint);
191 191
 		$hash = md5($mountPoint);
192 192
 
193 193
 		$this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType);
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 		$validShare = is_array($share) && isset($share['share_type']) && isset($share['user']);
247 247
 
248 248
 		// check if the user is allowed to access it
249
-		if ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_USER && $share['user'] === $this->uid) {
249
+		if ($validShare && (int) $share['share_type'] === Share::SHARE_TYPE_USER && $share['user'] === $this->uid) {
250 250
 			return $share;
251
-		} else if ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) {
251
+		} else if ($validShare && (int) $share['share_type'] === Share::SHARE_TYPE_GROUP) {
252 252
 			$user = $this->userManager->get($this->uid);
253 253
 			if ($this->groupManager->get($share['user'])->inGroup($user)) {
254 254
 				return $share;
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 			$hash = md5($mountPoint);
279 279
 			$userShareAccepted = false;
280 280
 
281
-			if((int)$share['share_type'] === Share::SHARE_TYPE_USER) {
281
+			if ((int) $share['share_type'] === Share::SHARE_TYPE_USER) {
282 282
 				$acceptShare = $this->connection->prepare('
283 283
 				UPDATE `*PREFIX*share_external`
284 284
 				SET `accepted` = ?,
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		$share = $this->getShare($id);
324 324
 		$result = false;
325 325
 
326
-		if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_USER) {
326
+		if ($share && (int) $share['share_type'] === Share::SHARE_TYPE_USER) {
327 327
 			$removeShare = $this->connection->prepare('
328 328
 				DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?');
329 329
 			$removeShare->execute(array($id, $this->uid));
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 
332 332
 			$this->processNotification($id);
333 333
 			$result = true;
334
-		} else if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) {
334
+		} else if ($share && (int) $share['share_type'] === Share::SHARE_TYPE_GROUP) {
335 335
 			$result = $this->writeShareToDb(
336 336
 				$share['remote'],
337 337
 				$share['share_token'],
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
 
376 376
 		$result = $this->tryOCMEndPoint($remote, $token, $remoteId, $feedback);
377 377
 
378
-		if($result === true) {
378
+		if ($result === true) {
379 379
 			return true;
380 380
 		}
381 381
 
382 382
 		$federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING');
383 383
 		$endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
384 384
 
385
-		$url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT;
385
+		$url = rtrim($remote, '/').$endpoint.'/'.$remoteId.'/'.$feedback.'?format='.Share::RESPONSE_FORMAT;
386 386
 		$fields = array('token' => $token);
387 387
 
388 388
 		$client = $this->clientService->newClient();
@@ -455,13 +455,13 @@  discard block
 block discarded – undo
455 455
 	 * @return string
456 456
 	 */
457 457
 	protected function stripPath($path) {
458
-		$prefix = '/' . $this->uid . '/files';
458
+		$prefix = '/'.$this->uid.'/files';
459 459
 		return rtrim(substr($path, strlen($prefix)), '/');
460 460
 	}
461 461
 
462 462
 	public function getMount($data) {
463 463
 		$data['manager'] = $this;
464
-		$mountPoint = '/' . $this->uid . '/files' . $data['mountpoint'];
464
+		$mountPoint = '/'.$this->uid.'/files'.$data['mountpoint'];
465 465
 		$data['mountpoint'] = $mountPoint;
466 466
 		$data['certificateManager'] = \OC::$server->getCertificateManager($this->uid);
467 467
 		return new Mount(self::STORAGE, $mountPoint, $data, $this, $this->storageLoader);
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 			WHERE `mountpoint_hash` = ?
502 502
 			AND `user` = ?
503 503
 		');
504
-		$result = (bool)$query->execute(array($target, $targetHash, $sourceHash, $this->uid));
504
+		$result = (bool) $query->execute(array($target, $targetHash, $sourceHash, $this->uid));
505 505
 
506 506
 		return $result;
507 507
 	}
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 
523 523
 		$share = $getShare->fetch();
524 524
 		$getShare->closeCursor();
525
-		if ($result && (bool)$share !== false && (int)$share['share_type'] === Share::SHARE_TYPE_USER) {
525
+		if ($result && (bool) $share !== false && (int) $share['share_type'] === Share::SHARE_TYPE_USER) {
526 526
 			try {
527 527
 				$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
528 528
 			} catch (\Exception $e) {
@@ -534,16 +534,16 @@  discard block
 block discarded – undo
534 534
 			DELETE FROM `*PREFIX*share_external`
535 535
 			WHERE `id` = ?
536 536
 			');
537
-			$result = (bool)$query->execute(array((int)$share['id']));
538
-		} else if ($result && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) {
537
+			$result = (bool) $query->execute(array((int) $share['id']));
538
+		} else if ($result && (int) $share['share_type'] === Share::SHARE_TYPE_GROUP) {
539 539
 			$query = $this->connection->prepare('
540 540
 				UPDATE `*PREFIX*share_external`
541 541
 				SET `accepted` = ?
542 542
 				WHERE `id` = ?');
543
-			$result = (bool)$query->execute(array(0, (int)$share['id']));
543
+			$result = (bool) $query->execute(array(0, (int) $share['id']));
544 544
 		}
545 545
 
546
-		if($result) {
546
+		if ($result) {
547 547
 			$this->removeReShares($id);
548 548
 		}
549 549
 
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 
565 565
 
566 566
 		$query->delete('federated_reshares')
567
-			->where($query->expr()->in('share_id', $query->createFunction('(' . $select . ')')));
567
+			->where($query->expr()->in('share_id', $query->createFunction('('.$select.')')));
568 568
 		$query->execute();
569 569
 
570 570
 		$deleteReShares = $this->connection->getQueryBuilder();
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 
589 589
 		if ($result) {
590 590
 			$shares = $getShare->fetchAll();
591
-			foreach($shares as $share) {
591
+			foreach ($shares as $share) {
592 592
 				$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
593 593
 			}
594 594
 		}
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 			DELETE FROM `*PREFIX*share_external`
598 598
 			WHERE `user` = ?
599 599
 		');
600
-		return (bool)$query->execute(array($uid));
600
+		return (bool) $query->execute(array($uid));
601 601
 	}
602 602
 
603 603
 	/**
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 		$query = 'SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`
638 638
 		          FROM `*PREFIX*share_external` 
639 639
 				  WHERE (`user` = ? OR `user` IN (?))';
640
-		$parameters = [$this->uid, implode(',',$userGroups)];
640
+		$parameters = [$this->uid, implode(',', $userGroups)];
641 641
 		if (!is_null($accepted)) {
642 642
 			$query .= ' AND `accepted` = ?';
643 643
 			$parameters[] = (int) $accepted;
Please login to merge, or discard this patch.