summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/gallery_event.php
diff options
context:
space:
mode:
authorNathan Kinkade <nkinkade@nkinka.de>2010-05-13 01:49:54 +0000
committerNathan Kinkade <nkinkade@nkinka.de>2010-05-13 01:49:54 +0000
commita0b0b415515bff5f9edd43d373e8e78f3b3f8e4d (patch)
treea101f7a71a33f75c21d4ac828f442d902f5d8af9 /modules/gallery/helpers/gallery_event.php
parent104430e9e1e8dacd5e4320e29e59fc59aa5c6ee9 (diff)
parent9affa8ebbd539396d71f19003b91af577a8a183e (diff)
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/gallery/helpers/gallery_event.php')
-rw-r--r--modules/gallery/helpers/gallery_event.php11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index d723cc1b..2416f2e5 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -97,6 +97,17 @@ class gallery_event_Core {
static function item_deleted($item) {
access::delete_item($item);
+
+ $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
+ // album is logical, but it's not the most efficient in the case where we're deleting all
+ // the photos in the album one at a time since we'll probably delete them in order which
+ // means that we'll be resetting the album cover each time.
+ if ($child = $parent->children(1)->current()) {
+ item::make_album_cover($child);
+ }
+ }
}
static function item_moved($item, $old_parent) {