diff --git a/controller/documentcontroller.php b/controller/documentcontroller.php
index 9e310ec3..f4303475 100644
--- a/controller/documentcontroller.php
+++ b/controller/documentcontroller.php
@@ -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();
diff --git a/js/admin.js b/js/admin.js
index c54e5761..627c2615 100644
--- a/js/admin.js
+++ b/js/admin.js
@@ -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() {
diff --git a/js/documents.js b/js/documents.js
index 105926ba..7179389c 100644
--- a/js/documents.js
+++ b/js/documents.js
@@ -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";
}
diff --git a/templates/documents.php b/templates/documents.php
index 2019fbae..75594590 100644
--- a/templates/documents.php
+++ b/templates/documents.php
@@ -52,3 +52,4 @@ script('files', 'jquery.fileupload');
+