diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 343da21741..390bf4e057 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -178,6 +178,13 @@ window.FileList = { if (type === 'dir') { mime = mime || 'httpd/unix-directory'; } + + // user should always be able to rename a share mount point + var allowRename = 0; + if (fileData.isShareMountPoint) { + allowRename = OC.PERMISSION_UPDATE; + } + //containing tr var tr = $('').attr({ "data-id" : fileData.id, @@ -187,7 +194,7 @@ window.FileList = { "data-mime": mime, "data-mtime": mtime, "data-etag": fileData.etag, - "data-permissions": fileData.permissions || this.getDirectoryPermissions() + "data-permissions": fileData.permissions | allowRename || this.getDirectoryPermissions() }); if (type === 'dir') { @@ -283,6 +290,10 @@ window.FileList = { mime = fileData.mimetype, permissions = parseInt(fileData.permissions, 10) || 0; + if (fileData.isShareMountPoint) { + permissions = permissions | OC.PERMISSION_UPDATE; + } + if (type === 'dir') { mime = mime || 'httpd/unix-directory'; } diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php index 88a5ffcfb6..0ae87d12fb 100644 --- a/apps/files/lib/helper.php +++ b/apps/files/lib/helper.php @@ -96,6 +96,9 @@ class Helper if (isset($i['displayname_owner'])) { $entry['shareOwner'] = $i['displayname_owner']; } + if (isset($i['is_share_mount_point'])) { + $entry['isShareMountPoint'] = $i['is_share_mount_point']; + } return $entry; } diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php index 4a2f0ff08b..67a0410ef7 100644 --- a/apps/files_sharing/lib/cache.php +++ b/apps/files_sharing/lib/cache.php @@ -91,6 +91,9 @@ class Shared_Cache extends Cache { $data = $cache->get($this->files[$file]); $data['displayname_owner'] = \OC_User::getDisplayName($this->storage->getSharedFrom()); $data['path'] = $path; + if ($file === '') { + $data['is_share_mount_point'] = true; + } return $data; } } else { @@ -123,6 +126,7 @@ class Shared_Cache extends Cache { } if (isset($mountPoint)) { $data['path'] = 'files/' . $mountPoint; + $data['is_share_mount_point'] = true; } return $data; } diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php index d2fa425b22..2956f60838 100644 --- a/lib/private/connector/sabre/objecttree.php +++ b/lib/private/connector/sabre/objecttree.php @@ -87,9 +87,15 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { list($sourceDir,) = \Sabre_DAV_URLUtil::splitPath($sourcePath); list($destinationDir,) = \Sabre_DAV_URLUtil::splitPath($destinationPath); + $isShareMountPoint = false; + list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath( '/' . \OCP\User::getUser() . '/files/' . $sourcePath); + if ($storage instanceof \OC\Files\Storage\Shared && !$internalPath) { + $isShareMountPoint = true; + } + // check update privileges $fs = $this->getFileView(); - if (!$fs->isUpdatable($sourcePath)) { + if (!$fs->isUpdatable($sourcePath) && !$isShareMountPoint) { throw new \Sabre_DAV_Exception_Forbidden(); } if ($sourceDir !== $destinationDir) {