From: Michael J. Rubinsky Date: Thu, 9 Sep 2010 14:27:26 +0000 (-0400) Subject: More thorough checks for when we need to reset/remove a key image. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0f5fc56d126e237c05adf339174b95e67e1aa633;p=horde.git More thorough checks for when we need to reset/remove a key image. --- diff --git a/ansel/gallery/delete.php b/ansel/gallery/delete.php index 9befd25e9..778b2e552 100644 --- a/ansel/gallery/delete.php +++ b/ansel/gallery/delete.php @@ -32,9 +32,7 @@ if ($galleryId) { } else { try { $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($gallery); - $notification->push(sprintf( - _("Successfully deleted %s."), - $gallery->get('name')), 'horde.success'); + $notification->push(sprintf(_("Successfully deleted %s."), $gallery->get('name')), 'horde.success'); } catch (Ansel_Exception $e) { $notification->push(sprintf( _("There was a problem deleting %s: %s"), diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index 99225fb92..5e4da3ba5 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -165,6 +165,11 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical throw Ansel_Exception($e); } + /* Make sure we get rid of key image/stacks if no more images */ + if (!$this->data['attribute_images']) { + $this->resetKeyImage(); + } + /* Need to expire the cache for the gallery that was changed */ if ($GLOBALS['conf']['ansel_cache']['usecache']) { $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $this->id); @@ -334,6 +339,19 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical } /** + * Reset the gallery's key image. This will force Ansel to attempt to fetch + * a new key image the next time one is requested. + * + */ + public function resetKeyImage() + { + $this->clearStacks(); + $this->set('default', 0); + $this->set('default_type', 'auto'); + $this->save(); + } + + /** * Move images from this gallery to a new gallery. * * @param array $images An array of image ids. @@ -835,6 +853,9 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical if ($cnt == 1) { /* Count is 1, and we are about to delete it */ $reset_has_subgalleries = true; + if (!$old->countImages()) { + $old->resetKeyImage(); + } } } diff --git a/ansel/lib/View/GalleryRenderer/Gallery.php b/ansel/lib/View/GalleryRenderer/Gallery.php index 8ab7e0503..db63dd96b 100644 --- a/ansel/lib/View/GalleryRenderer/Gallery.php +++ b/ansel/lib/View/GalleryRenderer/Gallery.php @@ -91,10 +91,6 @@ class Ansel_View_GalleryRenderer_Gallery extends Ansel_View_GalleryRenderer_Base $pager = new Horde_Core_Ui_Pager('page', $vars, $params); - // Note that we can't use Horde_Util::bufferOutput() here since the - // include file would be included inside that method's scope, and not - // this one. - //ob_start(); Horde::startBuffer(); if (!empty($this->view->api)) { $includes = $GLOBALS['injector']->createInstance('Horde_Script_Files');