Simplify edit group checking algorithm
Rather than making a server call, which seems to be not working always anyways, use a foolproof method for this.
This commit is contained in:
parent
de62725ed2
commit
1ad1f667ee
@ -292,6 +292,11 @@ class DocumentController extends Controller {
|
|||||||
return $this->responseError($this->l10n->t('Collabora Online: Invalid URL "%s".', array($wopiRemote)), $this->l10n->t('Please ask your administrator to check the Collabora Online server setting.'));
|
return $this->responseError($this->l10n->t('Collabora Online: Invalid URL "%s".', array($wopiRemote)), $this->l10n->t('Please ask your administrator to check the Collabora Online server setting.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user = \OC::$server->getUserSession()->getUser();
|
||||||
|
$usergroups = array_filter(\OC::$server->getGroupManager()->getUserGroupIds($user));
|
||||||
|
$usergroups = join('|', $usergroups);
|
||||||
|
\OC::$server->getLogger()->debug('User is in groups: {groups}', [ 'app' => $this->appName, 'groups' => $usergroups ]);
|
||||||
|
|
||||||
\OC::$server->getNavigationManager()->setActiveEntry( 'richdocuments_index' );
|
\OC::$server->getNavigationManager()->setActiveEntry( 'richdocuments_index' );
|
||||||
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
|
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
|
||||||
$response = new TemplateResponse('richdocuments', 'documents', [
|
$response = new TemplateResponse('richdocuments', 'documents', [
|
||||||
@ -301,7 +306,8 @@ class DocumentController extends Controller {
|
|||||||
'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'),
|
'edit_groups' => $this->appConfig->getAppValue('edit_groups'),
|
||||||
'doc_format' => $this->appConfig->getAppValue('doc_format')
|
'doc_format' => $this->appConfig->getAppValue('doc_format'),
|
||||||
|
'usergroups' => $usergroups
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$policy = new ContentSecurityPolicy();
|
$policy = new ContentSecurityPolicy();
|
||||||
|
@ -19,27 +19,17 @@ $.widget('oc.documentGrid', {
|
|||||||
that._render();
|
that._render();
|
||||||
|
|
||||||
if (!documentsMain.isGuest) {
|
if (!documentsMain.isGuest) {
|
||||||
$.ajax({
|
var editGroups = $('#edit_groups').val().split('|');
|
||||||
url: OC.generateUrl('/settings/users/users'),
|
var usergroups = $('#usergroups').val().split('|');
|
||||||
type: 'get',
|
documentsMain.canEdit = (editGroups.length === 0);
|
||||||
data: { limit: 1, pattern: OC.currentUser },
|
if (!documentsMain.canEdit && usergroups.length >= 1) {
|
||||||
async: false,
|
for (var idx in usergroups) {
|
||||||
success: function(result) {
|
if (editGroups.indexOf(usergroups[idx]) !== -1) {
|
||||||
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;
|
documentsMain.canEdit = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
error: function() {
|
|
||||||
console.log('Error fetching information about current user.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
documentsMain.renderComplete = true;
|
documentsMain.renderComplete = true;
|
||||||
|
@ -53,3 +53,4 @@ script('files', 'jquery.fileupload');
|
|||||||
<?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']) ?>" />
|
<input type="hidden" name="edit_groups" id="edit_groups" value="<?php p($_['edit_groups']) ?>" />
|
||||||
|
<input type="hidden" name="usergroups" id="usergroups" value="<?php p($_['usergroups']) ?>" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user