From 64ed01f0aff569da2fd4ed589df9ed4ee9852cb7 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 22 Jul 2008 12:02:13 -0400 Subject: centralize and optimize with-friends query darcs-hash:20080722160213-84dde-2e466b9cc4601a8cb7237770a7df17a2f9dcadb9.gz --- classes/User.php | 19 +++++++++++++++++++ classes/stoica.links.ini | 3 +++ 2 files changed, 22 insertions(+) (limited to 'classes') diff --git a/classes/User.php b/classes/User.php index e4928eb34..1772b82e0 100644 --- a/classes/User.php +++ b/classes/User.php @@ -128,4 +128,23 @@ class User extends DB_DataObject return true; } + + function noticesWithFriends() { + + $notice = new Notice(); + + $notice->selectAs(); + + $subscription = new Subscription(); + + $subscription->subscriber = $this->id; + + $notice->joinAdd($subscription); + $notice->whereAdd('notice.profile_id = subscription.subscribed'); + $notice->selectAs($subscription, 'sub_%'); + + $notice->orderBy('created DESC, notice.id DESC'); + + return $notice; + } } diff --git a/classes/stoica.links.ini b/classes/stoica.links.ini index 7e4e3613c..bb849cbf2 100644 --- a/classes/stoica.links.ini +++ b/classes/stoica.links.ini @@ -34,3 +34,6 @@ user_id = user:id [queue_item] notice_id = notice:id +[subscription] +subscriber = profile:id +subscribed = profile:id -- cgit v1.2.3-54-g00ecf