public function pageDrop($args) { $srcId = (int) $args['srcId']; $dstId = (int) $args['dstId']; $srcPage = DBUtil::selectObjectByID('content_page', $srcId); $dstPage = DBUtil::selectObjectByID('content_page', $dstId); // Is $src a parent of $dst? This is not allowed if ($srcPage['setLeft'] < $dstPage['setLeft'] && $srcPage['setRight'] > $dstPage['setRight']) { return LogUtil::registerError($this->__('Error! It is not possible to move a parent page beneath one of its descendants.')); } // Remove the src page and reinsert later on. $ok = $this->removePage(array('id' => $srcId)); if ($ok === false) { return false; } DBUtil::flushCache('content_page'); // Get destination again so we get an updated position after the above "removePage" and DB flush $dstPage = DBUtil::selectObjectByID('content_page', $dstId); $test = $this->isUniqueUrlnameByParentID(array('urlname' => $srcPage['urlname'], 'parentId' => $dstPage['parentPageId'], 'currentPageId' => $srcId)); if (!$test) { // not unique name so reinsert at src position $this->insertPage(array('pageId' => $srcId, 'position' => $srcPage['position'], 'parentPageId' => $srcPage['parentPageId'])); // FIXME: This causes a "page not found". But I don't know why. Pls help ;) return LogUtil::registerError($this->__('Error! There is already another page registered with the supplied permalink URL.')); } // insert the srcPage as subpage of the dstPage $ok = $this->insertPage(array('pageId' => $srcId, 'position' => $dstPage['position'] + 1, 'parentPageId' => $dstPage['id'])); if ($ok === false) { return false; } else { // Expand the destination page to show the new nested page Content_Util::contentMainEditExpandSet($dstPage['id'], true); } Content_Util::clearCache(); return true; }