diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-03 14:03:04 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-03 14:03:04 -0400 |
commit | 96dea9507aab6189e4b0c7a50558a4d74bd37d8e (patch) | |
tree | fd3aa434b0ddc5f7a1f9781dff396ed932402a7d /lib | |
parent | 5e8ef331904d09bc02da101de807b7f7f2ceae65 (diff) | |
download | nextcloud-server-96dea9507aab6189e4b0c7a50558a4d74bd37d8e.tar.gz nextcloud-server-96dea9507aab6189e4b0c7a50558a4d74bd37d8e.zip |
Return false for single item checks and an empty array for multiple item checks
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/share.php | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/public/share.php b/lib/public/share.php index c0e80510628..641d1640019 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -156,7 +156,7 @@ class Share { return false; } } - if ($checkShareExists = self::getItems($itemType, $item, self::SHARE_TYPE_USER, $shareWith, $uidOwner, self::FORMAT_NONE, 1) && !empty($checkShareExists)) { + if (self::getItems($itemType, $item, self::SHARE_TYPE_USER, $shareWith, $uidOwner, self::FORMAT_NONE, 1)) { \OC_Log::write('OCP\Share', 'Sharing '.$item.' failed, because this item is already shared with the user '.$shareWith, \OC_Log::ERROR); return false; } @@ -169,7 +169,7 @@ 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 ($checkShareExists = self::getItems($itemType, $item, self::SHARE_TYPE_GROUP, $shareWith, $uidOwner, self::FORMAT_NONE, 1) && !empty($checkShareExists)) { + if (self::getItems($itemType, $item, self::SHARE_TYPE_GROUP, $shareWith, $uidOwner, self::FORMAT_NONE, 1)) { \OC_Log::write('OCP\Share', 'Sharing '.$item.' failed, because this item is already shared with the group '.$shareWith, \OC_Log::ERROR); return false; } @@ -221,7 +221,7 @@ class Share { * @return Returns true on success or false on failure */ public static function unshare($itemType, $item, $shareType, $shareWith) { - if ($item = self::getItems($itemType, $item, $shareType, $shareWith, \OC_User::getUser(), self::FORMAT_NONE, 1) && !empty($item)) { + if ($item = self::getItems($itemType, $item, $shareType, $shareWith, \OC_User::getUser(), self::FORMAT_NONE, 1)) { self::delete($item['id']); return true; } @@ -270,7 +270,7 @@ class Share { if ($backend = self::getBackend($itemType)) { $uidSharedWith = \OC_User::getUser(); // TODO Check permissions for setting target? - if ($item = self::getItems($itemType, $oldTarget, self::SHARE_TYPE_USER, $uidSharedWith, null, self::FORMAT_NONE, 1) && !empty($item)) { + if ($item = self::getItems($itemType, $oldTarget, self::SHARE_TYPE_USER, $uidSharedWith, null, self::FORMAT_NONE, 1)) { // Check if this is a group share if ($item['uid_shared_with'] == null) { // A new entry needs to be created exclusively for the user @@ -308,7 +308,7 @@ class Share { * @return Returns true on success or false on failure */ public static function setPermissions($itemType, $item, $shareType, $shareWith, $permissions) { - if ($item = self::getItems($itemType, $item, $shareType, $shareWith, \OC_User::getUser(), self::FORMAT_NONE, 1) && !empty($item)) { + if ($item = self::getItems($itemType, $item, $shareType, $shareWith, \OC_User::getUser(), self::FORMAT_NONE, 1)) { // Check if this item is a reshare and verify that the permissions granted don't exceed the parent shared item if (isset($item['parent'])) { $query = \OC_DB::prepare('SELECT permissions FROM *PREFIX*share WHERE id = ? LIMIT 1'); @@ -521,7 +521,7 @@ class Share { } else { return $backend->formatItems($items, $format); } - } else if ($limit == 1) { + } else if ($limit == 1 || (isset($uidOwner) && isset($item))) { return false; } } @@ -556,7 +556,7 @@ class Share { } if ($backend = self::getBackend($itemType)) { // Check if this is a reshare - if ($checkReshare = self::getItemSharedWith($itemType, $item) && !empty($checkReshare)) { + if ($checkReshare = self::getItemSharedWith($itemType, $item)) { // TODO Check if resharing is allowed // TODO Don't check if inside folder $parent = $checkReshare['id']; |