Code Duplication    Length = 7-7 lines in 3 locations

lib/private/share/share.php 3 locations

@@ 697-703 (lines=7) @@
694
			}
695
			if ($shareWithinGroupOnly) {
696
				$inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith));
697
				if (empty($inGroup)) {
698
					$message = 'Sharing %s failed, because the user '
699
						.'%s is not a member of any groups that %s is a member of';
700
					$message_t = $l->t('Sharing %s failed, because the user %s is not a member of any groups that %s is a member of', array($itemName, $shareWith, $uidOwner));
701
					\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemName, $shareWith, $uidOwner), \OCP\Util::DEBUG);
702
					throw new \Exception($message_t);
703
				}
704
			}
705
			// Check if the item source is already shared with the user, either from the same owner or a different user
706
			if ($checkExists = self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups,
@@ 737-743 (lines=7) @@
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';
740
				$message_t = $l->t('Sharing %s failed, because %s is not a member of the group %s', array($itemSourceName, $uidOwner, $shareWith));
741
				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner, $shareWith), \OCP\Util::DEBUG);
742
				throw new \Exception($message_t);
743
			}
744
			// Check if the item source is already shared with the group, either from the same owner or a different user
745
			// The check for each user in the group is done inside the put() function
746
			if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_GROUP, $shareWith,
@@ 2293-2299 (lines=7) @@
2290
			$result['suggestedFileTarget'] = null;
2291
			$result['itemSource'] = $itemSource;
2292
			$result['expirationDate'] = $expirationDate;
2293
			if (!$backend->isValidSource($itemSource, $uidOwner)) {
2294
				$message = 'Sharing %s failed, because the sharing backend for '
2295
					.'%s could not find its source';
2296
				$message_t = $l->t('Sharing %s failed, because the sharing backend for %s could not find its source', array($itemSource, $itemType));
2297
				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource, $itemType), \OCP\Util::DEBUG);
2298
				throw new \Exception($message_t);
2299
			}
2300
			if ($backend instanceof \OCP\Share_Backend_File_Dependent) {
2301
				$result['filePath'] = $backend->getFilePath($itemSource, $uidOwner);
2302
				if ($itemType == 'file' || $itemType == 'folder') {