summaryrefslogtreecommitdiff
path: root/core/models/item.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/models/item.php')
-rw-r--r--core/models/item.php26
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
*/