|
|
|
|
@ -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'];
|
|
|
|
|
|