From 5c095cbd787bf71e30658536aafdbf8ea837aa1f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 4 Dec 2008 01:12:44 +0000 Subject: Add unit tests to test growing and contracting the left and right pointers Added a delete method to ORM_MPTT that contracts the tree when an item is deleted --- core/libraries/ORM_MPTT.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'core/libraries') diff --git a/core/libraries/ORM_MPTT.php b/core/libraries/ORM_MPTT.php index d7e8d7b7..2cdc617d 100644 --- a/core/libraries/ORM_MPTT.php +++ b/core/libraries/ORM_MPTT.php @@ -72,6 +72,14 @@ class ORM_MPTT_Core extends ORM { return $this; } + /** + * Deleted this node and adjust the left and right pointers + */ + public function delete() { + parent::delete(); + $this->_grow(-1); + } + /** * Return the parent of this node * @@ -194,7 +202,7 @@ class ORM_MPTT_Core extends ORM { * * @param integer $count the number of new nodes to add */ - private function _grow($count=1) { + public function _grow($count=1) { $size = $count * 2; $this->db->query( "UPDATE `{$this->table_name}` SET `left` = `left` + $size WHERE `left` >= {$this->right}"); -- cgit v1.2.3