private function _getGallery()
{
// Make sure we haven't already selected a gallery.
if ($this->_gallery instanceof Ansel_Gallery) {
return $this->_gallery;
}
// Get the gallery object and cache it.
if (isset($this->_params['gallery']) && $this->_params['gallery'] != '__random') {
$this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_params['gallery']);
} else {
$this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRandomGallery();
}
if (empty($this->_gallery)) {
throw new Horde_Exception_NotFound(_("Gallery does not exist."));
} elseif (!$this->_gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
throw new Horde_Exception_PermissionDenied(_("Access denied viewing this gallery."));
}
// Return a reference to the gallery.
return $this->_gallery;
}