Restore 'Enable edit for specific groups' feature, fixes #66
This commit is contained in:
parent
935674b862
commit
aa4df2e800
44
js/admin.js
44
js/admin.js
@ -15,6 +15,17 @@ var documentsSettings = {
|
||||
);
|
||||
},
|
||||
|
||||
saveGroups: function(groups) {
|
||||
var data = {
|
||||
'edit_groups': groups
|
||||
};
|
||||
|
||||
$.post(
|
||||
OC.filePath('richdocuments', 'ajax', 'admin.php'),
|
||||
data
|
||||
);
|
||||
},
|
||||
|
||||
saveDocFormat: function(format) {
|
||||
$.post(
|
||||
OC.filePath('richdocuments', 'ajax', 'admin.php'),
|
||||
@ -27,7 +38,19 @@ var documentsSettings = {
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
documentsSettings.initEditGroups();
|
||||
|
||||
$('#wopi_apply').on('click', documentsSettings.save);
|
||||
|
||||
$(document).on('change', '.doc-format-ooxml', function() {
|
||||
@ -35,6 +58,27 @@ var documentsSettings = {
|
||||
documentsSettings.saveDocFormat(ooxml ? 'ooxml' : 'odf');
|
||||
});
|
||||
|
||||
$(document).on('change', '#edit_group_select', function() {
|
||||
var element = $(this).parent().find('input.edit-groups-enable');
|
||||
var groups = $(this).val();
|
||||
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();
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -52,17 +52,20 @@ class SettingsController extends Controller{
|
||||
*/
|
||||
public function getSettings() {
|
||||
return new JSONResponse([
|
||||
'doc_format' => $this->appConfig->getAppValue('doc_format'),
|
||||
'wopi_url' => $this->appConfig->getAppValue('wopi_url'),
|
||||
'edit_groups' => $this->appConfig->getAppValue('edit_groups'),
|
||||
'doc_format' => $this->appConfig->getAppValue('doc_format'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $wopi_url
|
||||
* @param string $edit_groups
|
||||
* @param string $doc_format
|
||||
* @return JSONResponse
|
||||
*/
|
||||
public function setSettings($wopi_url,
|
||||
$edit_groups,
|
||||
$doc_format){
|
||||
$message = $this->l10n->t('Saved');
|
||||
|
||||
@ -75,6 +78,10 @@ class SettingsController extends Controller{
|
||||
}
|
||||
}
|
||||
|
||||
if ($edit_groups !== null){
|
||||
$this->appConfig->setAppValue('edit_groups', $edit_groups);
|
||||
}
|
||||
|
||||
if ($doc_format !== null) {
|
||||
$this->appConfig->setAppValue('doc_format', $doc_format);
|
||||
}
|
||||
|
@ -49,8 +49,6 @@ class Admin implements ISettings {
|
||||
'wopi_url' => $this->config->getAppValue('richdocuments', 'wopi_url'),
|
||||
'edit_groups' => $this->config->getAppValue('richdocuments', 'edit_groups'),
|
||||
'doc_format' => $this->config->getAppValue('richdocuments', 'doc_format'),
|
||||
'test_wopi_url' => $this->config->getAppValue('richdocuments', 'test_wopi_url'),
|
||||
'test_server_groups' => $this->config->getAppValue('richdocuments', 'test_server_groups')
|
||||
],
|
||||
'blank'
|
||||
);
|
||||
|
@ -50,11 +50,13 @@ class TokenManager {
|
||||
IManager $shareManager,
|
||||
IURLGenerator $urlGenerator,
|
||||
Parser $wopiParser,
|
||||
AppConfig $appConfig,
|
||||
$UserId) {
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->shareManager = $shareManager;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->wopiParser = $wopiParser;
|
||||
$this->appConfig = $appConfig;
|
||||
$this->userId = $UserId;
|
||||
}
|
||||
|
||||
@ -79,6 +81,22 @@ class TokenManager {
|
||||
/** @var File $file */
|
||||
$rootFolder = $this->rootFolder->getUserFolder($this->userId);
|
||||
$updatable = $rootFolder->isUpdateable();
|
||||
// Check if the editor (user who is accessing) is in editable group
|
||||
// UserCanWrite only if
|
||||
// 1. No edit groups are set or
|
||||
// 2. if they are set, it is in one of the edit groups
|
||||
$editorUid = \OC::$server->getUserSession()->getUser()->getUID();
|
||||
$editGroups = array_filter(explode('|', $this->appConfig->getAppValue('edit_groups')));
|
||||
if ($updatable && count($editGroups) > 0) {
|
||||
$updatable = false;
|
||||
foreach($editGroups as $editGroup) {
|
||||
$editorGroup = \OC::$server->getGroupManager()->get($editGroup);
|
||||
if ($editorGroup !== null && sizeof($editorGroup->searchUsers($editorUid)) > 0) {
|
||||
$updatable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@ -103,4 +121,4 @@ class TokenManager {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,10 @@ script('richdocuments', 'admin');
|
||||
<br/><button type="button" id="wopi_apply"><?php p($l->t('Apply')) ?></button>
|
||||
<span id="documents-admin-msg" class="msg"></span>
|
||||
<br/>
|
||||
|
||||
<input type="checkbox" class="edit-groups-enable" id="edit_groups_enable-richdocuments" />
|
||||
<label for="edit_groups_enable-richdocuments"><?php p($l->t('Enable edit for specific groups')) ?></label>
|
||||
<input type="hidden" id="edit_group_select" value="<?php p($_['edit_groups'])?>" title="<?php p($l->t('All')); ?>" style="width: 200px">
|
||||
<br/>
|
||||
<input type="checkbox" class="doc-format-ooxml" id="doc_format_ooxml_enable-richdocuments" <?php p($_['doc_format'] === 'ooxml' ? 'checked' : '') ?> />
|
||||
<label for="doc_format_ooxml_enable-richdocuments"><?php p($l->t('Use OOXML by default for new files')) ?></label>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user