summaryrefslogtreecommitdiff
path: root/modules/gallery/models
diff options
context:
space:
mode:
authorRomain LE DISEZ <romain.git@ledisez.net>2009-07-18 17:51:23 +0200
committerRomain LE DISEZ <romain.git@ledisez.net>2009-07-18 17:51:23 +0200
commitc78744d4f8a0cfad7ca5aa3d2867fb66d4c6b8c4 (patch)
treee2b4d5d066590a966d949409cb48104456edaf7e /modules/gallery/models
parent7f5030ac208c30a7dc576a57cd9e665022ccbde5 (diff)
parentdf22832a5b7e7c1962940becab1c90aaec3392f9 (diff)
Merge commit 'upstream/master'
Diffstat (limited to 'modules/gallery/models')
-rw-r--r--modules/gallery/models/item.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 85b0c9a7..c7311081 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -93,6 +93,7 @@ class Item_Model extends ORM_MPTT {
}
public function delete() {
+ $old = clone $this;
module::event("item_before_delete", $this);
$parent = $this->parent();
@@ -114,13 +115,15 @@ class Item_Model extends ORM_MPTT {
@unlink($resize_path);
@unlink($thumb_path);
}
+
+ module::event("item_deleted", $old);
}
/**
* Move this item to the specified target.
* @chainable
- * @param Item_Model $target Target item (must be an album
- * @return ORM_MTPP
+ * @param Item_Model $target Target item (must be an album)
+ * @return ORM_MPTT
*/
function move_to($target) {
if (!$target->is_album()) {
@@ -134,8 +137,10 @@ class Item_Model extends ORM_MPTT {
$original_path = $this->file_path();
$original_resize_path = $this->resize_path();
$original_thumb_path = $this->thumb_path();
+ $original_parent = $this->parent();
parent::move_to($target, true);
+ model_cache::clear();
$this->relative_path_cache = null;
rename($original_path, $this->file_path());
@@ -151,6 +156,7 @@ class Item_Model extends ORM_MPTT {
@rename($original_thumb_path, $this->thumb_path());
}
+ module::event("item_moved", $this, $original_parent);
return $this;
}
@@ -347,9 +353,14 @@ class Item_Model extends ORM_MPTT {
$this->created = $this->updated;
$r = ORM::factory("item")->select("MAX(weight) as max_weight")->find();
$this->weight = $r->max_weight + 1;
+ $created = 1;
}
}
- return parent::save();
+ parent::save();
+ if (!isset($created)) {
+ module::event("item_updated", $this);
+ }
+ return $this;
}
/**