} 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"),
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);
}
/**
+ * 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.
if ($cnt == 1) {
/* Count is 1, and we are about to delete it */
$reset_has_subgalleries = true;
+ if (!$old->countImages()) {
+ $old->resetKeyImage();
+ }
}
}
$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');