diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Feed/Pubsubhubbub/Model/Subscription.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Feed/Pubsubhubbub/Model/Subscription.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,135 @@ +_db->find($data['id']); + if (count($result)) { + $data['created_time'] = $result->current()->created_time; + $now = new Zend_Date; + if (isset($data['lease_seconds'])) { + $data['expiration_time'] = $now->add($data['lease_seconds'], Zend_Date::SECOND) + ->get('yyyy-MM-dd HH:mm:ss'); + } + $this->_db->update( + $data, + $this->_db->getAdapter()->quoteInto('id = ?', $data['id']) + ); + return false; + } + + $this->_db->insert($data); + return true; + } + + /** + * Get subscription by ID/key + * + * @param string $key + * @return array + */ + public function getSubscription($key) + { + if (empty($key) || !is_string($key)) { + require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; + throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "key"' + .' of "' . $key . '" must be a non-empty string'); + } + $result = $this->_db->find($key); + if (count($result)) { + return $result->current()->toArray(); + } + return false; + } + + /** + * Determine if a subscription matching the key exists + * + * @param string $key + * @return bool + */ + public function hasSubscription($key) + { + if (empty($key) || !is_string($key)) { + require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; + throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "key"' + .' of "' . $key . '" must be a non-empty string'); + } + $result = $this->_db->find($key); + if (count($result)) { + return true; + } + return false; + } + + /** + * Delete a subscription + * + * @param string $key + * @return bool + */ + public function deleteSubscription($key) + { + $result = $this->_db->find($key); + if (count($result)) { + $this->_db->delete( + $this->_db->getAdapter()->quoteInto('id = ?', $key) + ); + return true; + } + return false; + } + +}