diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-11-05 07:47:19 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-11-05 07:47:19 +0000 |
commit | e44ff9bb6054f83d266a28f4e5418ff9b98a5b80 (patch) | |
tree | 2ff6b454d82542218ba0a160993ecc2466cbf958 | |
parent | d21f3437e64fb67f306eaec40e778e77176796ff (diff) |
ORM_MPTT::parents() should not include the node itself.
-rw-r--r-- | core/libraries/ORM_MPTT.php | 2 | ||||
-rw-r--r-- | core/models/item.php | 4 | ||||
-rw-r--r-- | core/tests/ORM_MPTT_Test.php | 2 |
3 files changed, 3 insertions, 5 deletions
diff --git a/core/libraries/ORM_MPTT.php b/core/libraries/ORM_MPTT.php index c8dd613b..3ce5e3e4 100644 --- a/core/libraries/ORM_MPTT.php +++ b/core/libraries/ORM_MPTT.php @@ -87,11 +87,11 @@ class ORM_MPTT_Core extends ORM { * @return array ORM */ function parents() { - $id = (int)$this->id; if (!isset($this->parents)) { $this->parents = $this ->where("`left` <= {$this->left}") ->where("`right` >= {$this->right}") + ->where("id <> {$this->id}") ->orderby("left", "ASC") ->find_all(); } diff --git a/core/models/item.php b/core/models/item.php index 265a9219..5ab3935c 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -35,10 +35,8 @@ class Item_Model extends ORM_MPTT { $paths[] = $parent->name; } } + $paths[] = $this->name; $path = implode($paths, "/"); - if (!$this->saved) { - $path .= $this->name; - } if ($tag) { $pi = pathinfo($path); diff --git a/core/tests/ORM_MPTT_Test.php b/core/tests/ORM_MPTT_Test.php index 208c199f..a543c1cd 100644 --- a/core/tests/ORM_MPTT_Test.php +++ b/core/tests/ORM_MPTT_Test.php @@ -50,7 +50,7 @@ class ORM_MPTT_Test extends Unit_Test_Case { foreach ($inner->parents() as $parent) { $parent_ids[] = $parent->id; } - $this->assert_equal(array(1, $outer->id, $inner->id), $parent_ids); + $this->assert_equal(array(1, $outer->id), $parent_ids); } public function children_test() { |