//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)) {
}
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.
$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 */
$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)) {
// 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;
}
} 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()) {