Deprecate oc_isadmin and move OC.isUserAdmin() to the bundle

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2019-05-03 09:07:31 +02:00
parent a7a35d32fd
commit d68be1ae4d
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
8 changed files with 68 additions and 28 deletions

46
core/js/dist/main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,3 @@
/* global oc_isadmin */
var oc_debug;
var oc_webroot;
@ -610,16 +608,6 @@ Object.assign(window.OC, {
return $('html').prop('lang');
},
/**
* Returns whether the current user is an administrator
*
* @return {bool} true if the user is an admin, false otherwise
* @since 9.0.0
*/
isUserAdmin: function() {
return oc_isadmin;
},
/**
* Warn users that the connection to the server was lost temporarily
*

View File

@ -86,7 +86,6 @@ window.firstDay = 0;
// setup dummy webroots
/* jshint camelcase: false */
window.oc_debug = true;
window.oc_isadmin = false;
// FIXME: oc_webroot is supposed to be only the path!!!
window.oc_webroot = location.href + '/';
window.oc_appswebroots = {

30
core/src/OC/admin.js Normal file
View File

@ -0,0 +1,30 @@
/*
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const isAdmin = !!window._oc_isadmin
/**
* Returns whether the current user is an administrator
*
* @return {bool} true if the user is an admin, false otherwise
* @since 9.0.0
*/
export const isUserAdmin = () => isAdmin

View File

@ -26,6 +26,7 @@ import Config from './config'
import ContactsMenu from './contactsmenu'
import Dialogs from './dialogs'
import EventSource from './eventsource'
import {isUserAdmin} from './admin'
import L10N from './l10n'
import {
generateUrl,
@ -52,6 +53,7 @@ export default {
config: Config,
dialogs: Dialogs,
EventSource,
isUserAdmin,
L10N,
msg,
Notification,

View File

@ -108,6 +108,7 @@ window['moment'] = moment
window['OC'] = OC
setDeprecatedProp('oc_config', OC.config, 'use OC.config instead')
setDeprecatedProp('oc_isadmin', OC.isUserAdmin(), 'use OC.isUserAdmin() instead')
setDeprecatedProp('OCDialogs', OC.dialogs, 'use OC.dialogs instead')
window['OCP'] = OCP
window['OCA'] = OCA

View File

@ -167,7 +167,7 @@ class JSConfigHelper {
$array = [
"oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false',
"oc_isadmin" => $this->groupManager->isAdmin($uid) ? 'true' : 'false',
"_oc_isadmin" => $this->groupManager->isAdmin($uid) ? 'true' : 'false',
"backendAllowsPasswordConfirmation" => $userBackendAllowsPasswordConfirmation ? 'true' : 'false',
"oc_dataURL" => is_string($dataLocation) ? "\"".$dataLocation."\"" : 'false',
"oc_webroot" => "\"".\OC::$WEBROOT."\"",