Fixed it so items will automatically be dirtied if you set a custom thumbnail size
This commit is contained in:
parent
5691ed9aaf
commit
5571068444
@ -34,30 +34,48 @@ class custom_albums_event_Core {
|
|||||||
|
|
||||||
static function item_edit_form_completed($item, $form) {
|
static function item_edit_form_completed($item, $form) {
|
||||||
if ($item->is_album()) {
|
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 == "") {
|
if ($form->edit_item->custom_album->thumbsize->value == "") {
|
||||||
|
// 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()
|
db::build()
|
||||||
->delete("custom_album")
|
->delete("custom_album")
|
||||||
->where("album_id", "=", $item->id)
|
->where("album_id", "=", $item->id)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
$thumbDirty = true;
|
||||||
|
}
|
||||||
} else {
|
} 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()) {
|
if (!$albumCustom->loaded()) {
|
||||||
$albumCustom->album_id = $item->id;
|
$albumCustom->album_id = $item->id;
|
||||||
}
|
|
||||||
$albumCustom->thumb_size = $form->edit_item->custom_album->thumbsize->value;
|
$albumCustom->thumb_size = $form->edit_item->custom_album->thumbsize->value;
|
||||||
$albumCustom->save();
|
$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()
|
db::build()
|
||||||
->update("items")
|
->update("items")
|
||||||
->set("thumb_dirty", 1)
|
->set("thumb_dirty", 1)
|
||||||
->where("parent_id", "=", $item->id)
|
->where("parent_id", "=", $item->id)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
site_status::warning(
|
||||||
|
t('One or more of your photos are out of date. Fix this now on <a href="%url">the maintenance page</a>.',
|
||||||
|
array("url" => url::site("admin/maintenance/"))),
|
||||||
|
"graphics_dirty");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user