Commit ad0d24ff authored by romanb's avatar romanb

Fixed #1023. Thanks for ticket & patch.

parent 0dd85678
...@@ -350,15 +350,28 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int ...@@ -350,15 +350,28 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
if ($dest->getNode()->isRoot()) { if ($dest->getNode()->isRoot()) {
return false; return false;
} }
$newRoot = $dest->getNode()->getRootValue();
$this->shiftRLValues($dest->getNode()->getLeftValue(), 1, $newRoot);
$this->shiftRLValues($dest->getNode()->getRightValue() + 2, 1, $newRoot);
$newLeft = $dest->getNode()->getLeftValue(); $newLeft = $dest->getNode()->getLeftValue();
$newRight = $dest->getNode()->getRightValue() + 2; $newRight = $dest->getNode()->getRightValue() + 2;
$newRoot = $dest->getNode()->getRootValue();
$this->record['level'] = $dest['level'] - 1; $newLevel = $dest->getNode()->getLevel();
$this->insertNode($newLeft, $newRight, $newRoot);
// Make space for new node
$this->shiftRLValues($dest->getNode()->getRightValue() + 1, 2, $newRoot);
// Slide child nodes over one and down one to allow new parent to wrap them
$componentName = $this->_tree->getBaseComponent();
$q = new Doctrine_Query();
$q->update($componentName);
$q->set("$componentName.lft", "$componentName.lft + 1");
$q->set("$componentName.rgt", "$componentName.rgt + 1");
$q->set("$componentName.level", "$componentName.level + 1");
$q->where("$componentName.lft >= ? AND $componentName.rgt <= ?", array($newLeft, $newRight));
$q = $this->_tree->returnQueryWithRootId($q, $newRoot);
$q->execute();
$this->record['level'] = $newLevel;
$this->insertNode($newLeft, $newRight, $newRoot);
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment