Disable delete and upload buttons on readonly folders
This commit is contained in:
parent
4b727c45cd
commit
423979d63f
1 changed files with 27 additions and 24 deletions
|
@ -754,23 +754,20 @@ kolab_files_list_select = function(list)
|
||||||
// if (list.selection.length && list.selection.length != list.rowcount)
|
// if (list.selection.length && list.selection.length != list.rowcount)
|
||||||
// rcmail.select_all_mode = false;
|
// rcmail.select_all_mode = false;
|
||||||
|
|
||||||
// enable files-
|
|
||||||
if (selected == 1) {
|
if (selected == 1) {
|
||||||
// get file mimetype
|
// get file mimetype
|
||||||
var type = $('tr.selected', list.list).data('type');
|
var elem = $('tr.selected', list.list),
|
||||||
|
type = elem.data('type'),
|
||||||
|
file = elem.data('file');
|
||||||
|
|
||||||
rcmail.env.viewer = file_api.file_type_supported(type);
|
rcmail.env.viewer = file_api.file_type_supported(type);
|
||||||
|
|
||||||
|
if (!file_api.is_writable(file.replace(/\/[^/]+$/, '')))
|
||||||
|
rcmail.enable_command('files-delete', false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rcmail.env.viewer = 0;
|
rcmail.env.viewer = 0;
|
||||||
/*
|
|
||||||
) {
|
|
||||||
// caps = this.browser_capabilities().join();
|
|
||||||
href = '?' + $.param({_task: 'files', _action: 'open', file: file, viewer: viewer == 2 ? 1 : 0});
|
|
||||||
var win = window.open(href, rcmail.html_identifier('rcubefile'+file));
|
|
||||||
if (win)
|
|
||||||
setTimeout(function() { win.focus(); }, 10);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
rcmail.enable_command('files-open', rcmail.env.viewer);
|
rcmail.enable_command('files-open', rcmail.env.viewer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -878,7 +875,7 @@ kolab_files_drag_drop_init = function(container)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$(document.body).bind('dragover dragleave drop', function(e) {
|
$(document.body).bind('dragover dragleave drop', function(e) {
|
||||||
if (!kolab_files_current_folder_is_writable())
|
if (!file_api.is_writable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -898,21 +895,11 @@ kolab_files_drag_drop_init = function(container)
|
||||||
}, false);
|
}, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
function kolab_files_current_folder_is_writable()
|
|
||||||
{
|
|
||||||
if (!file_api.env.folder)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (file_api.env.folders[file_api.env.folder].readonly)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// handler for drag/drop on element
|
// handler for drag/drop on element
|
||||||
kolab_files_drag_hover = function(e)
|
kolab_files_drag_hover = function(e)
|
||||||
{
|
{
|
||||||
if (!kolab_files_current_folder_is_writable())
|
if (!file_api.is_writable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -1201,6 +1188,21 @@ function kolab_files_ui()
|
||||||
rcmail.http_error(request, status, err);
|
rcmail.http_error(request, status, err);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// check if specified/current folder/view is writable
|
||||||
|
this.is_writable = function(folder)
|
||||||
|
{
|
||||||
|
if (!folder)
|
||||||
|
folder = this.env.folder;
|
||||||
|
|
||||||
|
if (!folder)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (this.env.folders[folder].readonly)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
// folders list request
|
// folders list request
|
||||||
this.folder_list = function(params)
|
this.folder_list = function(params)
|
||||||
{
|
{
|
||||||
|
@ -1333,7 +1335,8 @@ function kolab_files_ui()
|
||||||
this.env.collection = collection;
|
this.env.collection = collection;
|
||||||
|
|
||||||
rcmail.enable_command('files-list', true);
|
rcmail.enable_command('files-list', true);
|
||||||
rcmail.enable_command('files-folder-delete', 'folder-rename', 'files-upload', !is_collection);
|
rcmail.enable_command('files-folder-delete', 'folder-rename', !is_collection);
|
||||||
|
rcmail.enable_command('files-upload', !is_collection && this.is_writable());
|
||||||
rcmail.command('files-list', is_collection ? {collection: collection} : {folder: folder});
|
rcmail.command('files-list', is_collection ? {collection: collection} : {folder: folder});
|
||||||
|
|
||||||
this.quota();
|
this.quota();
|
||||||
|
|
Loading…
Add table
Reference in a new issue