summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-07-03 14:25:33 -0700
committerBharat Mediratta <bharat@menalto.com>2010-07-03 14:25:33 -0700
commit0d424a635d12eee59d2080fa7ffa32a248b0fd5c (patch)
tree473f5217179e61f853590449b1fa773d38c8ffe0 /modules/gallery/helpers
parent3feb561054a735e6959e894eb568aa386426bb65 (diff)
When we delete an item, make sure that we scrub it from any other
items that may have it in the album_cover_item_id column. Fixes ticket #1172.
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/gallery_event.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 82f42d98..40ea50fa 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -98,6 +98,15 @@ class gallery_event_Core {
static function item_deleted($item) {
access::delete_item($item);
+ // Find any other albums that had the deleted item as the album cover and null it out.
+ // In some cases this may leave us with a missing album cover up in this item's parent
+ // hierarchy, but in most cases it'll work out fine.
+ foreach (ORM::factory("item")
+ ->where("album_cover_item_id", "=", $item->id)
+ ->find_all() as $parent) {
+ item::remove_album_cover($parent);
+ }
+
$parent = $item->parent();
if (!$parent->album_cover_item_id) {
// Assume we deleted the album cover and pick a new one. Choosing the first photo in the