Code Duplication    Length = 12-12 lines in 2 locations

lib/private/share/share.php 2 locations

@@ 626-637 (lines=12) @@
623
				}
624
			}
625
			// Check if the item source is already shared with the user, either from the same owner or a different user
626
			if ($checkExists = self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups,
627
				$shareWith, null, self::FORMAT_NONE, null, 1, true, true)) {
628
				// Only allow the same share to occur again if it is the same
629
				// owner and is not a user share, this use case is for increasing
630
				// permissions for a specific user
631
				if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
632
					$message = 'Sharing %s failed, because this item is already shared with %s';
633
					$message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith));
634
					\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OC_Log::ERROR);
635
					throw new \Exception($message_t);
636
				}
637
			}
638
		} else if ($shareType === self::SHARE_TYPE_GROUP) {
639
			if (!\OC_Group::groupExists($shareWith)) {
640
				$message = 'Sharing %s failed, because the group %s does not exist';
@@ 654-665 (lines=12) @@
651
			}
652
			// Check if the item source is already shared with the group, either from the same owner or a different user
653
			// The check for each user in the group is done inside the put() function
654
			if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_GROUP, $shareWith,
655
				null, self::FORMAT_NONE, null, 1, true, true)) {
656
				// Only allow the same share to occur again if it is the same
657
				// owner and is not a group share, this use case is for increasing
658
				// permissions for a specific user
659
				if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
660
					$message = 'Sharing %s failed, because this item is already shared with %s';
661
					$message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith));
662
					\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OC_Log::ERROR);
663
					throw new \Exception($message_t);
664
				}
665
			}
666
			// Convert share with into an array with the keys group and users
667
			$group = $shareWith;
668
			$shareWith = array();