[BUGFIX] Select available page when changing WS 95/24595/3
authorThorsten Kahler <thorsten.kahler@typo3.org>
Fri, 11 Oct 2013 15:57:22 +0000 (17:57 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 12 Oct 2013 10:05:04 +0000 (12:05 +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/24595
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/workspaces/Classes/ExtDirect/ToolbarMenu.php
typo3/sysext/workspaces/Resources/Public/JavaScript/workspacemenu.js

index cad55e0..c378418 100644 (file)
@@ -49,11 +49,26 @@ class tx_Workspaces_ExtDirect_ToolbarMenu {
         */
        public function setWorkspace($parameter) {
                $workspaceId = intval($parameter->workSpaceId);
+               $pageId = intval($parameter->pageId);
 
                $GLOBALS['BE_USER']->setWorkspace($workspaceId);
+
+               while ($pageId) {
+                       $page = t3lib_BEfunc::getRecordWSOL('pages', $pageId, '*', ' AND pages.t3ver_wsid IN (0, ' . $workspaceId . ')');
+                       if ($page) {
+                               if ($GLOBALS['BE_USER']->doesUserHaveAccess($page, 1)) {
+                                       break;
+                               }
+                       } else {
+                               $page = t3lib_BEfunc::getRecord('pages', $pageId);
+                       }
+                       $pageId = $page['pid'];
+               }
+
                return array(
                        'title' => tx_Workspaces_Service_Workspaces::getWorkspaceTitle($workspaceId),
-                       'id' => $workspaceId
+                       'id' => $workspaceId,
+                       'page' => ($parameter->pageId == $page['uid']) ? NULL : intval($page['uid'])
                );
        }
 }
index f9b00a2..1ef6371 100644 (file)
@@ -120,25 +120,36 @@ var WorkspaceMenu = Class.create({
                var clickedElement = Event.element(event);
                var workspaceId = clickedElement.identify().substring(3);
 
-               TYPO3.Ajax.ExtDirect.ToolbarMenu.setWorkspace({'workSpaceId': workspaceId }, function(response) {
-                       if (!response.id) {
-                               response.id = 0;
-                       }
+               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);
+                               TYPO3BackendWorkspaceMenu.performWorkspaceSwitch(response.id, response.title);
 
-                       // when in web module reload, otherwise send the user to the web module
-                       if (currentModuleLoaded.startsWith('web_')) {
-                               top.TYPO3.Backend.NavigationContainer.PageTree.refreshTree();
-                               top.TYPO3.ModuleMenu.App.reloadFrames();
-                       } else {
-                               if (TYPO3.configuration.pageModule) {
-                                       top.TYPO3.ModuleMenu.App.showModule(TYPO3.configuration.pageModule);
+                               // when in web module reload, otherwise send the user to the web module
+                               if (currentModuleLoaded.startsWith('web_')) {
+                                       top.TYPO3.Backend.NavigationContainer.PageTree.refreshTree();
+                                       top.TYPO3.ModuleMenu.App.reloadFrames();
+                               } else {
+                                       if (TYPO3.configuration.pageModule) {
+                                               top.TYPO3.ModuleMenu.App.showModule(TYPO3.configuration.pageModule);
+                                       }
                                }
-                       }
 
-                       // reload the module menu
-                       TYPO3ModuleMenu.refreshMenu();
+                               // reload the module menu
+                               TYPO3ModuleMenu.refreshMenu();
                });
 
                TYPO3BackendWorkspaceMenu.toggleMenu(event);