diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-09-07 00:01:52 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-09-07 00:02:22 -0400 |
commit | 73d726d1b26f011e77761934bcf7f5ce8db86241 (patch) | |
tree | b95913dddcd74b71a97c20ea843d5a4ea23ded16 /apps | |
parent | 17dadd5c8a39f1903ffeec2c2c78e5e6cd145d9c (diff) | |
download | nextcloud-server-73d726d1b26f011e77761934bcf7f5ce8db86241.tar.gz nextcloud-server-73d726d1b26f011e77761934bcf7f5ce8db86241.zip |
Support for unshare from self, with a bunch of temporary fixes to overcome configuration problems with file actions
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/js/fileactions.js | 7 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 7 | ||||
-rw-r--r-- | apps/files/templates/index.php | 7 | ||||
-rw-r--r-- | apps/files_sharing/lib/share/file.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/sharedstorage.php | 18 |
5 files changed, 34 insertions, 7 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='<a href="#" original-title="' + t('files', 'Delete') + '" class="action delete" style="display:none" />'; + // NOTE: Temporary fix to allow unsharing of files in root of Shared folder + if ($('#dir').val() == '/Shared') { + var html = '<a href="#" original-title="' + t('files', 'Unshare') + '" class="action delete" style="display:none" />'; + } else { + var html='<a href="#" original-title="' + t('files', 'Delete') + '" class="action delete" style="display:none" />'; + } var element=$(html); if(img){ element.append($('<img src="'+img+'"/>')); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index b777785f4d9..7ebfd4b68bb 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -263,7 +263,12 @@ var FileList={ return; } FileList.prepareDeletion(files); - $('#notification').html(t('files', 'deleted')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>'); + // NOTE: Temporary fix to change the text to unshared for files in root of Shared folder + if ($('#dir').val() == '/Shared') { + $('#notification').html(t('files', 'unshared')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>'); + } else { + $('#notification').html(t('files', 'deleted')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>'); + } $('#notification').fadeIn(); }, finishDelete:function(ready,sync){ diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index ec9e80e955e..911a312fb9a 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -57,7 +57,12 @@ <th id="headerDate"> <span id="modified"><?php echo $l->t( 'Modified' ); ?></span> <?php if ($_['permissions'] & OCP\Share::PERMISSION_DELETE): ?> - <span class="selectedActions"><a href="" class="delete"><?php echo $l->t('Delete')?> <img class="svg" alt="<?php echo $l->t('Delete')?>" src="<?php echo OCP\image_path("core", "actions/delete.svg"); ?>" /></a></span> +<!-- NOTE: Temporary fix to allow unsharing of files in root of Shared folder --> + <?php if ($_['dir'] == '/Shared'): ?> + <span class="selectedActions"><a href="" class="delete"><?php echo $l->t('Unshare')?> <img class="svg" alt="<?php echo $l->t('Unshare')?>" src="<?php echo OCP\image_path("core", "actions/delete.svg"); ?>" /></a></span> + <?php else: ?> + <span class="selectedActions"><a href="" class="delete"><?php echo $l->t('Delete')?> <img class="svg" alt="<?php echo $l->t('Delete')?>" src="<?php echo OCP\image_path("core", "actions/delete.svg"); ?>" /></a></span> + <?php endif; ?> <?php endif; ?> </th> </tr> 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; } |