Changeset 4343

Show
Ignore:
Timestamp:
05/08/08 22:04:19 (8 months ago)
Author:
romanb
Message:

Fixed #1023. Thanks for ticket & patch.

Location:
branches/0.11
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Node/NestedSet.php

    r4089 r4343  
    351351            return false; 
    352352        } 
    353         $newRoot = $dest->getNode()->getRootValue(); 
    354         $this->shiftRLValues($dest->getNode()->getLeftValue(), 1, $newRoot); 
    355         $this->shiftRLValues($dest->getNode()->getRightValue() + 2, 1, $newRoot); 
    356          
    357         $newLeft = $dest->getNode()->getLeftValue(); 
     353         
     354        $newLeft  = $dest->getNode()->getLeftValue(); 
    358355        $newRight = $dest->getNode()->getRightValue() + 2; 
    359  
    360         $this->record['level'] = $dest['level'] - 1; 
    361         $this->insertNode($newLeft, $newRight, $newRoot); 
     356        $newRoot  = $dest->getNode()->getRootValue(); 
     357                $newLevel = $dest->getNode()->getLevel(); 
     358                 
     359                // Make space for new node 
     360        $this->shiftRLValues($dest->getNode()->getRightValue() + 1, 2, $newRoot); 
     361         
     362        // Slide child nodes over one and down one to allow new parent to wrap them 
     363                $componentName = $this->_tree->getBaseComponent();               
     364        $q = new Doctrine_Query(); 
     365        $q->update($componentName); 
     366        $q->set("$componentName.lft", "$componentName.lft + 1"); 
     367        $q->set("$componentName.rgt", "$componentName.rgt + 1"); 
     368        $q->set("$componentName.level", "$componentName.level + 1"); 
     369        $q->where("$componentName.lft >= ? AND $componentName.rgt <= ?", array($newLeft, $newRight)); 
     370                $q = $this->_tree->returnQueryWithRootId($q, $newRoot); 
     371                $q->execute(); 
     372         
     373        $this->record['level'] = $newLevel; 
     374                $this->insertNode($newLeft, $newRight, $newRoot); 
    362375         
    363376        return true; 
  • branches/0.11/tests/ValidatorTestCase.php

    r4341 r4343  
    499499    } 
    500500} 
     501