[BUGFIX] create/move new page behind move-placeholder
authorDennis Ahrens <dennis.ahrens@fh-hannover.de>
Wed, 11 Jan 2012 06:22:38 +0000 (07:22 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Mon, 6 Feb 2012 09:10:39 +0000 (10:10 +0100)
Fixes the described scenerio below by using just another tcemain hook.

* Switch to a workspace without pending changes.
* Move page M that is located behind X as a child of Y to any other location.
* Now create a new page N behind our moved page M (using the pagetree drag & drop)
  the page seems to be located correct, but if you refresh the pagetree this new
  page N is not at the intended location anymore.
* Searching the tree shows that it became a child of Y behind the page X, which
  was the old location of M.

Change-Id: I1f3140f9822d3197cbdfddb7e954a8b0f90be491
Fixes: #33104
Releases: 4.5,4.6,4.7
Reviewed-on: http://review.typo3.org/7732
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/version/class.tx_version_tcemain.php

index 218d52d..ea53c0f 100644 (file)
@@ -137,6 +137,32 @@ class tx_version_tcemain {
        }
 
        /**
+        * Hook that is called after tcemain made most of its decisions.
+        *
+        * NOTE: This fixes an issue related to moving/creating initial-placeholders - if such a new page
+        * is intended to be place behind a move-placeholder tcemain handles the movement/creation,
+        * but does not respect the wsPlaceholder, which leads the new page to be located at the old location of the
+        * page where it was intended to be placed behind.
+        *
+        * @param string $command
+        * @param string $table
+        * @param int $id
+        * @param mixed $value
+        * @param t3lib_TCEmain $tcemain
+        */
+       public function processCmdmap_postProcess($command, $table, $id, $value, t3lib_TCEmain $tcemain) {
+               if ($command === 'move') {
+                       if ($value < 0) {
+                               $movePlaceHolder = t3lib_BEfunc::getMovePlaceholder($table, abs($value), 'uid');
+                               if ($movePlaceHolder !== FALSE) {
+                                       $destPid = -$movePlaceHolder['uid'];
+                                       $tcemain->moveRecord_raw($table, $id, $destPid);
+                               }
+                       }
+               }
+       }
+
+       /**
         * hook that is called AFTER all commands of the commandmap was
         * executed
         *
@@ -1415,4 +1441,4 @@ class tx_version_tcemain {
 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_tcemain.php'])) {
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_tcemain.php']);
 }
-?>
\ No newline at end of file
+?>