[TASK] Move config.beLoginLinkIPList to compat7 56/52156/4
authorBenni Mack <benni@typo3.org>
Sat, 25 Mar 2017 19:39:07 +0000 (20:39 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Sat, 25 Mar 2017 22:17:41 +0000 (23:17 +0100)
The functionality to output a login link / logout link when coming from
a certain IP address (set via TypoScript config.beLoginLinkIPList) was
moved to EXT:compatibility7.

Resolves: #80444
Releases: master
Change-Id: I1b754cfd454abd3376642a290c056442c5be733d
Reviewed-on: https://review.typo3.org/52156
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/compatibility7/Classes/Hooks/BackendLoginLinkHook.php [new file with mode: 0644]
typo3/sysext/compatibility7/ext_localconf.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-80444-TypoScriptFrontendController-BeLoginLinkIPList.rst [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Important-80444-ConfigbeLoginLinkIPListMovedToCompatibility7.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Http/RequestHandler.php

diff --git a/typo3/sysext/compatibility7/Classes/Hooks/BackendLoginLinkHook.php b/typo3/sysext/compatibility7/Classes/Hooks/BackendLoginLinkHook.php
new file mode 100644 (file)
index 0000000..06152b5
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+namespace TYPO3\CMS\Compatibility7\Hooks;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
+
+/**
+ * Hook to validate the TypoScript option
+ * config.beLoginLinkIPList, config beLoginLinkIPList_login and config.beLoginLinkIPList_logout
+ */
+class BackendLoginLinkHook
+{
+    /**
+     * Echoes a link to the BE login screen with redirect to the front-end
+     * if the option config.beLoginLinkIPList is set.
+     *
+     * @param array $parameters left empty, not in use
+     * @param TypoScriptFrontendController $parentObject
+     */
+    public function renderBackendLoginLink(array $parameters, TypoScriptFrontendController $parentObject)
+    {
+        if (empty($parentObject->config['config']['beLoginLinkIPList'])) {
+            return;
+        }
+        if (!GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $parentObject->config['config']['beLoginLinkIPList'])) {
+            return;
+        }
+        $label = !$parentObject->isBackendUserLoggedIn() ? $parentObject->config['config']['beLoginLinkIPList_login'] : $parentObject->config['config']['beLoginLinkIPList_logout'];
+        if ($label) {
+            if (!$parentObject->isBackendUserLoggedIn()) {
+                $link = '<a href="' . htmlspecialchars((TYPO3_mainDir . 'index.php?redirect_url=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . $label . '</a>';
+            } else {
+                $link = '<a href="' . htmlspecialchars((TYPO3_mainDir . 'index.php?L=OUT&redirect_url=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . $label . '</a>';
+            }
+            echo $link;
+        }
+    }
+}
index 3ac8cb1..e2603a8 100644 (file)
@@ -101,3 +101,7 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Backend\Controller\PageLayo
 // Enable TypoScript functionality config.sys_language_softExclude
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_postProcess']['compatibility7_softExclude']
     = \TYPO3\CMS\Compatibility7\Hooks\TcaSoftExcludeHook::class . '->setCustomExcludeFields';
+
+// Enable TypoScript functionality config.beLoginLinkIPList
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe']['compatibility7_backendloginlink']
+    = \TYPO3\CMS\Compatibility7\Hooks\BackendLoginLinkHook::class . '->renderBackendLoginLink';
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80444-TypoScriptFrontendController-BeLoginLinkIPList.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80444-TypoScriptFrontendController-BeLoginLinkIPList.rst
new file mode 100644 (file)
index 0000000..24f7c47
--- /dev/null
@@ -0,0 +1,33 @@
+.. include:: ../../Includes.txt
+
+======================================================================
+Deprecation: #80444 - TypoScriptFrontendController-> beLoginLinkIPList
+======================================================================
+
+See :issue:`80444`
+
+Description
+===========
+
+The method ``TypoScriptFrontendController->beLoginLinkIPList`` has been marked as deprecated.
+
+
+Impact
+======
+
+Calling the PHP method directly will trigger a deprecation warning.
+
+
+Affected Installations
+======================
+
+Any installation instantiating a custom frontend-related RequestHandler or using the method above
+when rendering the frontend. Also, any custom extension using this method.
+
+
+Migration
+=========
+
+The functionality is moved to EXT:compatibility7.
+
+.. index:: Frontend
\ No newline at end of file
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Important-80444-ConfigbeLoginLinkIPListMovedToCompatibility7.rst b/typo3/sysext/core/Documentation/Changelog/master/Important-80444-ConfigbeLoginLinkIPListMovedToCompatibility7.rst
new file mode 100644 (file)
index 0000000..2eba7af
--- /dev/null
@@ -0,0 +1,15 @@
+.. include:: ../../Includes.txt
+
+====================================================================
+Important: #80444 - config.beLoginLinkIPList moved to compatibility7
+====================================================================
+
+See :issue:`80444`
+
+Description
+===========
+
+The TypoScript option ``config.beLoginLinkIPList`` which renders a link to login/logout to the TYPO3
+Backend when visiting a frontend page from a certain IP address, has been moved to EXT:compatibility7.
+
+.. index:: TypoScript
\ No newline at end of file
index f71b2df..4c9a5c5 100644 (file)
@@ -3891,9 +3891,11 @@ class TypoScriptFrontendController
      * Returns a link to the BE login screen with redirect to the front-end
      *
      * @return string HTML, a tag for a link to the backend.
+     * @deprecated since TYPO3 v8, will be removed in TYPO3 v9
      */
     public function beLoginLinkIPList()
     {
+        GeneralUtility::logDeprecatedFunction();
         if (!empty($this->config['config']['beLoginLinkIPList'])) {
             if (GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $this->config['config']['beLoginLinkIPList'])) {
                 $label = !$this->beUserLogin ? $this->config['config']['beLoginLinkIPList_login'] : $this->config['config']['beLoginLinkIPList_logout'];
index 3865f54..ef30c09 100644 (file)
@@ -19,7 +19,6 @@ use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\FrontendEditing\FrontendEditingController;
 use TYPO3\CMS\Core\Http\RequestHandlerInterface;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
-use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\MonitorUtility;
@@ -258,8 +257,6 @@ class RequestHandler implements RequestHandlerInterface
         $this->timeTracker->pull();
         // Check memory usage
         MonitorUtility::peakMemoryUsage();
-        // beLoginLinkIPList
-        echo $this->controller->beLoginLinkIPList();
 
         // Admin panel
         if ($this->controller->isBackendUserLoggedIn() && $GLOBALS['BE_USER'] instanceof FrontendBackendUserAuthentication) {