diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-12 11:59:48 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-12 12:11:04 -0400 |
commit | 63b6f20e05391e65da1569ae5e897d1e279081f2 (patch) | |
tree | d2629f9ea0f018ae6ad38f4e807f86fb5012f2be | |
parent | ecae3ea43055055d39080a512f247f89be3c22df (diff) | |
download | nextcloud-server-63b6f20e05391e65da1569ae5e897d1e279081f2.tar.gz nextcloud-server-63b6f20e05391e65da1569ae5e897d1e279081f2.zip |
Move already shared with check out of user and group cases, and add check for already shared with inside a collection
-rw-r--r-- | lib/public/share.php | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/public/share.php b/lib/public/share.php index a3ed7846b54..3bf0a76a5d1 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -156,10 +156,6 @@ class Share { return false; } } - if (self::getItems($itemType, $item, self::SHARE_TYPE_USER, $shareWith, $uidOwner, self::FORMAT_NONE, null, 1)) { - \OC_Log::write('OCP\Share', 'Sharing '.$item.' failed, because this item is already shared with the user '.$shareWith, \OC_Log::ERROR); - return false; - } break; case self::SHARE_TYPE_GROUP: if (!\OC_Group::groupExists($shareWith)) { @@ -169,10 +165,6 @@ class Share { \OC_Log::write('OCP\Share', 'Sharing '.$item.' failed, because '.$uidOwner.' is not a member of the group '.$shareWith, \OC_Log::ERROR); return false; } - if (self::getItems($itemType, $item, self::SHARE_TYPE_GROUP, $shareWith, $uidOwner, self::FORMAT_NONE, null, 1)) { - \OC_Log::write('OCP\Share', 'Sharing '.$item.' failed, because this item is already shared with the group '.$shareWith, \OC_Log::ERROR); - return false; - } // Convert share with into an array with the keys group and users $group = $shareWith; $shareWith = array(); @@ -187,6 +179,21 @@ class Share { \OC_Log::write('OCP\Share', 'Share type '.$shareType.' is not valid for '.$item, \OC_Log::ERROR); return false; } + if (self::getItems($itemType, $item, $shareType, $shareWith, $uidOwner, self::FORMAT_NONE, null, 1)) { + \OC_Log::write('OCP\Share', 'Sharing '.$item.' failed, because this item is already shared with '.$shareWith, \OC_Log::ERROR); + return false; + } + if ($collectionTypes = self::getCollectionItemTypes($itemType)) { + foreach ($collectionTypes as $collectionType) { + $collections = self::getItems($collectionType, null, self::SHARE_TYPE_USER, $shareWith, $uidOwner); + if ($backend = self::getBackend($collectionType)) { + if ($backend->inCollection($collections, $item)) { + \OC_Log::write('OCP\Share', 'Sharing '.$item.' failed, because this item is already shared with '.$shareWith.' inside a collection', \OC_Log::ERROR); + return false; + } + } + } + } // If the item is a folder, scan through the folder looking for equivalent item types if ($itemType == 'folder') { $parentFolder = self::put('folder', $item, $shareType, $shareWith, $uidOwner, $permissions, true); |