From: Michael J. Rubinsky Date: Tue, 10 Nov 2009 20:52:17 +0000 (-0500) Subject: throw exception from Ansel_View#getGallery X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=ab5caf1851243bec9787dc5c622980989400b4e7;p=horde.git throw exception from Ansel_View#getGallery Bug: 8699 --- diff --git a/ansel/lib/View/Base.php b/ansel/lib/View/Base.php index 43596c1c9..df8ec708b 100644 --- a/ansel/lib/View/Base.php +++ b/ansel/lib/View/Base.php @@ -49,6 +49,15 @@ abstract class Ansel_View_Base //throw new Horde_Exception(sprintf("The property %s of Ansel_View not found.", $property)); } + /** + * + * + * @param integer $galleryId The gallery id + * @param string $slug The gallery slug + * + * @return Ansel_Gallery The requested Ansel_Gallery object + * @throws Horde_Exception + */ public function &getGallery($galleryId = null, $slug = '') { if (is_null($galleryId) && empty($slug)) { @@ -57,7 +66,7 @@ abstract class Ansel_View_Base } if (empty($galleryId) && empty($slug)) { - return PEAR::raiseError(_("No gallery specified")); + throw new Horde_Exception(_("No gallery specified")); } // If we have a slug, use it. @@ -67,9 +76,9 @@ abstract class Ansel_View_Base $gallery = &$GLOBALS['ansel_storage']->getGallery($galleryId); } if (is_a($gallery, 'PEAR_Error')) { - return $gallery; + throw new Horde_Exception($gallery->getMessage()); } elseif (!$gallery->hasPermission(Horde_Auth::getAuth(), PERMS_READ)) { - return PEAR::raiseError(sprintf(_("Access denied to gallery \"%s\"."), $gallery->get('name'))); + throw new Horde_Exception(sprintf(_("Access denied to gallery \"%s\"."), $gallery->get('name'))); } /* Set any date info we might have */ diff --git a/ansel/lib/View/EmbeddedRenderer/GalleryLink.php b/ansel/lib/View/EmbeddedRenderer/GalleryLink.php index 973354e1c..13b119886 100644 --- a/ansel/lib/View/EmbeddedRenderer/GalleryLink.php +++ b/ansel/lib/View/EmbeddedRenderer/GalleryLink.php @@ -52,13 +52,14 @@ class Ansel_View_EmbeddedRenderer_GalleryLink extends Ansel_View_Gallery $this->_params['thumbsize']; foreach ($galleries as $identifier) { - if ($haveSlugs) { - $gallery = $this->getGallery(null, $identifier); - } else { - $gallery = $this->getGallery($identifier); - } - if (is_a($gallery, 'PEAR_Error')) { - Horde::logMessage($gallery, __FILE__, __LINE__, PEAR_LOG_ERR); + try { + if ($haveSlugs) { + $gallery = $this->getGallery(null, $identifier); + } else { + $gallery = $this->getGallery($identifier); + } + } catch (Horde_Exception $e) { + Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR); exit; } if (!$gallery->hasPermission(Horde_Auth::getAuth(), PERMS_READ)) { diff --git a/ansel/lib/View/EmbeddedRenderer/Mini.php b/ansel/lib/View/EmbeddedRenderer/Mini.php index b24b211f7..a24386276 100644 --- a/ansel/lib/View/EmbeddedRenderer/Mini.php +++ b/ansel/lib/View/EmbeddedRenderer/Mini.php @@ -48,9 +48,10 @@ class Ansel_View_EmbeddedRenderer_Mini extends Ansel_View_Gallery // galleries. $images = explode(':', $images); } else { - $this->gallery = $this->getGallery($gallery_id, $gallery_slug); - if (is_a($this->gallery, 'PEAR_Error')) { - Horde::logMessage($this->gallery, __FILE__, __LINE__, PEAR_LOG_ERR); + try { + $this->gallery = $this->getGallery($gallery_id, $gallery_slug); + } catch (Horde_Exception $e) { + Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR); exit; } diff --git a/ansel/lib/View/Gallery.php b/ansel/lib/View/Gallery.php index c798af8e6..0b0ef844b 100644 --- a/ansel/lib/View/Gallery.php +++ b/ansel/lib/View/Gallery.php @@ -81,9 +81,6 @@ class Ansel_View_Gallery extends Ansel_View_Base } else { $this->gallery = $this->getGallery(); } - if (is_a($this->gallery, 'PEAR_Error')) { - throw new Horde_Exception($this->gallery); - } // Check user age if (!$this->gallery->isOldEnough()) {