Code Duplication    Length = 12-12 lines in 2 locations

lib/private/Share/Share.php 2 locations

@@ 791-802 (lines=12) @@
788
				}
789
			}
790
			// Check if the item source is already shared with the user, either from the same owner or a different user
791
			if ($checkExists = self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups,
792
				$shareWith, null, self::FORMAT_NONE, null, 1, true, true)) {
793
				// Only allow the same share to occur again if it is the same
794
				// owner and is not a user share, this use case is for increasing
795
				// permissions for a specific user
796
				if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
797
					$message = 'Sharing %s failed, because this item is already shared with %s';
798
					$message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith));
799
					\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
800
					throw new \Exception($message_t);
801
				}
802
			}
803
			if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_USER,
804
				$shareWith, null, self::FORMAT_NONE, null, 1, true, true)) {
805
				// Only allow the same share to occur again if it is the same
@@ 803-814 (lines=12) @@
800
					throw new \Exception($message_t);
801
				}
802
			}
803
			if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_USER,
804
				$shareWith, null, self::FORMAT_NONE, null, 1, true, true)) {
805
				// Only allow the same share to occur again if it is the same
806
				// owner and is not a user share, this use case is for increasing
807
				// permissions for a specific user
808
				if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
809
					$message = 'Sharing %s failed, because this item is already shared with user %s';
810
					$message_t = $l->t('Sharing %s failed, because this item is already shared with user %s', array($itemSourceName, $shareWith));
811
					\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::ERROR);
812
					throw new \Exception($message_t);
813
				}
814
			}
815
		} else if ($shareType === self::SHARE_TYPE_GROUP) {
816
			if (!\OC::$server->getGroupManager()->groupExists($shareWith)) {
817
				$message = 'Sharing %s failed, because the group %s does not exist';