Only allow users to edit documents if part of edit groups

If edit group setting is not set in Collabora Online settings,
then allow all users.
pull/1/head
Pranav Kant 8 years ago
parent 1174105402
commit c24c5a0439

@ -269,7 +269,8 @@ class DocumentController extends Controller {
'uploadMaxFilesize' => $maxUploadFilesize,
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'),
'wopi_url' => $webSocket,
'wopi_url' => $webSocket,
'edit_groups' => $this->appConfig->getAppValue('edit_groups')
]);
$policy = new ContentSecurityPolicy();

@ -33,13 +33,21 @@ var documentsSettings = {
},
initEditGroups: function() {
var groups = $('#edit_group_select').val().split('|');
if (groups.length) {
var groups = $('#edit_group_select').val();
if (groups !== '') {
OC.Settings.setupGroupsSelect($('#edit_group_select'));
$('.edit-groups-enable').attr('checked', 'checked');
} else {
$('.edit-groups-enable').attr('checked', null);
}
$.get(
OC.generateUrl('/settings/users/users'),
{ limit: 1, pattern: 'admin' },
function(result) {
console.log(result);
}
);
},
initialize: function() {

@ -17,6 +17,31 @@ $.widget('oc.documentGrid', {
jQuery.when(this._load(fileId))
.then(function(){
that._render();
if (!documentsMain.isGuest) {
$.ajax({
url: OC.generateUrl('/settings/users/users'),
type: 'get',
data: { limit: 1, pattern: OC.currentUser },
async: false,
success: function(result) {
var editGroups = $('#edit_groups').val();
documentsMain.canEdit = (editGroups === '');
if (!documentsMain.canEdit && result.length >= 1) {
for (var idx in result[0].groups) {
if (editGroups.indexOf(result[0].groups[idx]) !== -1) {
documentsMain.canEdit = true;
break;
}
}
}
},
error: function() {
console.log('Error fetching information about current user.');
}
});
}
documentsMain.renderComplete = true;
});
},
@ -188,6 +213,7 @@ var documentsMain = {
fileName: null,
baseName: null,
canShare : false,
canEdit: false,
loadError : false,
loadErrorMessage : '',
loadErrorHint : '',
@ -455,7 +481,7 @@ var documentsMain = {
"&lang=" + $('li[data-id='+ documentsMain.fileId +']>a').attr('lolang') +
"&closebutton=1" +
"&revisionhistory=1";
if (action === "view") {
if (!documentsMain.canEdit || action === "view") {
urlsrc += "&permission=readonly";
}

@ -52,3 +52,4 @@ script('files', 'jquery.fileupload');
<input type="hidden" id="previews_enabled" value="<?php p($_['enable_previews']) ?>" />
<?php endif; ?>
<input type="hidden" name="allowShareWithLink" id="allowShareWithLink" value="<?php p($_['allowShareWithLink']) ?>" />
<input type="hidden" name="edit_groups" id="edit_groups" value="<?php p($_['edit_groups']) ?>" />

Loading…
Cancel
Save