diff --git a/core/js/dist/main.js b/core/js/dist/main.js index ad7c4a8be0..faa2d5c10d 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 063ef13bb5..6d33bda9ed 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 f5d7ac4561..d420a8667f 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -6,8 +6,6 @@ var oc_webroot; var oc_current_user = document.getElementsByTagName('head')[0].getAttribute('data-user'); var oc_requesttoken = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken'); -window.oc_config = window.oc_config || {}; - if (typeof oc_webroot === "undefined") { oc_webroot = location.pathname; var pos = oc_webroot.indexOf('/index.php/'); @@ -61,7 +59,6 @@ Object.assign(window.OC, { * @deprecated use {@link OC.getCurrentUser} instead */ currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false, - config: window.oc_config, appConfig: window.oc_appconfig || {}, theme: window.oc_defaults || {}, coreApps:['', 'admin','log','core/search','settings','core','3rdparty'], diff --git a/core/js/tests/specHelper.js b/core/js/tests/specHelper.js index 5d4a7b81b5..04272161c8 100644 --- a/core/js/tests/specHelper.js +++ b/core/js/tests/specHelper.js @@ -93,7 +93,7 @@ window.oc_appswebroots = { "files": window.oc_webroot + '/apps/files/', "files_sharing": window.oc_webroot + '/apps/files_sharing/' }; -window.oc_config = { +OC.config = { session_lifetime: 600 * 1000, session_keepalive: false, blacklist_files_regex: '\.(part|filepart)$', diff --git a/core/src/OC/config.js b/core/src/OC/config.js new file mode 100644 index 0000000000..d1a3211cf6 --- /dev/null +++ b/core/src/OC/config.js @@ -0,0 +1,24 @@ +/* + * @copyright 2019 Christoph Wurst + * + * @author 2019 Christoph Wurst + * + * @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 . + */ + +const config = window._oc_config || {} + +export default config diff --git a/core/src/OC/index.js b/core/src/OC/index.js index 76b244adf3..789b5b22fa 100644 --- a/core/src/OC/index.js +++ b/core/src/OC/index.js @@ -22,6 +22,7 @@ import Apps from './apps' import AppConfig from './appconfig' import Backbone from './backbone' +import Config from './config' import ContactsMenu from './contactsmenu' import Dialogs from './dialogs' import EventSource from './eventsource' @@ -40,6 +41,7 @@ export default { AppConfig, Backbone, ContactsMenu, + config: Config, dialogs: Dialogs, EventSource, L10N, diff --git a/core/src/globals.js b/core/src/globals.js index cbb26cfc2a..b84ef10d22 100644 --- a/core/src/globals.js +++ b/core/src/globals.js @@ -34,7 +34,10 @@ const deprecate = (func, funcName) => { return newFunc } -const setDeprecatedProp = (global, val, msg) => +const setDeprecatedProp = (global, val, msg) => { + if (window[global] !== undefined) { + delete window[global] + } Object.defineProperty(window, global, { get: () => { if (msg) { @@ -45,6 +48,7 @@ const setDeprecatedProp = (global, val, msg) => return val } }) +} import _ from 'underscore' import $ from 'jquery' @@ -103,7 +107,8 @@ window['md5'] = md5 window['moment'] = moment window['OC'] = OC -setDeprecatedProp('OCDialogs', OC.dialogs, 'use OC.dialogs') +setDeprecatedProp('oc_config', OC.config, 'use OC.config instead') +setDeprecatedProp('OCDialogs', OC.dialogs, 'use OC.dialogs instead') window['OCP'] = OCP window['OCA'] = OCA window['escapeHTML'] = deprecate(escapeHTML, 'escapeHTML') diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index 26da8fcc3c..6ec92ef1cd 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -231,7 +231,7 @@ class JSConfigHelper { (string)$this->l->t('Dec.') ]), "firstDay" => json_encode($this->l->l('firstday', null)) , - "oc_config" => json_encode([ + "_oc_config" => json_encode([ 'session_lifetime' => min($this->config->getSystemValue('session_lifetime', $this->iniWrapper->getNumeric('session.gc_maxlifetime')), $this->iniWrapper->getNumeric('session.gc_maxlifetime')), 'session_keepalive' => $this->config->getSystemValue('session_keepalive', true), 'version' => implode('.', \OCP\Util::getVersion()),