Deprecate oc_isadmin and move OC.isUserAdmin() to the bundle
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
a7a35d32fd
commit
d68be1ae4d
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,3 @@
|
||||||
/* global oc_isadmin */
|
|
||||||
|
|
||||||
var oc_debug;
|
var oc_debug;
|
||||||
var oc_webroot;
|
var oc_webroot;
|
||||||
|
|
||||||
|
@ -610,16 +608,6 @@ Object.assign(window.OC, {
|
||||||
return $('html').prop('lang');
|
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
|
* Warn users that the connection to the server was lost temporarily
|
||||||
*
|
*
|
||||||
|
|
|
@ -86,7 +86,6 @@ window.firstDay = 0;
|
||||||
// setup dummy webroots
|
// setup dummy webroots
|
||||||
/* jshint camelcase: false */
|
/* jshint camelcase: false */
|
||||||
window.oc_debug = true;
|
window.oc_debug = true;
|
||||||
window.oc_isadmin = false;
|
|
||||||
// FIXME: oc_webroot is supposed to be only the path!!!
|
// FIXME: oc_webroot is supposed to be only the path!!!
|
||||||
window.oc_webroot = location.href + '/';
|
window.oc_webroot = location.href + '/';
|
||||||
window.oc_appswebroots = {
|
window.oc_appswebroots = {
|
||||||
|
|
|
@ -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
|
|
@ -26,6 +26,7 @@ import Config from './config'
|
||||||
import ContactsMenu from './contactsmenu'
|
import ContactsMenu from './contactsmenu'
|
||||||
import Dialogs from './dialogs'
|
import Dialogs from './dialogs'
|
||||||
import EventSource from './eventsource'
|
import EventSource from './eventsource'
|
||||||
|
import {isUserAdmin} from './admin'
|
||||||
import L10N from './l10n'
|
import L10N from './l10n'
|
||||||
import {
|
import {
|
||||||
generateUrl,
|
generateUrl,
|
||||||
|
@ -52,6 +53,7 @@ export default {
|
||||||
config: Config,
|
config: Config,
|
||||||
dialogs: Dialogs,
|
dialogs: Dialogs,
|
||||||
EventSource,
|
EventSource,
|
||||||
|
isUserAdmin,
|
||||||
L10N,
|
L10N,
|
||||||
msg,
|
msg,
|
||||||
Notification,
|
Notification,
|
||||||
|
|
|
@ -108,6 +108,7 @@ window['moment'] = moment
|
||||||
|
|
||||||
window['OC'] = OC
|
window['OC'] = OC
|
||||||
setDeprecatedProp('oc_config', OC.config, 'use OC.config instead')
|
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')
|
setDeprecatedProp('OCDialogs', OC.dialogs, 'use OC.dialogs instead')
|
||||||
window['OCP'] = OCP
|
window['OCP'] = OCP
|
||||||
window['OCA'] = OCA
|
window['OCA'] = OCA
|
||||||
|
|
|
@ -167,7 +167,7 @@ class JSConfigHelper {
|
||||||
|
|
||||||
$array = [
|
$array = [
|
||||||
"oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false',
|
"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',
|
"backendAllowsPasswordConfirmation" => $userBackendAllowsPasswordConfirmation ? 'true' : 'false',
|
||||||
"oc_dataURL" => is_string($dataLocation) ? "\"".$dataLocation."\"" : 'false',
|
"oc_dataURL" => is_string($dataLocation) ? "\"".$dataLocation."\"" : 'false',
|
||||||
"oc_webroot" => "\"".\OC::$WEBROOT."\"",
|
"oc_webroot" => "\"".\OC::$WEBROOT."\"",
|
||||||
|
|
Loading…
Reference in New Issue