[BUGFIX] Handle returnUrl for access module 28/54528/2
authorMarkus Klein <markus.klein@typo3.org>
Mon, 30 Oct 2017 19:56:30 +0000 (20:56 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 2 Nov 2017 08:49:37 +0000 (09:49 +0100)
With this fix the access module again returns to the correct
page the user expects it to return to.

Resolves: #82883
Releases: master, 8.7, 7.6
Change-Id: I76953aa1547365db6fbbea772d786e1ad9bfc184
Reviewed-on: https://review.typo3.org/54528
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/beuser/Classes/Controller/PermissionController.php
typo3/sysext/beuser/Resources/Private/Templates/Permission/Edit.html
typo3/sysext/beuser/Resources/Private/Templates/Permission/Index.html
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php

index b8c57e5..a98aef6 100644 (file)
@@ -42,9 +42,9 @@ class PermissionController extends ActionController
     protected $id;
 
     /**
-     * @var int
+     * @var string
      */
-    protected $returnId;
+    protected $returnUrl = '';
 
     /**
      * @var int
@@ -52,11 +52,6 @@ class PermissionController extends ActionController
     protected $depth;
 
     /**
-     * @var int
-     */
-    protected $lastEdited;
-
-    /**
      * Number of levels to enable recursive settings for
      *
      * @var int
@@ -89,22 +84,26 @@ class PermissionController extends ActionController
      */
     protected function initializeAction()
     {
+        // determine depth parameter
+        $this->depth = (int)GeneralUtility::_GP('depth') > 0
+            ? (int)GeneralUtility::_GP('depth')
+            : (int)$this->getBackendUser()->getSessionData(self::SESSION_PREFIX . 'depth');
+        if ($this->request->hasArgument('depth')) {
+            $this->depth = (int)$this->request->getArgument('depth');
+        }
+        $this->getBackendUser()->setAndSaveSessionData(self::SESSION_PREFIX . 'depth', $this->depth);
+
         // determine id parameter
         $this->id = (int)GeneralUtility::_GP('id');
         if ($this->request->hasArgument('id')) {
             $this->id = (int)$this->request->getArgument('id');
         }
 
-        // determine depth parameter
-        $this->depth = ((int)GeneralUtility::_GP('depth') > 0)
-            ? (int) GeneralUtility::_GP('depth')
-            : $this->getBackendUser()->getSessionData(self::SESSION_PREFIX . 'depth');
-        if ($this->request->hasArgument('depth')) {
-            $this->depth = (int)$this->request->getArgument('depth');
+        $this->returnUrl = GeneralUtility::_GP('returnUrl');
+        if ($this->request->hasArgument('returnUrl')) {
+            $this->returnUrl = $this->request->getArgument('returnUrl');
         }
-        $this->getBackendUser()->setAndSaveSessionData(self::SESSION_PREFIX . 'depth', $this->depth);
-        $this->lastEdited = GeneralUtility::_GP('lastEdited');
-        $this->returnId = GeneralUtility::_GP('returnId');
+
         $this->pageInfo = BackendUtility::readPageAccess($this->id, ' 1=1');
     }
 
@@ -139,6 +138,7 @@ class PermissionController extends ActionController
                 '
             );
             $this->registerDocHeaderButtons();
+            $this->view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($this->pageInfo);
             $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
         }
     }
