[BUGFIX] Select available page when changing WS 90/24590/2
authorThorsten Kahler <thorsten.kahler@typo3.org>
Thu, 7 Feb 2013 17:13:34 +0000 (18:13 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 11 Oct 2013 15:25:22 +0000 (17:25 +0200)
When changing to another workspaces the currently selected page is not
always available.
This change selects the next available page from the rootline for page
tree and submodules of web module when the current page does not exist
in the workspace.

Change-Id: I0502fea3c21515421586403a41f5c696ffc0d762
Fixes: #37611
Releases: 6.2, 6.1, 6.0, 4.7, 4.5
Reviewed-on: https://review.typo3.org/24590
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/workspaces/Classes/ExtDirect/ToolbarMenu.php
typo3/sysext/workspaces/Resources/Public/JavaScript/workspacemenu.js

index abba483..9f4b1dc 100644 (file)
@@ -49,14 +49,31 @@ class ToolbarMenu {
         */
        public function setWorkspace($parameter) {
                $workspaceId = intval($parameter->workSpaceId);
+               $pageId = intval($parameter->pageId);
+
                $GLOBALS['BE_USER']->setWorkspace($workspaceId);
+
+               while ($pageId) {
+                       $page = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $pageId, '*',
+                               ' AND pages.t3ver_wsid IN (0, ' . $workspaceId . ')');
+                       if ($page) {
+                               if ($GLOBALS['BE_USER']->doesUserHaveAccess($page, 1)) {
+                                       break;
+                               }
+                       } else {
+                               $page = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $pageId);
+                       }
+                       $pageId = $page['pid'];
+               }
+
                return array(
                        'title' => \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($workspaceId),
-                       'id' => $workspaceId
+                       'id' => $workspaceId,
+                       'page' => (isset($page['uid']) && ($parameter->pageId == $page['uid'])) ? NULL : intval($page['uid'])
                );
        }
 
 }
 
 
-?>
\ No newline at end of file
+?>
index 57e86a8..e9725fe 100644 (file)
@@ -98,11 +98,22 @@ var WorkspaceMenu = Class.create({
                var clickedElement = Event.element(event);
                var workspaceId = clickedElement.identify().substring(3);
 
-               TYPO3.Ajax.ExtDirect.ToolbarMenu.setWorkspace({'workSpaceId': workspaceId }, function(response) {
+               TYPO3.Ajax.ExtDirect.ToolbarMenu.setWorkspace({
+                       'workSpaceId': workspaceId,
+                       'pageId': fsMod.recentIds['web']
+               }, function(response) {
                        if (!response.id) {
                                response.id = 0;
                        }
 
+                       if (Ext.isNumber(response.page)) {
+                               fsMod.recentIds['web'] = parseInt(response.page, 10);
+                               var url = TYPO3.Backend.ContentContainer.getUrl().split('?');
+                               var parameters = Ext.urlDecode(url[1]);
+                               parameters.id = fsMod.recentIds['web'];
+                               TYPO3.Backend.ContentContainer.setUrl(Ext.urlAppend(url[0], Ext.urlEncode(parameters)));
+                       }
+
                        TYPO3BackendWorkspaceMenu.performWorkspaceSwitch(response.id, response.title);
 
                        // when in web module reload, otherwise send the user to the web module
@@ -189,4 +200,4 @@ var WorkspaceMenu = Class.create({
 
 });
 
-var TYPO3BackendWorkspaceMenu = new WorkspaceMenu();
\ No newline at end of file
+var TYPO3BackendWorkspaceMenu = new WorkspaceMenu();