Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 33 additions & 13 deletions core/js/dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/main.js.map

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions core/js/js.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global oc_isadmin */

var oc_debug;
var oc_webroot;

Expand Down Expand Up @@ -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
*
Expand Down
1 change: 0 additions & 1 deletion core/js/tests/specHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
30 changes: 30 additions & 0 deletions core/src/OC/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* @copyright 2019 Christoph Wurst <[email protected]>
*
* @author 2019 Christoph Wurst <[email protected]>
*
* @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
2 changes: 2 additions & 0 deletions core/src/OC/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -52,6 +53,7 @@ export default {
config: Config,
dialogs: Dialogs,
EventSource,
isUserAdmin,
L10N,
msg,
Notification,
Expand Down
1 change: 1 addition & 0 deletions core/src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Template/JSConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function getConfig() {

$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."\"",
Expand Down