summaryrefslogtreecommitdiff
path: root/classes/User.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-09-16 13:44:00 -0400
committerEvan Prodromou <evan@prodromou.name>2008-09-16 13:44:00 -0400
commit4476a4286f012bc72b274133203c6a9c1a6c00b3 (patch)
tree5f9632bd47fb19870c7c9492bde8274e2aae35e7 /classes/User.php
parent2c65a44e2c13cc30bc004a38ab8ca1d74ef4f040 (diff)
rationalize with repository version
darcs-hash:20080916174400-84dde-63781c5cd6a7c9a3dbc765dfa15084e3372effd5.gz
Diffstat (limited to 'classes/User.php')
-rw-r--r--classes/User.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/classes/User.php b/classes/User.php
index 62f077739..84a980db4 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -153,6 +153,52 @@ class User extends DB_DataObject
return $notice;
}
+
+ function favoriteNotices($offset=0, $limit=20) {
+
+ $notice = new Notice();
+
+ $notice->query('SELECT notice.* ' .
+ 'FROM notice JOIN fave on notice.id = fave.notice_id ' .
+ 'WHERE fave.user_id = ' . $this->id . ' ' .
+ 'ORDER BY notice.created DESC, notice.id DESC ' .
+ 'LIMIT ' . $offset . ', ' . $limit);
+
+ return $notice;
+ }
+
+ function noticesWithFriendsWindow() {
+
+ $cache = new Memcache();
+ $res = $cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'));
+
+ if (!$res) {
+ return NULL;
+ }
+
+ $notices = $cache->get(common_cache_key('user:notices_with_friends:' . $this->id));
+
+ if ($notices) {
+ return $notices;
+ }
+
+ $notice = new Notice();
+
+ $notice->query('SELECT notice.* ' .
+ 'FROM notice JOIN subscription on notice.profile_id = subscription.subscribed ' .
+ 'WHERE subscription.subscriber = ' . $this->id . ' ' .
+ 'ORDER BY created DESC, notice.id DESC ' .
+ 'LIMIT 0, ' . WITHFRIENDS_CACHE_WINDOW);
+
+ $notices = array();
+
+ while ($notice->fetch()) {
+ $notices[] = clone($notice);
+ }
+
+ $cache->set(common_cache_key('user:notices_with_friends:' . $this->id), $notices);
+ return $notices;
+ }
static function register($fields) {