From 73d726d1b26f011e77761934bcf7f5ce8db86241 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Fri, 7 Sep 2012 00:01:52 -0400 Subject: [PATCH] Support for unshare from self, with a bunch of temporary fixes to overcome configuration problems with file actions --- apps/files/js/fileactions.js | 7 ++++++- apps/files/js/filelist.js | 7 ++++++- apps/files/templates/index.php | 7 ++++++- apps/files_sharing/lib/share/file.php | 2 ++ apps/files_sharing/lib/sharedstorage.php | 18 ++++++++++++++---- lib/public/share.php | 3 ++- 6 files changed, 36 insertions(+), 8 deletions(-) diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index b7670fa2259..1403d345e8a 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -103,7 +103,12 @@ var FileActions={ if(img.call){ img=img(file); } - var html='t('Delete')?> <?php echo $l->t('Delete')?>" /> + + + t('Unshare')?> <?php echo $l->t('Unshare')?>" /> + + t('Delete')?> <?php echo $l->t('Delete')?>" /> + diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php index 82744924be3..c8821ee0fe8 100644 --- a/apps/files_sharing/lib/share/file.php +++ b/apps/files_sharing/lib/share/file.php @@ -91,6 +91,8 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent { // Remove Create permission if type is file $file['permissions'] &= ~OCP\Share::PERMISSION_CREATE; } + // NOTE: Temporary fix to allow unsharing of files in root of Shared directory + $file['permissions'] |= OCP\Share::PERMISSION_DELETE; $files[] = $file; } return $files; diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 6a2905b52c9..4530ce87777 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -209,7 +209,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { public function isDeletable($path) { if ($path == '') { - return false; + return true; } return ($this->getPermissions($path) & OCP\Share::PERMISSION_DELETE); } @@ -306,9 +306,19 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { public function unlink($path) { // Delete the file if DELETE permission is granted - if (($source = $this->getSourcePath($path)) && $this->isDeletable($path)) { - $storage = OC_Filesystem::getStorage($source); - return $storage->unlink($this->getInternalPath($source)); + if ($source = $this->getSourcePath($path)) { + if ($this->isDeletable($path)) { + $storage = OC_Filesystem::getStorage($source); + return $storage->unlink($this->getInternalPath($source)); + } else if (dirname($path) == '/' || dirname($path) == '.') { + // Unshare the file from the user if in the root of the Shared folder + if ($this->is_dir($path)) { + $itemType = 'folder'; + } else { + $itemType = 'file'; + } + return OCP\Share::unshareFromSelf($itemType, $path); + } } return false; } diff --git a/lib/public/share.php b/lib/public/share.php index 7b6b78561d4..cf61681424f 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -340,7 +340,7 @@ class Share { // TODO } // Delete - return self::delete($item['id'], true); + return self::delete($item['id']); } return false; } @@ -564,6 +564,7 @@ class Share { } else { if ($itemType == 'file' || $itemType == 'folder') { $where .= ' `file_target` = ?'; + $item = \OC_Filesystem::normalizePath($item); } else { $where .= ' `item_target` = ?'; } -- 2.39.5