/** * Retrieve an Ansel_Gallery given the share id * * @param integer $gallery_id The gallery_id to fetch * @param array $overrides An array of attributes that should be * overridden when the gallery is returned. * * @return Ansel_Gallery * @throws Ansel_Exception */ public function getGallery($gallery_id, array $overrides = array()) { if (!count($overrides) && $GLOBALS['conf']['ansel_cache']['usecache'] && ($gallery = $GLOBALS['injector']->getInstance('Horde_Cache')->get('Ansel_Gallery' . $gallery_id, $GLOBALS['conf']['cache']['default_lifetime'])) !== false) { if ($cached_gallery = unserialize($gallery)) { return $cached_gallery; } } try { $result = $this->buildGallery($this->_shares->getShareById($gallery_id)); } catch (Horde_Share_Exception $e) { throw new Ansel_Exception($e); } catch (Horde_Exception_NotFound $e) { throw new Ansel_Exception($e); } // Don't cache if we have overridden anything if (!count($overrides)) { if ($GLOBALS['conf']['ansel_cache']['usecache']) { $GLOBALS['injector']->getInstance('Horde_Cache')->set('Ansel_Gallery' . $gallery_id, serialize($result)); } } else { foreach ($overrides as $key => $value) { $result->set($key, $value, false); } } return $result; }
/** * @param Whups_Query $query The query to delete. */ public function delete(Whups_Query $query) { if (!$query->id) { // Queries that aren't saved yet shouldn't be able to be deleted. return; } try { $share = $this->_shareManager->getShareById($query->id); $this->_shareManager->removeShare($share); } catch (Exception $e) { throw new Whups_Exception($e); } $GLOBALS['whups_driver']->deleteQuery($query->id); }