Merge pull request #120 from pranavk/editgroups
Edit groups functionality
This commit is contained in:
commit
f63aaeb631
@ -269,7 +269,8 @@ class DocumentController extends Controller {
|
|||||||
'uploadMaxFilesize' => $maxUploadFilesize,
|
'uploadMaxFilesize' => $maxUploadFilesize,
|
||||||
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
|
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
|
||||||
'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'),
|
'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();
|
$policy = new ContentSecurityPolicy();
|
||||||
|
@ -63,16 +63,21 @@ class SettingsController extends Controller{
|
|||||||
'admin',
|
'admin',
|
||||||
[
|
[
|
||||||
'wopi_url' => $this->appConfig->getAppValue('wopi_url'),
|
'wopi_url' => $this->appConfig->getAppValue('wopi_url'),
|
||||||
|
'edit_groups' => $this->appConfig->getAppValue('edit_groups')
|
||||||
],
|
],
|
||||||
'blank'
|
'blank'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSettings($wopi_url){
|
public function setSettings($wopi_url, $edit_groups){
|
||||||
if (!is_null($wopi_url)){
|
if (!is_null($wopi_url)){
|
||||||
$this->appConfig->setAppValue('wopi_url', $wopi_url);
|
$this->appConfig->setAppValue('wopi_url', $wopi_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_null($edit_groups)){
|
||||||
|
$this->appConfig->setAppValue('edit_groups', $edit_groups);
|
||||||
|
}
|
||||||
|
|
||||||
$richMemCache = \OC::$server->getMemCacheFactory()->create('richdocuments');
|
$richMemCache = \OC::$server->getMemCacheFactory()->create('richdocuments');
|
||||||
$richMemCache->clear('discovery.xml');
|
$richMemCache->clear('discovery.xml');
|
||||||
|
|
||||||
|
99
js/admin.js
99
js/admin.js
@ -1,27 +1,88 @@
|
|||||||
/*global OC, $ */
|
/*global OC, $ */
|
||||||
|
|
||||||
$(document).ready(function(){
|
var documentsSettings = {
|
||||||
|
save : function() {
|
||||||
|
$('#wopi_apply').attr('disabled', true);
|
||||||
|
var data = {
|
||||||
|
wopi_url : $('#wopi_url').val()
|
||||||
|
};
|
||||||
|
|
||||||
var documentsSettings = {
|
OC.msg.startAction('#documents-admin-msg', t('richdocuments', 'Saving...'));
|
||||||
save : function() {
|
$.post(
|
||||||
$('#wopi_apply').attr('disabled', true);
|
OC.filePath('richdocuments', 'ajax', 'admin.php'),
|
||||||
var data = {
|
data,
|
||||||
wopi_url : $('#wopi_url').val()
|
documentsSettings.afterSave
|
||||||
};
|
);
|
||||||
|
},
|
||||||
|
|
||||||
OC.msg.startAction('#documents-admin-msg', t('richdocuments', 'Saving...'));
|
saveGroups: function(groups) {
|
||||||
$.post(
|
var data = {
|
||||||
OC.filePath('richdocuments', 'ajax', 'admin.php'),
|
'edit_groups': groups.join('|')
|
||||||
data,
|
};
|
||||||
documentsSettings.afterSave
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
afterSave : function(response){
|
console.log('posting to setSettings');
|
||||||
$('#wopi_apply').attr('disabled', false);
|
$.post(
|
||||||
OC.msg.finishedAction('#documents-admin-msg', response);
|
OC.filePath('richdocuments', 'ajax', 'admin.php'),
|
||||||
|
data
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
afterSave : function(response){
|
||||||
|
$('#wopi_apply').attr('disabled', false);
|
||||||
|
OC.msg.finishedAction('#documents-admin-msg', response);
|
||||||
|
},
|
||||||
|
|
||||||
|
initEditGroups: function() {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
$('#wopi_apply').on('click', documentsSettings.save);
|
$.get(
|
||||||
|
OC.generateUrl('/settings/users/users'),
|
||||||
|
{ limit: 1, pattern: 'admin' },
|
||||||
|
function(result) {
|
||||||
|
console.log(result);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
initialize: function() {
|
||||||
|
$('#wopi_apply').on('click', documentsSettings.save);
|
||||||
|
documentsSettings.initEditGroups();
|
||||||
|
|
||||||
|
$(document).on('change', '#edit_group_select', function() {
|
||||||
|
var element = $(this).parent().find('input.edit-groups-enable');
|
||||||
|
var groups = $(this).val();
|
||||||
|
if (groups && groups !== '') {
|
||||||
|
groups = groups.split('|');
|
||||||
|
} else {
|
||||||
|
groups = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
documentsSettings.saveGroups(groups);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('change', '.edit-groups-enable', function() {
|
||||||
|
var $select = $(this).parent().find('#edit_group_select');
|
||||||
|
$select.val('');
|
||||||
|
|
||||||
|
if (this.checked) {
|
||||||
|
OC.Settings.setupGroupsSelect($select, {
|
||||||
|
placeholder: t('core', 'All')
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$select.select2('destroy');
|
||||||
|
}
|
||||||
|
|
||||||
|
$select.change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
documentsSettings.initialize();
|
||||||
});
|
});
|
||||||
|
@ -17,6 +17,31 @@ $.widget('oc.documentGrid', {
|
|||||||
jQuery.when(this._load(fileId))
|
jQuery.when(this._load(fileId))
|
||||||
.then(function(){
|
.then(function(){
|
||||||
that._render();
|
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;
|
documentsMain.renderComplete = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -188,6 +213,7 @@ var documentsMain = {
|
|||||||
fileName: null,
|
fileName: null,
|
||||||
baseName: null,
|
baseName: null,
|
||||||
canShare : false,
|
canShare : false,
|
||||||
|
canEdit: false,
|
||||||
loadError : false,
|
loadError : false,
|
||||||
loadErrorMessage : '',
|
loadErrorMessage : '',
|
||||||
loadErrorHint : '',
|
loadErrorHint : '',
|
||||||
@ -455,7 +481,7 @@ var documentsMain = {
|
|||||||
"&lang=" + $('li[data-id='+ documentsMain.fileId +']>a').attr('lolang') +
|
"&lang=" + $('li[data-id='+ documentsMain.fileId +']>a').attr('lolang') +
|
||||||
"&closebutton=1" +
|
"&closebutton=1" +
|
||||||
"&revisionhistory=1";
|
"&revisionhistory=1";
|
||||||
if (action === "view") {
|
if (!documentsMain.canEdit || action === "view") {
|
||||||
urlsrc += "&permission=readonly";
|
urlsrc += "&permission=readonly";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,4 +8,9 @@ script('richdocuments', 'admin');
|
|||||||
<br /><em><?php p($l->t('URL (and port) of the Collabora Online server that provides the editing functionality as a WOPI client.')) ?></em>
|
<br /><em><?php p($l->t('URL (and port) of the Collabora Online server that provides the editing functionality as a WOPI client.')) ?></em>
|
||||||
<br /><button type="button" id="wopi_apply"><?php p($l->t('Apply')) ?></button>
|
<br /><button type="button" id="wopi_apply"><?php p($l->t('Apply')) ?></button>
|
||||||
<span id="documents-admin-msg" class="msg"></span>
|
<span id="documents-admin-msg" class="msg"></span>
|
||||||
|
<br/>
|
||||||
|
<input type="checkbox" class="edit-groups-enable" id="edit_groups_enable-richdocuments" data-appid="richdocuments" />
|
||||||
|
<label for="edit_groups_enable-richdocuments"><?php p($l->t('Enable edit for specific groups')) ?></label>
|
||||||
|
<br/>
|
||||||
|
<input type="hidden" id="edit_group_select" value="<?php p($_['edit_groups'])?>" title="<?php p($l->t('All')); ?>" style="width: 200px">
|
||||||
</div>
|
</div>
|
||||||
|
@ -52,3 +52,4 @@ script('files', 'jquery.fileupload');
|
|||||||
<input type="hidden" id="previews_enabled" value="<?php p($_['enable_previews']) ?>" />
|
<input type="hidden" id="previews_enabled" value="<?php p($_['enable_previews']) ?>" />
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<input type="hidden" name="allowShareWithLink" id="allowShareWithLink" value="<?php p($_['allowShareWithLink']) ?>" />
|
<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…
x
Reference in New Issue
Block a user