From 0f103b1c069063a2e6109a0ba7e566104f4ba8fa Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 4 Dec 2008 20:05:58 +0000 Subject: Moving albums around with a drag and drop interface seems to work and preserve the left right pointers. * changed _lock and _unlock to protected methods lock and lock respectively * added a moveTo method on the Item_Model * Corrected the hole closure on delete. * added moveTo on the ORM_MTPP class * Changed the rearrange javascript to do moves with ajax --- core/models/item.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'core/models') diff --git a/core/models/item.php b/core/models/item.php index fbaca0e7..495508ec 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -52,6 +52,32 @@ class Item_Model extends ORM_MPTT { } } + /** + * Move this item to the specified target. + * + * @chainable + * @param Item_Model $target Target item (must be an album + * @return ORM_MTPP + */ + function moveTo($target) { + $this->lock(); + try { + $original_path = $this->file_path(); + + parent::moveTo($target, true); + + $new_path = $this->file_path(); + rename($original_path, $new_path); + + } catch (Exception $e) { + $this->unlock(); + throw $e; + } + + $this->unlock(); + return $this; + } + /** * album: /var/albums/album1/album2 * photo: /var/albums/album1/album2/photo.jpg -- cgit v1.2.3