@@ -166,12 +166,8 @@ class PermissionController extends ActionController
 
         if ($currentRequest->getControllerActionName() === 'edit') {
             // CLOSE button:
-            $closeUrl = $this->uriBuilder->reset()->setArguments([
-                'action' => 'index',
-                'id' => $this->id
-            ])->buildBackendUri();
             $closeButton = $buttonBar->makeLinkButton()
-                ->setHref($closeUrl)
+                ->setHref($this->returnUrl)
                 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc'))
                 ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon(
                     'actions-document-close',
@@ -243,6 +239,7 @@ class PermissionController extends ActionController
         foreach ([1, 2, 3, 4, 10] as $depthLevel) {
             $depthOptions[$depthLevel] = $depthLevel . ' ' . LocalizationUtility::translate('LLL:EXT:beuser/Resources/Private/Language/locallang_mod_permission.xlf:levels', 'beuser');
         }
+        $this->view->assign('currentId', $this->id);
         $this->view->assign('depthBaseUrl', $url);
         $this->view->assign('depth', $this->depth);
         $this->view->assign('depthOptions', $depthOptions);
@@ -322,7 +319,7 @@ class PermissionController extends ActionController
         $this->view->assign('currentBeGroup', $this->pageInfo['perms_groupid']);
         $this->view->assign('beGroupData', $beGroupDataArray);
         $this->view->assign('pageInfo', $this->pageInfo);
-        $this->view->assign('returnId', $this->returnId);
+        $this->view->assign('returnUrl', $this->returnUrl);
         $this->view->assign('recursiveSelectOptions', $this->getRecursiveSelectOptions());
     }
 
@@ -361,7 +358,7 @@ class PermissionController extends ActionController
                 }
             }
         }
-        $this->redirect('index', null, null, ['id' => $this->returnId, 'depth' => $this->depth]);
+        $this->redirectToUri($this->returnUrl);
     }
 
     /**
index a5ac1e0..b740e2f 100644 (file)
@@ -82,7 +82,7 @@
                <f:form.hidden name="data[pages][{id}][perms_group]" value="{pageInfo.perms_group}" />
                <f:form.hidden name="data[pages][{id}][perms_everybody]" value="{pageInfo.perms_everybody}" />
                <f:form.hidden name="depth" value="{depth}" />
-               <f:form.hidden name="redirect" value="{f:uri.action(action: 'index', arguments: {lastEdited: id, id: returnId})}" />
+               <f:form.hidden name="returnUrl" value="{returnUrl}" />
 
        </f:form>
 
index 509cb02..00cdfb1 100644 (file)
@@ -38,7 +38,7 @@
                                                                <td align="left" nowrap="nowrap">
                                                                        <f:link.action
                                                                                action="edit"
-                                                                               arguments="{id: '{f:if(condition: data.row._ORIG_uid, then: data.row._ORIG_uid, else: data.row.uid)}', depth: depth}"
+                                                                               arguments="{id: '{f:if(condition: data.row._ORIG_uid, then: data.row._ORIG_uid, else: data.row.uid)}', depth: depth, returnUrl: '{f:uri.action(action: \'index\', arguments: {id: currentId, depth: depth})}'}"
                                                                                title="{f:translate(key: 'LLL:EXT:beuser/Resources/Private/Language/locallang_mod_permission.xlf:ch_permissions')}"
                                                                        >
                                                                                <f:format.raw>{data.depthData}{data.HTML}</f:format.raw>
@@ -52,7 +52,7 @@
                                                                        </f:comment>
                                                                        <f:link.action
                                                                                action="edit"
-                                                                               arguments="{id: '{f:if(condition: data.row._ORIG_uid, then: data.row._ORIG_uid, else: data.row.uid)}', depth: depth}"
+                                                                               arguments="{id: '{f:if(condition: data.row._ORIG_uid, then: data.row._ORIG_uid, else: data.row.uid)}', depth: depth, returnUrl: '{f:uri.action(action: \'index\', arguments: {id: currentId, depth: depth})}'}"
                                                                                class="btn btn-default"
                                                                                title="{f:translate(key: 'LLL:EXT:beuser/Resources/Private/Language/locallang_mod_permission.xlf:ch_permissions')}"
                                                                        >
index 2456d8f..8196f07 100644 (file)
@@ -1479,7 +1479,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList
             }
             // "Edit Perms" link:
             if ($table === 'pages' && $this->getBackendUserAuthentication()->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility::isLoaded('beuser')) {
-                $href = BackendUtility::getModuleUrl('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&returnId=' . $row['uid'] . '&tx_beuser_system_beusertxpermission[action]=edit';
+                $href = BackendUtility::getModuleUrl('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&tx_beuser_system_beusertxpermission[action]=edit' . $this->makeReturnUrl();
                 $permsAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
                     . $this->getLanguageService()->getLL('permissions', true) . '">'
                     . $this->iconFactory->getIcon('status-status-locked', Icon::SIZE_SMALL)->render() . '</a>';