summaryrefslogtreecommitdiffstats
path: root/lib/public/share.php
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-06-30 18:00:01 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-06-30 18:00:01 -0400
commit75c111a33b69d4da2f0540d17e425e9f6e7f5df6 (patch)
treed3881c4f9e113e16c27c720b5a789c844c6669b6 /lib/public/share.php
parent2418d9a1a9a1a36ed8e929ba4cb62b31ce849f8e (diff)
downloadnextcloud-server-75c111a33b69d4da2f0540d17e425e9f6e7f5df6.tar.gz
nextcloud-server-75c111a33b69d4da2f0540d17e425e9f6e7f5df6.zip
Have getItems() return an empty array instead of false, so apps only need to do an array_merge()
Diffstat (limited to 'lib/public/share.php')
-rw-r--r--lib/public/share.php14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/public/share.php b/lib/public/share.php
index 99dae542eb9..e214fb46dd6 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -145,7 +145,7 @@ class Share {
return false;
}
}
- if (self::getItems($itemType, $item, self::SHARE_TYPE_USER, $shareWith, $uidOwner, self::FORMAT_NONE, 1)) {
+ if ($item = self::getItems($itemType, $item, self::SHARE_TYPE_USER, $shareWith, $uidOwner, self::FORMAT_NONE, 1) && !empty($item)) {
\OC_Log::write('OCP\Share', 'Sharing '.$item.' failed, because this item is already shared with the user '.$shareWith, \OC_Log::ERROR);
return false;
}
@@ -158,7 +158,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 (self::getItems($itemType, $item, self::SHARE_TYPE_GROUP, $shareWith, $uidOwner, self::FORMAT_NONE, 1)) {
+ if ($item = self::getItems($itemType, $item, self::SHARE_TYPE_GROUP, $shareWith, $uidOwner, self::FORMAT_NONE, 1) && !empty($item)) {
\OC_Log::write('OCP\Share', 'Sharing '.$item.' failed, because this item is already shared with the group '.$shareWith, \OC_Log::ERROR);
return false;
}
@@ -210,7 +210,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)) {
+ if ($item = self::getItems($itemType, $item, $shareType, $shareWith, \OC_User::getUser(), self::FORMAT_NONE, 1) && !empty($item)) {
self::delete($item['id']);
return true;
}
@@ -259,7 +259,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)) {
+ if ($item = self::getItems($itemType, $oldTarget, self::SHARE_TYPE_USER, $uidSharedWith, null, self::FORMAT_NONE, 1) && !empty($item)) {
// Check if this is a group share
if ($item['uid_shared_with'] == null) {
// A new entry needs to be created exclusively for the user
@@ -297,7 +297,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)) {
+ if ($item = self::getItems($itemType, $item, $shareType, $shareWith, \OC_User::getUser(), self::FORMAT_NONE, 1) && !empty($item)) {
// 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');
@@ -491,7 +491,7 @@ class Share {
}
}
}
- return false;
+ return array();
}
/**
@@ -522,7 +522,7 @@ class Share {
}
if ($backend = self::getBackend($itemType)) {
// Check if this is a reshare
- if ($checkReshare = self::getItemSharedWith($itemType, $item)) {
+ if ($checkReshare = self::getItemSharedWith($itemType, $item) && !empty($checkReshare)) {
// TODO Check if resharing is allowed
// TODO Don't check if inside folder
$parent = $checkReshare['id'];