diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-01-24 05:14:44 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-01-24 05:14:44 +0000 |
commit | eed57674f99621e5354a13543067e9556eb9c6d0 (patch) | |
tree | 563795ae826ea1e1175bef94ceab722807718c6a /core/libraries | |
parent | 20cd5df3a374f035bddf71ddf2b75c533f05bfac (diff) |
Add move support. Use the move icon in the quick pane. You can't
move an item into its own hierarchy, or into an album where you don't
have edit permission.
Diffstat (limited to 'core/libraries')
-rw-r--r-- | core/libraries/ORM_MPTT.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/libraries/ORM_MPTT.php b/core/libraries/ORM_MPTT.php index e8411db0..e67478a7 100644 --- a/core/libraries/ORM_MPTT.php +++ b/core/libraries/ORM_MPTT.php @@ -103,6 +103,15 @@ class ORM_MPTT_Core extends ORM { } /** + * Return true if the target is descendant of this item. + * @param ORM $target + * @return boolean + */ + function is_descendant($target) { + return ($this->left <= $target->left && $this->right >= $target->right); + } + + /** * Return the parent of this node * * @return ORM @@ -203,6 +212,11 @@ class ORM_MPTT_Core extends ORM { throw new Exception("@todo INVALID_SOURCE root album"); } + if ($this->left <= $target->left && + $this->right >= $target->right) { + throw new Exception("@todo INVALID_TARGET can't move item inside itself"); + } + $number_to_move = (int)(($this->right - $this->left) / 2 + 1); $size_of_hole = $number_to_move * 2; $original_left = $this->left; |