diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2008-12-04 20:05:58 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2008-12-04 20:05:58 +0000 |
commit | 0f103b1c069063a2e6109a0ba7e566104f4ba8fa (patch) | |
tree | 8b7e26b0ef3650a6b90c0b9602da6b37bf3437f3 /core/models | |
parent | 80a7db61c9fba53477c1ec0850bdffaf7b11657a (diff) |
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
Diffstat (limited to 'core/models')
-rw-r--r-- | core/models/item.php | 26 |
1 files changed, 26 insertions, 0 deletions
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 @@ -53,6 +53,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 */ |