From 6b5aa874ea907d4a8682a69997e324e4d3af288a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 1 Mar 2020 00:32:30 +0100 Subject: [PATCH] Prevent script errors when running in enterprise mode --- .../js/WoltLabSuite/Core/Acp/Ui/Option/EmailSmtpTest.js | 7 ++++++- .../WoltLabSuite/Core/Acp/Ui/Option/RewriteGenerator.js | 9 ++++++++- .../js/WoltLabSuite/Core/Acp/Ui/Option/RewriteTest.js | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Option/EmailSmtpTest.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Option/EmailSmtpTest.js index 369976e20c..7ba5707111 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Option/EmailSmtpTest.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Option/EmailSmtpTest.js @@ -7,12 +7,17 @@ define(['Ajax', 'Core', 'Language'], function(Ajax, Core, Language) { return { init: function () { var smtpCheckbox = null; - elBySelAll('input[name="values[mail_send_method]"]', undefined, (function (radioCheckbox) { + var methods = elBySelAll('input[name="values[mail_send_method]"]', undefined, (function (radioCheckbox) { radioCheckbox.addEventListener('change', this._onChange.bind(this)); if (radioCheckbox.value === 'smtp') smtpCheckbox = radioCheckbox; }).bind(this)); + // This configuration part is unavailable when running in enterprise mode. + if (methods.length === 0) { + return; + } + Core.triggerEvent(smtpCheckbox, 'change'); }, diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Option/RewriteGenerator.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Option/RewriteGenerator.js index d9258d45cb..128da693fe 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Option/RewriteGenerator.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Option/RewriteGenerator.js @@ -20,6 +20,13 @@ define(['Ajax', 'Language', 'Ui/Dialog'], function (Ajax, Language, UiDialog) { * Initializes the generator for rewrite rules */ init: function () { + var urlOmitIndexPhp = elById('url_omit_index_php'); + + // This configuration part is unavailable when running in enterprise mode. + if (urlOmitIndexPhp === null) { + return; + } + _container = elCreate('dl'); var dt = elCreate('dt'); dt.classList.add('jsOnly'); @@ -38,7 +45,7 @@ define(['Ajax', 'Language', 'Ui/Dialog'], function (Ajax, Language, UiDialog) { _container.appendChild(dt); _container.appendChild(dd); - var insertAfter = elById('url_omit_index_php').closest('dl'); + var insertAfter = urlOmitIndexPhp.closest('dl'); insertAfter.parentNode.insertBefore(_container, insertAfter.nextSibling); }, diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Option/RewriteTest.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Option/RewriteTest.js index fd364b9339..604ef9df45 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Option/RewriteTest.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Option/RewriteTest.js @@ -27,6 +27,11 @@ define(['AjaxRequest', 'Language', 'Ui/Dialog'], function (AjaxRequest, Language * @param {Dictionary} apps */ init: function (apps) { + // This configuration part is unavailable when running in enterprise mode. + if (_option === null) { + return; + } + if (_option.checked) { // option is already enabled, ignore it return; -- 2.20.1