Commit ad0d24ff authored by romanb's avatar romanb

Fixed #1023. Thanks for ticket & patch.

parent 0dd85678
......@@ -350,14 +350,27 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
if ($dest->getNode()->isRoot()) {
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();
$newRight = $dest->getNode()->getRightValue() + 2;
$newRoot = $dest->getNode()->getRootValue();
$newLevel = $dest->getNode()->getLevel();
// 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'] = $dest['level'] - 1;
$this->record['level'] = $newLevel;
$this->insertNode($newLeft, $newRight, $newRoot);
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