Fixed bug #11529: Infinite not infinite / moved pages not always visible in element...
authortolleiv <tolleiv@743128fe-103e-dd11-99c4-001b210b3e58>
Mon, 17 Jan 2011 23:22:05 +0000 (23:22 +0000)
committertolleiv <tolleiv@743128fe-103e-dd11-99c4-001b210b3e58>
Mon, 17 Jan 2011 23:22:05 +0000 (23:22 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/CoreProjects/workspaces/workspaces/trunk@3848 743128fe-103e-dd11-99c4-001b210b3e58

typo3/sysext/workspaces/ChangeLog
typo3/sysext/workspaces/Classes/Service/Workspaces.php

index cd0e5b1..b74f861 100644 (file)
@@ -1,3 +1,7 @@
+2011-01-18  Tolleiv Nietsch <typo3@tolleiv.de>
+
+       * Fixed bug #11529: Infinite not infinite / moved pages not always visible in element list
+
 2011-01-16  Sonja Scholz <ss@cabag.ch>
 
        * Fixed bug #11825: non-admin editors can't see non-page records within the review module
index 2e7c9a4..6b8b7aa 100644 (file)
@@ -354,15 +354,22 @@ class tx_Workspaces_Service_Workspaces {
                        if ($pageList) {
                                        // Remove the "subbranch" if a page was moved away
                                $movedAwayPages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid, pid, t3ver_move_id', 'pages', 't3ver_move_id IN (' . $pageList . ') AND t3ver_wsid=' . $wsid . t3lib_BEfunc::deleteClause($table), '', 'uid', '', 't3ver_move_id');
-                               $newList = array();
                                $pageIds = t3lib_div::intExplode(',', $pageList, TRUE);
 
-                               foreach ($pageIds as $tmpId) {
-                                       if (isset($movedAwayPages[$tmpId]) && !empty($newList) && !in_array($movedAwayPages[$tmpId]['pid'], intval($newList))) {
-                                               break;
+                                       // move all pages away
+                               $newList = array_diff($pageIds, array_keys($movedAwayPages));
+
+                                       // move back in if still connected to the "remaining" pages
+                               do {
+                                       $changed = FALSE;
+                                       foreach ($movedAwayPages as $uid => $rec) {
+                                               if (in_array($rec['pid'], $newList) && !in_array($uid, $newList)) {
+                                                       $newList[] = $uid;
+                                                       $changed = TRUE;
+                                               }
                                        }
-                                       $newList[] = $tmpId;
-                               }
+                               } while ($changed);
+
                                $pageList = implode(',', $newList);
                        }
                                // In case moving pages is enabled we need to replace all move-to pointer with their origin