diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-04-29 00:40:59 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-04-29 00:40:59 +0000 |
commit | 0d49773559160120768d33b574f97d9b6b993a3d (patch) | |
tree | cfa4d918600b2d09f7f760834cff9e2c038abe57 | |
parent | 9176dadfd69c15d9f16581d119569a7745c53067 (diff) |
Reset the parent thumbnail in Item_Model::delete instead of where the
delete was happening. This will insure that it is consistently done
for all deletes and we don't have to remember to replicate the code.
-rw-r--r-- | core/controllers/quick.php | 8 | ||||
-rw-r--r-- | core/models/item.php | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/core/controllers/quick.php b/core/controllers/quick.php index 32febb31..cb43a50f 100644 --- a/core/controllers/quick.php +++ b/core/controllers/quick.php @@ -106,20 +106,12 @@ class Quick_Controller extends Controller { $item = ORM::factory("item", $id); access::required("edit", $item); - $parent = $item->parent(); - if ($item->is_album()) { $msg = t("Deleted album <b>%title</b>", array("title" => $item->title)); } else { $msg = t("Deleted photo <b>%title</b>", array("title" => $item->title)); } - if ($parent->album_cover_item_id == $item->id) { - // @todo change the album cover to some other random image inside the album - $parent->album_cover_item_id = null; - $parent->save(); - } - $item->delete(); message::success($msg); diff --git a/core/models/item.php b/core/models/item.php index f529a471..34b8a8dd 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -95,6 +95,14 @@ class Item_Model extends ORM_MPTT { public function delete() { module::event("item_before_delete", $this); + $parent = $this->parent(); + + if ($parent->album_cover_item_id == $this->id) { + // @todo change the album cover to some other random image inside the album + $parent->album_cover_item_id = null; + $parent->save(); + } + $original_path = $this->file_path(); $original_resize_path = $this->resize_path(); $original_thumb_path = $this->thumb_path(); |