Code Duplication    Length = 6-6 lines in 5 locations

lib/private/share/share.php 5 locations

@@ 638-643 (lines=6) @@
635
				throw new \Exception($message_t);
636
			}
637
			// verify that the user has share permission
638
			if (!\OC\Files\Filesystem::isSharable($path) || \OCP\Util::isSharingDisabledForUser()) {
639
				$message = 'You are not allowed to share %s';
640
				$message_t = $l->t('You are not allowed to share %s', [$path]);
641
				\OCP\Util::writeLog('OCP\Share', sprintf($message, $path), \OCP\Util::DEBUG);
642
				throw new \Exception($message_t);
643
			}
644
		}
645
646
		//verify that we don't share a folder which already contains a share mount point
@@ 689-694 (lines=6) @@
686
				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG);
687
				throw new \Exception($message_t);
688
			}
689
			if (!\OC_User::userExists($shareWith)) {
690
				$message = 'Sharing %s failed, because the user %s does not exist';
691
				$message_t = $l->t('Sharing %s failed, because the user %s does not exist', array($itemSourceName, $shareWith));
692
				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
693
				throw new \Exception($message_t);
694
			}
695
			if ($shareWithinGroupOnly) {
696
				$inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith));
697
				if (empty($inGroup)) {
@@ 731-736 (lines=6) @@
728
				}
729
			}
730
		} else if ($shareType === self::SHARE_TYPE_GROUP) {
731
			if (!\OC_Group::groupExists($shareWith)) {
732
				$message = 'Sharing %s failed, because the group %s does not exist';
733
				$message_t = $l->t('Sharing %s failed, because the group %s does not exist', array($itemSourceName, $shareWith));
734
				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
735
				throw new \Exception($message_t);
736
			}
737
			if ($shareWithinGroupOnly && !\OC_Group::inGroup($uidOwner, $shareWith)) {
738
				$message = 'Sharing %s failed, because '
739
					.'%s is not a member of the group %s';
@@ 856-861 (lines=6) @@
853
			list($user, $remote) = Helper::splitUserRemote($shareWith);
854
			$currentServer = self::removeProtocolFromUrl(\OC::$server->getURLGenerator()->getAbsoluteURL('/'));
855
			$currentUser = \OC::$server->getUserSession()->getUser()->getUID();
856
			if (Helper::isSameUserOnSameServer($user, $remote, $currentUser, $currentServer)) {
857
				$message = 'Not allowed to create a federated share with the same user.';
858
				$message_t = $l->t('Not allowed to create a federated share with the same user');
859
				\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::DEBUG);
860
				throw new \Exception($message_t);
861
			}
862
863
			$token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER .
864
				\OCP\Security\ISecureRandom::CHAR_DIGITS);
@@ 1446-1451 (lines=6) @@
1443
			$class = self::$backendTypes[$itemType]['class'];
1444
			if (class_exists($class)) {
1445
				self::$backends[$itemType] = new $class;
1446
				if (!(self::$backends[$itemType] instanceof \OCP\Share_Backend)) {
1447
					$message = 'Sharing backend %s must implement the interface OCP\Share_Backend';
1448
					$message_t = $l->t('Sharing backend %s must implement the interface OCP\Share_Backend', array($class));
1449
					\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), \OCP\Util::ERROR);
1450
					throw new \Exception($message_t);
1451
				}
1452
				return self::$backends[$itemType];
1453
			} else {
1454
				$message = 'Sharing backend %s not found';