]> source.dussan.org Git - nextcloud-server.git/commitdiff
Support for unshare from self, with a bunch of temporary fixes to overcome configurat...
authorMichael Gapczynski <mtgap@owncloud.com>
Fri, 7 Sep 2012 04:01:52 +0000 (00:01 -0400)
committerMichael Gapczynski <mtgap@owncloud.com>
Fri, 7 Sep 2012 04:02:22 +0000 (00:02 -0400)
apps/files/js/fileactions.js
apps/files/js/filelist.js
apps/files/templates/index.php
apps/files_sharing/lib/share/file.php
apps/files_sharing/lib/sharedstorage.php
lib/public/share.php

index b7670fa22595cb2758e170a5ae6842d4fb1163f0..1403d345e8a41f381bd61cc5d2e70f5e47182a8e 100644 (file)
@@ -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+'"/>'));
index b777785f4d93f7bf8b00b7698ce7538d20874fa1..7ebfd4b68bbe5ea83ce183beee0e2ffeac6b9522 100644 (file)
@@ -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){
index ec9e80e955eba1d52881765101de1d515541ddf1..911a312fb9aa6badb59e9f076501e7a0661b3316 100644 (file)
                        <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>
index 82744924be30a2e3003843df7fe4c44db20a850d..c8821ee0fe855d8eb3e71d54c598c2b872ab89bf 100644 (file)
@@ -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;
index 6a2905b52c91265a4342797631ed90feddac0db3..4530ce87777d5555f4e44f54fb629f8f5600cf2a 100644 (file)
@@ -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;
        }
index 7b6b78561d4b55a84e8be8265e1a46a9c9af3143..cf61681424fdf00c105ef781b6ebff918a3ca7e5 100644 (file)
@@ -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` = ?';
                                }