public function add() { if (is_null($this->created)) { $this->created = Timestamp::getUNIXTime(); } if (!$this->validate()) { return false; } $this->setAttribute('id', $this->id); $this->setAttribute('blogid', $this->blogid); $this->setAttribute('category', $this->category, true); $this->setAttribute('root', $this->root, true); $this->setAttribute('author', $this->author, true); $this->setAttribute('content', $this->content, true); $this->setAttribute('permalink', $this->permalink, true); $this->setAttribute('created', $this->created); return $this->insert(); }
function getLinesFeed($blogid, $category = 'public', $mode = 'atom') { global $blog; $channel = array(); $channel = initializeRSSchannel($blogid); $lineobj = Model_Line::getInstance(); $lineobj->reset(); $lineobj->setFilter(array('created', 'bigger', Timestamp::getUNIXTime() - 86400)); $lineobj->setFilter(array('blogid', 'equals', $blogid)); $lineobj->setFilter(array('category', 'equals', $category, true)); $lines = $lineobj->get(); $channel['items'] = getFeedItemByLines($lines); $channel['title'] = RSSMessage($blog['title'] . ': ' . _text('Lines')); $rss = array('channel' => $channel); if ($mode == 'rss') { return publishRSS($blogid, $rss); } else { if ($mode == 'atom') { return publishATOM($blogid, $rss); } } return false; }
function update($openid, $delegatedid, $nickname, $homepage = null) { $context = Model_Context::getInstance(); $pool = DBModel::getInstance(); $pool->reset('OpenIDUsers'); $pool->setQualifier('openid', 'equals', $openid, true); $result = $pool->getCell('openidinfo'); if (is_null($result)) { $data = serialize(array('nickname' => $nickname, 'homepage' => $homepage)); OpenIDConsumer::setUserInfo($nickname, $homepage); /* Owner column is used for reference, all openid records are shared */ $pool->reset('OpenIDUsers'); $pool->setAttribute('blogid', $context->getProperty('blog.id')); $pool->setAttribute('openid', $openid, true); $pool->setAttribute('delegatedid', $deligatedid, true); $pool->setAttribute('firstlogin', Timestamp::getUNIXTime()); $pool->setAttribute('lastlogin', Timestamp::getUNIXTime()); $pool->setAttribute('logincount', 1); $pool->setAttribute('openidinfo', $data, true); $pool->insert(); } else { $data = unserialize($result); if (!empty($nickname)) { $data['nickname'] = $nickname; } if (!empty($homepage)) { $data['homepage'] = $homepage; } OpenIDConsumer::setUserInfo($data['nickname'], $data['homepage']); $data = serialize($data); $pool->reset('OpenIDUsers'); $pool->setQualifier('openid', 'equals', $openid, true); $lastcount = $pool->getCell('logincount'); $pool->reset('OpenIDUsers'); $pool->setAttribute('openidinfo', $data, true); $pool->setAttribute('lastlogin', Timestamp::getUNIXTime()); $pool->setAttribute('logincount', $lastcount + 1); $pool->setQualifier('openid', 'equals', $openid, true); $pool->update(); } return; }