Completed
Pull Request — master (#6437)
by Lukas
12:11
created
lib/private/Share20/DefaultShareProvider.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 			->orderBy('id');
288 288
 
289 289
 		$cursor = $qb->execute();
290
-		while($data = $cursor->fetch()) {
290
+		while ($data = $cursor->fetch()) {
291 291
 			$children[] = $this->createShare($data);
292 292
 		}
293 293
 		$cursor->closeCursor();
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 			$user = $this->userManager->get($recipient);
333 333
 
334 334
 			if (is_null($group)) {
335
-				throw new ProviderException('Group "' . $share->getSharedWith() . '" does not exist');
335
+				throw new ProviderException('Group "'.$share->getSharedWith().'" does not exist');
336 336
 			}
337 337
 
338 338
 			if (!$group->inGroup($user)) {
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 			);
493 493
 		}
494 494
 
495
-		$qb->innerJoin('s', 'filecache' ,'f', $qb->expr()->eq('s.file_source', 'f.fileid'));
495
+		$qb->innerJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid'));
496 496
 		$qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId())));
497 497
 
498 498
 		$qb->orderBy('id');
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 
549 549
 		$cursor = $qb->execute();
550 550
 		$shares = [];
551
-		while($data = $cursor->fetch()) {
551
+		while ($data = $cursor->fetch()) {
552 552
 			$shares[] = $this->createShare($data);
553 553
 		}
554 554
 		$cursor->closeCursor();
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 			->execute();
628 628
 
629 629
 		$shares = [];
630
-		while($data = $cursor->fetch()) {
630
+		while ($data = $cursor->fetch()) {
631 631
 			$shares[] = $this->createShare($data);
632 632
 		}
633 633
 		$cursor->closeCursor();
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 
699 699
 			$cursor = $qb->execute();
700 700
 
701
-			while($data = $cursor->fetch()) {
701
+			while ($data = $cursor->fetch()) {
702 702
 				if ($this->isAccessibleResult($data)) {
703 703
 					$shares[] = $this->createShare($data);
704 704
 				}
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 			$shares2 = [];
714 714
 
715 715
 			$start = 0;
716
-			while(true) {
716
+			while (true) {
717 717
 				$groups = array_slice($allGroups, $start, 100);
718 718
 				$start += 100;
719 719
 
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 					));
759 759
 
760 760
 				$cursor = $qb->execute();
761
-				while($data = $cursor->fetch()) {
761
+				while ($data = $cursor->fetch()) {
762 762
 					if ($offset > 0) {
763 763
 						$offset--;
764 764
 						continue;
@@ -827,14 +827,14 @@  discard block
 block discarded – undo
827 827
 	 */
828 828
 	private function createShare($data) {
829 829
 		$share = new Share($this->rootFolder, $this->userManager);
830
-		$share->setId((int)$data['id'])
831
-			->setShareType((int)$data['share_type'])
832
-			->setPermissions((int)$data['permissions'])
830
+		$share->setId((int) $data['id'])
831
+			->setShareType((int) $data['share_type'])
832
+			->setPermissions((int) $data['permissions'])
833 833
 			->setTarget($data['file_target'])
834 834
 			->setMailSend(true);
835 835
 
836 836
 		$shareTime = new \DateTime();
837
-		$shareTime->setTimestamp((int)$data['stime']);
837
+		$shareTime->setTimestamp((int) $data['stime']);
838 838
 		$share->setShareTime($shareTime);
839 839
 
840 840
 		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 		$share->setSharedBy($data['uid_initiator']);
850 850
 		$share->setShareOwner($data['uid_owner']);
851 851
 
852
-		$share->setNodeId((int)$data['file_source']);
852
+		$share->setNodeId((int) $data['file_source']);
853 853
 		$share->setNodeType($data['item_type']);
854 854
 
855 855
 		if ($data['expiration'] !== null) {
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
 		$result = [];
880 880
 
881 881
 		$start = 0;
882
-		while(true) {
882
+		while (true) {
883 883
 			/** @var Share[] $shareSlice */
884 884
 			$shareSlice = array_slice($shares, $start, 100);
885 885
 			$start += 100;
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 			$shareMap = [];
895 895
 
896 896
 			foreach ($shareSlice as $share) {
897
-				$ids[] = (int)$share->getId();
897
+				$ids[] = (int) $share->getId();
898 898
 				$shareMap[$share->getId()] = $share;
899 899
 			}
900 900
 
@@ -911,8 +911,8 @@  discard block
 block discarded – undo
911 911
 
912 912
 			$stmt = $query->execute();
913 913
 
914
-			while($data = $stmt->fetch()) {
915
-				$shareMap[$data['parent']]->setPermissions((int)$data['permissions']);
914
+			while ($data = $stmt->fetch()) {
915
+				$shareMap[$data['parent']]->setPermissions((int) $data['permissions']);
916 916
 				$shareMap[$data['parent']]->setTarget($data['file_target']);
917 917
 			}
918 918
 
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 
1010 1010
 		$cursor = $qb->execute();
1011 1011
 		$ids = [];
1012
-		while($row = $cursor->fetch()) {
1013
-			$ids[] = (int)$row['id'];
1012
+		while ($row = $cursor->fetch()) {
1013
+			$ids[] = (int) $row['id'];
1014 1014
 		}
1015 1015
 		$cursor->closeCursor();
1016 1016
 
@@ -1052,8 +1052,8 @@  discard block
 block discarded – undo
1052 1052
 
1053 1053
 		$cursor = $qb->execute();
1054 1054
 		$ids = [];
1055
-		while($row = $cursor->fetch()) {
1056
-			$ids[] = (int)$row['id'];
1055
+		while ($row = $cursor->fetch()) {
1056
+			$ids[] = (int) $row['id'];
1057 1057
 		}
1058 1058
 		$cursor->closeCursor();
1059 1059
 
@@ -1107,8 +1107,8 @@  discard block
 block discarded – undo
1107 1107
 
1108 1108
 		$users = [];
1109 1109
 		$link = false;
1110
-		while($row = $cursor->fetch()) {
1111
-			$type = (int)$row['share_type'];
1110
+		while ($row = $cursor->fetch()) {
1111
+			$type = (int) $row['share_type'];
1112 1112
 			if ($type === \OCP\Share::SHARE_TYPE_USER) {
1113 1113
 				$uid = $row['share_with'];
1114 1114
 				$users[$uid] = isset($users[$uid]) ? $users[$uid] : [];
Please login to merge, or discard this patch.
lib/private/Share20/Manager.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 
346 346
 		if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
347 347
 			$expirationDate = new \DateTime();
348
-			$expirationDate->setTime(0,0,0);
348
+			$expirationDate->setTime(0, 0, 0);
349 349
 			$expirationDate->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D'));
350 350
 		}
351 351
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 
358 358
 			$date = new \DateTime();
359 359
 			$date->setTime(0, 0, 0);
360
-			$date->add(new \DateInterval('P' . $this->shareApiLinkDefaultExpireDays() . 'D'));
360
+			$date->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D'));
361 361
 			if ($date < $expirationDate) {
362 362
 				$message = $this->l->t('Can’t set expiration date more than %s days in the future', [$this->shareApiLinkDefaultExpireDays()]);
363 363
 				throw new GenericShareException($message, $message, 404);
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 		 */
411 411
 		$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_USER);
412 412
 		$existingShares = $provider->getSharesByPath($share->getNode());
413
-		foreach($existingShares as $existingShare) {
413
+		foreach ($existingShares as $existingShare) {
414 414
 			// Ignore if it is the same share
415 415
 			try {
416 416
 				if ($existingShare->getFullId() === $share->getFullId()) {
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 		 */
468 468
 		$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP);
469 469
 		$existingShares = $provider->getSharesByPath($share->getNode());
470
-		foreach($existingShares as $existingShare) {
470
+		foreach ($existingShares as $existingShare) {
471 471
 			try {
472 472
 				if ($existingShare->getFullId() === $share->getFullId()) {
473 473
 					continue;
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 		// Make sure that we do not share a path that contains a shared mountpoint
537 537
 		if ($path instanceof \OCP\Files\Folder) {
538 538
 			$mounts = $this->mountManager->findIn($path->getPath());
539
-			foreach($mounts as $mount) {
539
+			foreach ($mounts as $mount) {
540 540
 				if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) {
541 541
 					throw new \InvalidArgumentException('Path contains files shared with you');
542 542
 				}
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		$storage = $share->getNode()->getStorage();
585 585
 		if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
586 586
 			$parent = $share->getNode()->getParent();
587
-			while($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
587
+			while ($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
588 588
 				$parent = $parent->getParent();
589 589
 			}
590 590
 			$share->setShareOwner($parent->getOwner()->getUID());
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 		}
638 638
 
639 639
 		// Generate the target
640
-		$target = $this->config->getSystemValue('share_folder', '/') .'/'. $share->getNode()->getName();
640
+		$target = $this->config->getSystemValue('share_folder', '/').'/'.$share->getNode()->getName();
641 641
 		$target = \OC\Files\Filesystem::normalizePath($target);
642 642
 		$share->setTarget($target);
643 643
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 
661 661
 		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
662 662
 			$mailSend = $share->getMailSend();
663
-			if($mailSend === true) {
663
+			if ($mailSend === true) {
664 664
 				$user = $this->userManager->get($share->getSharedWith());
665 665
 				if ($user !== null) {
666 666
 					$emailAddress = $user->getEMailAddress();
@@ -675,12 +675,12 @@  discard block
 block discarded – undo
675 675
 							$emailAddress,
676 676
 							$share->getExpirationDate()
677 677
 						);
678
-						$this->logger->debug('Send share notification to ' . $emailAddress . ' for share with ID ' . $share->getId(), ['app' => 'share']);
678
+						$this->logger->debug('Send share notification to '.$emailAddress.' for share with ID '.$share->getId(), ['app' => 'share']);
679 679
 					} else {
680
-						$this->logger->debug('Share notification not send to ' . $share->getSharedWith() . ' because email address is not set.', ['app' => 'share']);
680
+						$this->logger->debug('Share notification not send to '.$share->getSharedWith().' because email address is not set.', ['app' => 'share']);
681 681
 					}
682 682
 				} else {
683
-					$this->logger->debug('Share notification not send to ' . $share->getSharedWith() . ' because user could not be found.', ['app' => 'share']);
683
+					$this->logger->debug('Share notification not send to '.$share->getSharedWith().' because user could not be found.', ['app' => 'share']);
684 684
 				}
685 685
 			} else {
686 686
 				$this->logger->debug('Share notification not send because mailsend is false.', ['app' => 'share']);
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 		$text = $l->t('%s shared »%s« with you.', [$initiatorDisplayName, $filename]);
725 725
 
726 726
 		$emailTemplate->addBodyText(
727
-			$text . ' ' . $l->t('Click the button below to open it.'),
727
+			$text.' '.$l->t('Click the button below to open it.'),
728 728
 			$text
729 729
 		);
730 730
 		$emailTemplate->addBodyButton(
@@ -748,9 +748,9 @@  discard block
 block discarded – undo
748 748
 		// The "Reply-To" is set to the sharer if an mail address is configured
749 749
 		// also the default footer contains a "Do not reply" which needs to be adjusted.
750 750
 		$initiatorEmail = $initiatorUser->getEMailAddress();
751
-		if($initiatorEmail !== null) {
751
+		if ($initiatorEmail !== null) {
752 752
 			$message->setReplyTo([$initiatorEmail => $initiatorDisplayName]);
753
-			$emailTemplate->addFooter($instanceName . ' - ' . $this->defaults->getSlogan());
753
+			$emailTemplate->addFooter($instanceName.' - '.$this->defaults->getSlogan());
754 754
 		} else {
755 755
 			$emailTemplate->addFooter();
756 756
 		}
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 	 * @param string $recipientId
962 962
 	 */
963 963
 	public function deleteFromSelf(\OCP\Share\IShare $share, $recipientId) {
964
-		list($providerId, ) = $this->splitFullId($share->getFullId());
964
+		list($providerId,) = $this->splitFullId($share->getFullId());
965 965
 		$provider = $this->factory->getProvider($providerId);
966 966
 
967 967
 		$provider->deleteFromSelf($share, $recipientId);
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
985 985
 			$sharedWith = $this->groupManager->get($share->getSharedWith());
986 986
 			if (is_null($sharedWith)) {
987
-				throw new \InvalidArgumentException('Group "' . $share->getSharedWith() . '" does not exist');
987
+				throw new \InvalidArgumentException('Group "'.$share->getSharedWith().'" does not exist');
988 988
 			}
989 989
 			$recipient = $this->userManager->get($recipientId);
990 990
 			if (!$sharedWith->inGroup($recipient)) {
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 			}
993 993
 		}
994 994
 
995
-		list($providerId, ) = $this->splitFullId($share->getFullId());
995
+		list($providerId,) = $this->splitFullId($share->getFullId());
996 996
 		$provider = $this->factory->getProvider($providerId);
997 997
 
998 998
 		$provider->move($share, $recipientId);
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 
1040 1040
 		$shares2 = [];
1041 1041
 
1042
-		while(true) {
1042
+		while (true) {
1043 1043
 			$added = 0;
1044 1044
 			foreach ($shares as $share) {
1045 1045
 
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 	 *
1140 1140
 	 * @return Share[]
1141 1141
 	 */
1142
-	public function getSharesByPath(\OCP\Files\Node $path, $page=0, $perPage=50) {
1142
+	public function getSharesByPath(\OCP\Files\Node $path, $page = 0, $perPage = 50) {
1143 1143
 		return [];
1144 1144
 	}
1145 1145
 
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 	public function getShareByToken($token) {
1155 1155
 		$share = null;
1156 1156
 		try {
1157
-			if($this->shareApiAllowLinks()) {
1157
+			if ($this->shareApiAllowLinks()) {
1158 1158
 				$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK);
1159 1159
 				$share = $provider->getShareByToken($token);
1160 1160
 			}
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
 			}
1362 1362
 			$al['users'][$owner] = [
1363 1363
 				'node_id' => $path->getId(),
1364
-				'node_path' => '/' . $ownerPath,
1364
+				'node_path' => '/'.$ownerPath,
1365 1365
 			];
1366 1366
 		} else {
1367 1367
 			$al['users'][] = $owner;
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 	 * @return int
1456 1456
 	 */
1457 1457
 	public function shareApiLinkDefaultExpireDays() {
1458
-		return (int)$this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
1458
+		return (int) $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
1459 1459
 	}
1460 1460
 
1461 1461
 	/**
Please login to merge, or discard this patch.