diff --git a/core/js/dist/main.js b/core/js/dist/main.js index 625bbed4ebdccca3a8084788c05da760ca12c06b..51d1d10a490891bdd4f0a7925d1cc5019d7ce8b9 100644 Binary files a/core/js/dist/main.js and b/core/js/dist/main.js differ diff --git a/core/js/dist/main.js.map b/core/js/dist/main.js.map index 4ee00dfa8e049f214f5b9637fa7077aa8cec0972..ea01e00e325b8fbc0c64d055b3932e415ed65e00 100644 Binary files a/core/js/dist/main.js.map and b/core/js/dist/main.js.map differ diff --git a/core/js/js.js b/core/js/js.js index f32bd5545553c5671fc9c1fa56300e76c6199c25..e9e66fd63fc483b25c7fd5955091019c2104f76f 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -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 * diff --git a/core/js/tests/specHelper.js b/core/js/tests/specHelper.js index 04272161c8bd99f1f755f1ed80016676a4a809f8..83a469dc1b6a5df1ab267bfe298c64730f199858 100644 --- a/core/js/tests/specHelper.js +++ b/core/js/tests/specHelper.js @@ -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 = { diff --git a/core/src/OC/admin.js b/core/src/OC/admin.js new file mode 100644 index 0000000000000000000000000000000000000000..565af9946f7629e17252bd97215a63b7631f7c0c --- /dev/null +++ b/core/src/OC/admin.js @@ -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 diff --git a/core/src/OC/index.js b/core/src/OC/index.js index 308324ff4bd00a9561532ccd9e33094722cce4ba..dd618e7a1a05437dfb091e410972e7b76fecdbd3 100644 --- a/core/src/OC/index.js +++ b/core/src/OC/index.js @@ -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, diff --git a/core/src/globals.js b/core/src/globals.js index b84ef10d22b57ede73c83ba0d8caa3f7fc2d63b0..9fcf03ba9ee6524e841c87c6f7ee17ed6f1d591d 100644 --- a/core/src/globals.js +++ b/core/src/globals.js @@ -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 diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index 6ec92ef1cdd55e5f5ff8397048987a905579f8db..a190371d6d9e1b7049a8e8a48d5a7beaadfcd0b9 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -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."\"",