[BUGFIX] Init simulate usergroup correctly in admin panel 30/58330/3
authorFrank Naegler <frank.naegler@typo3.org>
Wed, 19 Sep 2018 09:01:10 +0000 (11:01 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Thu, 20 Sep 2018 03:21:57 +0000 (05:21 +0200)
The PreviewModule must be run before initializeFrontendPreview is called,
to ensure the settings from adminpanel are available if the init preview happens.

Resolves: #84198
Releases: master
Change-Id: I74366e652b9195e46aaaa724f2de343b125343ed
Reviewed-on: https://review.typo3.org/58330
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/adminpanel/Classes/Modules/PreviewModule.php
typo3/sysext/adminpanel/Configuration/RequestMiddlewares.php
typo3/sysext/adminpanel/Resources/Private/Partials/Form/Select.html

index 44d77ee..6e1562f 100644 (file)
@@ -114,7 +114,7 @@ class PreviewModule extends AbstractModule implements InitializableInterface, Pa
                 'simulateDate' => $this->config['simulateDate'],
                 'frontendUserGroups' => [
                     'availableGroups' => $frontendGroupsRepository->getAvailableFrontendUserGroups(),
-                    'selected' => $this->config['simulateUserGroup'],
+                    'selected' => (int)$this->config['simulateUserGroup'],
                 ],
             ]
         );
@@ -175,9 +175,10 @@ class PreviewModule extends AbstractModule implements InitializableInterface, Pa
         string $simulateUserGroup
     ): void {
         $context = GeneralUtility::makeInstance(Context::class);
-        $tsfe = $this->getTypoScriptFrontendController();
-        $tsfe->clear_preview();
-        $tsfe->fePreview = 1;
+        $typoScriptFrontendController = $this->getTypoScriptFrontendController();
+        $typoScriptFrontendController->clear_preview();
+        $typoScriptFrontendController->fePreview = 1;
+
         // Simulate date
         $simTime = null;
         if ($simulateDate) {
@@ -190,20 +191,20 @@ class PreviewModule extends AbstractModule implements InitializableInterface, Pa
         }
         $context->setAspect('visibility', GeneralUtility::makeInstance(VisibilityAspect::class, $showHiddenPages, $showHiddenRecords));
         // simulate user
-        $tsfe->simUserGroup = $simulateUserGroup;
-        if ($tsfe->simUserGroup) {
-            if ($tsfe->fe_user->user) {
-                $tsfe->fe_user->user[$tsfe->fe_user->usergroup_column] = $tsfe->simUserGroup;
+        $typoScriptFrontendController->simUserGroup = (int)$simulateUserGroup;
+        if ($typoScriptFrontendController->simUserGroup) {
+            if ($typoScriptFrontendController->fe_user->user) {
+                $typoScriptFrontendController->fe_user->user[$typoScriptFrontendController->fe_user->usergroup_column] = $typoScriptFrontendController->simUserGroup;
             } else {
-                $tsfe->fe_user = GeneralUtility::makeInstance(FrontendUserAuthentication::class);
-                $tsfe->fe_user->user = [
-                    $tsfe->fe_user->usergroup_column => $tsfe->simUserGroup,
+                $typoScriptFrontendController->fe_user = GeneralUtility::makeInstance(FrontendUserAuthentication::class);
+                $typoScriptFrontendController->fe_user->user = [
+                    $typoScriptFrontendController->fe_user->usergroup_column => $typoScriptFrontendController->simUserGroup,
                 ];
             }
-            $context->setAspect('frontend.user', GeneralUtility::makeInstance(UserAspect::class, $tsfe->fe_user ?: null));
+            $context->setAspect('frontend.user', GeneralUtility::makeInstance(UserAspect::class, $typoScriptFrontendController->fe_user ?: null));
         }
-        if (!$tsfe->simUserGroup && !$simTime && !$showHiddenPages && !$showHiddenRecords) {
-            $tsfe->fePreview = 0;
+        if (!$typoScriptFrontendController->simUserGroup && !$simTime && !$showHiddenPages && !$showHiddenRecords) {
+            $typoScriptFrontendController->fePreview = 0;
         }
     }
 
index 0bf26c5..0b08aa5 100644 (file)
@@ -13,7 +13,8 @@ return [
         'typo3/cms-adminpanel/initiator' => [
             'target' => \TYPO3\CMS\Adminpanel\Middleware\AdminPanelInitiator::class,
             'before' => [
-                'typo3/cms-frontend/prepare-tsfe-rendering'
+                'typo3/cms-frontend/prepare-tsfe-rendering',
+                'typo3/cms-frontend/page-resolver'
             ],
             'after' => [
                 'typo3/cms-frontend/tsfe',
index ff15fa2..9c30747 100644 (file)
@@ -8,7 +8,7 @@
             <select name="TSFE_ADMIN_PANEL[{name}]" id="{name}" class="typo3-adminPanel-form-select-input">
                 <option value="0"></option>
                 <f:for each="{options}" as="option">
-                    <option value="{option.{optionValue}}" {f:if(condition:'{option.{optionValue}} === {value}', then: 'selected')}>
+                    <option value="{option.{optionValue}}" {f:if(condition:'{option.{optionValue}} == {value}', then: 'selected')}>
                         {option.{optionLabel}}
                     </option>
                 </f:for>