diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-09-04 16:22:01 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-09-04 16:22:01 +0200 |
commit | f100ef0fc6acddc6f5c9d38affa34bb243dc8eeb (patch) | |
tree | a1f2301253f5a0f9cb7f1b36fd0038b7bdb10558 | |
parent | e9e42fff61a922f11a3b1014d810562537950b6a (diff) | |
download | nextcloud-server-f100ef0fc6acddc6f5c9d38affa34bb243dc8eeb.tar.gz nextcloud-server-f100ef0fc6acddc6f5c9d38affa34bb243dc8eeb.zip |
Prevent sharing twice with user when already a group
-rw-r--r-- | lib/private/share/share.php | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php index d0c69badb46..3a4bd0b19dd 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -701,6 +701,18 @@ class Share extends Constants { throw new \Exception($message_t); } } + if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_USER, + $shareWith, null, self::FORMAT_NONE, null, 1, true, true)) { + // Only allow the same share to occur again if it is the same + // owner and is not a user share, this use case is for increasing + // permissions for a specific user + if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) { + $message = 'Sharing %s failed, because this item is already shared with user %s'; + $message_t = $l->t('Sharing %s failed, because this item is already shared with user %s', array($itemSourceName, $shareWith)); + \OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OC_Log::ERROR); + throw new \Exception($message_t); + } + } } else if ($shareType === self::SHARE_TYPE_GROUP) { if (!\OC_Group::groupExists($shareWith)) { $message = 'Sharing %s failed, because the group %s does not exist'; |