]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't allow user to delete, rename and re-share the "Shared" directory
authorBjoern Schiessle <schiessle@owncloud.com>
Mon, 4 Jun 2012 08:42:09 +0000 (10:42 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Mon, 4 Jun 2012 08:42:09 +0000 (10:42 +0200)
apps/files/js/fileactions.js
apps/files/js/files.js
lib/files.php

index 19978b61a7d17ed4b0960ea0e707896f5bfc799b..0c672cd6708c28dbe7bcb0df87444030815c2b0a 100644 (file)
@@ -51,7 +51,7 @@ FileActions={
                var actions=this.get(mime,type);
                return actions[name];
        },
-       display:function(parent){
+       display:function(parent, filename, type){
                FileActions.currentFile=parent;
                $('#fileList span.fileactions, #fileList td.date a.action').remove();
                var actions=FileActions.get(FileActions.getCurrentMimeType(),FileActions.getCurrentType());
@@ -62,6 +62,8 @@ FileActions={
                parent.children('a.name').append('<span class="fileactions" />');
                var defaultAction=FileActions.getDefault(FileActions.getCurrentMimeType(),FileActions.getCurrentType());
                for(name in actions){
+                       // no rename and share action for the 'Shared' dir
+                       if((name=='Rename' || name =='Share') && type=='dir' && filename=='Shared') { continue; }
                        if((name=='Download' || actions[name]!=defaultAction) && name!='Delete'){
                                var img=FileActions.icons[name];
                                if(img.call){
@@ -84,7 +86,7 @@ FileActions={
                                parent.find('a.name>span.fileactions').append(element);
                        }
                }
-               if(actions['Delete']){
+               if(actions['Delete'] && (type!='dir' || filename != 'Shared')){ // no delete action for the 'Shared' dir
                        var img=FileActions.icons['Delete'];
                        if(img.call){
                                img=img(file);
index 7d9c53eaa8e638a407b9b8c19c58ab1b7f41a182..7cd0f388a3cb19e9f1d16c31a44a6a32b9848a65 100644 (file)
@@ -56,7 +56,7 @@ $(document).ready(function() {
 
        // Sets the file-action buttons behaviour :
        $('tr').live('mouseenter',function(event) {
-               FileActions.display($(this).children('td.filename'));
+               FileActions.display($(this).children('td.filename'), $(this).attr('data-file'), $(this).attr('data-type'));
        });
        $('tr').live('mouseleave',function(event) {
                FileActions.hide();
index 79d214665dea9aa57c7f46ea1b9cfd04b7c0c834..1e88a7b608d7ca9ad6f88ceff3f831eccba17ab7 100644 (file)
@@ -224,7 +224,7 @@ class OC_Files {
        * @param file $name
        */
        public static function delete($dir,$file){
-               if(OC_User::isLoggedIn()){
+               if(OC_User::isLoggedIn() && ($dir!= '' || $file != 'Shared')) {
                        $file=$dir.'/'.$file;
                        return OC_Filesystem::unlink($file);
                }