Prevent resharing in UI if share permission not granted

This commit is contained in:
Michael Gapczynski 2012-08-23 14:48:35 -04:00
parent 3148edbdef
commit cfec290ad9
2 changed files with 63 additions and 57 deletions

View File

@ -2,7 +2,7 @@ $(document).ready(function() {
if (typeof FileActions !== 'undefined') {
OC.Share.loadIcons('file');
FileActions.register('all', 'Share', FileActions.PERMISSION_SHARE, function(filename) {
FileActions.register('all', 'Share', FileActions.PERMISSION_READ, function(filename) {
// Return the correct sharing icon
if (scanFiles.scanning) { return; } // workaround to prevent additional http request block scanning feedback
if ($('#dir').val() == '/') {
@ -36,13 +36,13 @@ $(document).ready(function() {
} else {
var item = $('#dir').val() + '/' + filename;
}
if ($('tr').filterAttr('data-file', filename).data('type') == 'dir') {
var tr = $('tr').filterAttr('data-file', filename);
if ($(tr).data('type') == 'dir') {
var itemType = 'folder';
var possiblePermissions = OC.Share.PERMISSION_CREATE | OC.Share.PERMISSION_UPDATE | OC.Share.PERMISSION_DELETE | OC.Share.PERMISSION_SHARE;
} else {
var itemType = 'file';
var possiblePermissions = OC.Share.PERMISSION_UPDATE | OC.Share.PERMISSION_DELETE | OC.Share.PERMISSION_SHARE;
}
var possiblePermissions = $(tr).data('permissions');
var appendTo = $('tr').filterAttr('data-file', filename).find('td.filename');
// Check if drop down is already visible for a different file
if (OC.Share.droppedDown) {

View File

@ -86,6 +86,7 @@ OC.Share={
}
html += '<br />';
}
if (possiblePermissions & OC.Share.PERMISSION_SHARE) {
html += '<input id="shareWith" type="text" placeholder="Share with" style="width:90%;"/>';
html += '<ul id="shareWithList">';
html += '</ul>';
@ -111,9 +112,9 @@ OC.Share={
});
}
$('#shareWith').autocomplete({minLength: 2, source: function(search, response) {
// if (cache[search.term]) {
// response(cache[search.term]);
// } else {
// if (cache[search.term]) {
// response(cache[search.term]);
// } else {
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getShareWith', search: search.term, itemShares: OC.Share.itemShares }, function(result) {
if (result.status == 'success' && result.data.length > 0) {
response(result.data);
@ -127,7 +128,7 @@ OC.Share={
}
}
});
// }
// }
},
focus: function(event, focused) {
event.preventDefault();
@ -145,6 +146,11 @@ OC.Share={
return false;
}
});
} else {
html += '<input id="shareWith" type="text" placeholder="Resharing is not allowed" style="width:90%;" disabled="disabled"/>';
html += '</div>';
$(html).appendTo(appendTo);
}
$('#dropdown').show('blind', function() {
OC.Share.droppedDown = true;
});