From 5571068444a57bf08d4634efb1aa4c928ad43591 Mon Sep 17 00:00:00 2001 From: colings Date: Sun, 9 Jan 2011 15:37:08 -0600 Subject: [PATCH] Fixed it so items will automatically be dirtied if you set a custom thumbnail size --- .../helpers/custom_albums_event.php | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/3.0/modules/custom_albums/helpers/custom_albums_event.php b/3.0/modules/custom_albums/helpers/custom_albums_event.php index 3564d410..2c864ba2 100644 --- a/3.0/modules/custom_albums/helpers/custom_albums_event.php +++ b/3.0/modules/custom_albums/helpers/custom_albums_event.php @@ -34,30 +34,48 @@ class custom_albums_event_Core { static function item_edit_form_completed($item, $form) { if ($item->is_album()) { - $thumbChanged = false; + $thumbDirty = false; + + $albumCustom = ORM::factory("custom_album")->where("album_id", "=", $item->id)->find(); if ($form->edit_item->custom_album->thumbsize->value == "") { - db::build() - ->delete("custom_album") - ->where("album_id", "=", $item->id) - ->execute(); + // The thumbnail size is empty. If there was something saved for this album before, delete + // it and mark the thumbnails as dirty. + if ($albumCustom->loaded()) { + db::build() + ->delete("custom_album") + ->where("album_id", "=", $item->id) + ->execute(); + + $thumbDirty = true; + } } else { - $albumCustom = ORM::factory("custom_album")->where("album_id", "=", $item->id)->find(); + // If we've never set a custom thumbnail size for this album, do it now if (!$albumCustom->loaded()) { $albumCustom->album_id = $item->id; - } - $albumCustom->thumb_size = $form->edit_item->custom_album->thumbsize->value; - $albumCustom->save(); + $albumCustom->thumb_size = $form->edit_item->custom_album->thumbsize->value; + $albumCustom->save(); - $thumbChanged = true; + $thumbDirty = true; + } else if ($albumCustom->thumb_size != $form->edit_item->custom_album->thumbsize->value) { + $albumCustom->thumb_size = $form->edit_item->custom_album->thumbsize->value; + $albumCustom->save(); + + $thumbDirty = true; + } } - if ($thumbChanged) { + if ($thumbDirty) { db::build() ->update("items") ->set("thumb_dirty", 1) ->where("parent_id", "=", $item->id) ->execute(); + + site_status::warning( + t('One or more of your photos are out of date. Fix this now on the maintenance page.', + array("url" => url::site("admin/maintenance/"))), + "graphics_dirty"); } } }