Code Duplication    Length = 7-7 lines in 3 locations

lib/private/Share/Share.php 3 locations

@@ 652-658 (lines=7) @@
649
			}
650
			if ($shareWithinGroupOnly) {
651
				$inGroup = \array_intersect(self::getGroupsForUser($uidOwner), self::getGroupsForUser($shareWith));
652
				if (empty($inGroup)) {
653
					$message = 'Sharing %s failed, because the user '
654
						.'%s is not a member of any groups that %s is a member of';
655
					$message_t = $l->t('Sharing %s failed, because the user %s is not a member of any groups that %s is a member of', [$itemName, $shareWith, $uidOwner]);
656
					\OCP\Util::writeLog('OCP\Share', \sprintf($message, $itemName, $shareWith, $uidOwner), \OCP\Util::DEBUG);
657
					throw new \Exception($message_t);
658
				}
659
			}
660
			// Check if the item source is already shared with the user, either from the same owner or a different user
661
			if ($checkExists = self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups,
@@ 692-698 (lines=7) @@
689
				\OCP\Util::writeLog('OCP\Share', \sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
690
				throw new \Exception($message_t);
691
			}
692
			if ($shareWithMembershipGroupOnly && !\OC::$server->getGroupManager()->inGroup($uidOwner, $shareWith)) {
693
				$message = 'Sharing %s failed, because '
694
					.'%s is not a member of the group %s';
695
				$message_t = $l->t('Sharing %s failed, because %s is not a member of the group %s', [$itemSourceName, $uidOwner, $shareWith]);
696
				\OCP\Util::writeLog('OCP\Share', \sprintf($message, $itemSourceName, $uidOwner, $shareWith), \OCP\Util::DEBUG);
697
				throw new \Exception($message_t);
698
			}
699
			// Check if the item source is already shared with the group, either from the same owner or a different user
700
			// The check for each user in the group is done inside the put() function
701
			if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_GROUP, $shareWith,
@@ 2222-2228 (lines=7) @@
2219
			$result['suggestedFileTarget'] = null;
2220
			$result['itemSource'] = $itemSource;
2221
			$result['expirationDate'] = $expirationDate;
2222
			if (!$backend->isValidSource($itemSource, $uidOwner)) {
2223
				$message = 'Sharing %s failed, because the sharing backend for '
2224
					.'%s could not find its source';
2225
				$message_t = $l->t('Sharing %s failed, because the sharing backend for %s could not find its source', [$itemSource, $itemType]);
2226
				\OCP\Util::writeLog('OCP\Share', \sprintf($message, $itemSource, $itemType), \OCP\Util::DEBUG);
2227
				throw new \Exception($message_t);
2228
			}
2229
			$result['filePath'] = null;
2230
			$result['fileSource'] = null;
2231
		}