summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-10-10 23:00:46 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-10-10 23:00:46 +0200
commit7a30f465439f65a1bcec61cf61f0cf7cae6664d7 (patch)
treec768db36fc94a2873ff5754e642392a2f2f2d311 /lib/public
parentccf8df440504b02f5d1387b263b3f09daf09a2a2 (diff)
parent2c3674ea87c6303f8dc1345d056871ca3637b437 (diff)
downloadnextcloud-server-7a30f465439f65a1bcec61cf61f0cf7cae6664d7.tar.gz
nextcloud-server-7a30f465439f65a1bcec61cf61f0cf7cae6664d7.zip
Merge branch 'master' of github.com:owncloud/core into vcategories_db
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/share.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/public/share.php b/lib/public/share.php
index e0488b8faf6..1db3a0b2c1d 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -173,6 +173,7 @@ class Share {
*/
public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions) {
$uidOwner = \OC_User::getUser();
+ $sharingPolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
// Verify share type and sharing conditions are met
if ($shareType === self::SHARE_TYPE_USER) {
if ($shareWith == $uidOwner) {
@@ -185,7 +186,7 @@ class Share {
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
throw new \Exception($message);
}
- if (\OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global') == 'groups_only') {
+ if ($sharingPolicy == 'groups_only') {
$inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith));
if (empty($inGroup)) {
$message = 'Sharing '.$itemSource.' failed, because the user '.$shareWith.' is not a member of any groups that '.$uidOwner.' is a member of';
@@ -208,7 +209,7 @@ class Share {
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
throw new \Exception($message);
}
- if (!\OC_Group::inGroup($uidOwner, $shareWith)) {
+ if ($sharingPolicy == 'groups_only' && !\OC_Group::inGroup($uidOwner, $shareWith)) {
$message = 'Sharing '.$itemSource.' failed, because '.$uidOwner.' is not a member of the group '.$shareWith;
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
throw new \Exception($message);
@@ -645,7 +646,7 @@ class Share {
} else {
if ($fileDependent) {
if (($itemType == 'file' || $itemType == 'folder') && $format == \OC_Share_Backend_File::FORMAT_FILE_APP || $format == \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT) {
- $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `file_target`, `permissions`, `expiration`, `name`, `ctime`, `mtime`, `mimetype`, `size`, `encrypted`, `versioned`, `writable`';
+ $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `uid_owner`, `share_type`, `share_with`, `file_source`, `path`, `file_target`, `permissions`, `expiration`, `name`, `ctime`, `mtime`, `mimetype`, `size`, `encrypted`, `versioned`, `writable`';
} else {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`';
}
@@ -1015,8 +1016,14 @@ class Share {
continue;
}
}
- if ($item['uid_owner'] == $uidOwner && $item[$columnSource] == $itemSource) {
- return $target;
+ if ($item['uid_owner'] == $uidOwner) {
+ if ($itemType == 'file' || $itemType == 'folder') {
+ if ($item['file_source'] == \OC_FileCache::getId($itemSource)) {
+ return $target;
+ }
+ } else if ($item['item_source'] == $itemSource) {
+ return $target;
+ }
}
}
if (!isset($exclude)) {