From d6879bfe0c188b06f7b7730bb64af469d5c6e461 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 22 Jan 2009 22:38:10 +0000 Subject: Debug some of the subscriptions+tags problems --- classes/User.php | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'classes') diff --git a/classes/User.php b/classes/User.php index 5dadd6b44..5f4fb9b6f 100644 --- a/classes/User.php +++ b/classes/User.php @@ -575,4 +575,58 @@ class User extends Memcached_DataObject return $profile; } + + function getTaggedSubscribers($tag, $offset=0, $limit=null) + { + $qry = + 'SELECT profile.* ' . + 'FROM profile JOIN subscription ' . + 'ON profile.id = subscription.subscriber ' . + 'JOIN profile_tag ON (profile_tag.tagged = subscription.subscriber ' . + 'AND profile_tag.tagger = subscription.subscribed) ' . + 'WHERE subscription.subscribed = %d ' . + 'AND profile_tag.tag = "%s" ' . + 'AND subscription.subscribed != subscription.subscriber ' . + 'ORDER BY subscription.created DESC '; + + if ($offset) { + if (common_config('db','type') == 'pgsql') { + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; + } else { + $qry .= ' LIMIT ' . $offset . ', ' . $limit; + } + } + + $profile = new Profile(); + + $cnt = $profile->query(sprintf($qry, $this->id, $tag)); + + return $profile; + } + + function getTaggedSubscriptions($tag, $offset=0, $limit=null) + { + $qry = + 'SELECT profile.* ' . + 'FROM profile JOIN subscription ' . + 'ON profile.id = subscription.subscribed ' . + 'JOIN profile_tag on (profile_tag.tagged = subscription.subscribed ' . + 'AND profile_tag.tagger = subscription.subscriber) ' . + 'WHERE subscription.subscriber = %d ' . + 'AND profile_tag.tag = "%s" ' . + 'AND subscription.subscribed != subscription.subscriber ' . + 'ORDER BY subscription.created DESC '; + + if (common_config('db','type') == 'pgsql') { + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; + } else { + $qry .= ' LIMIT ' . $offset . ', ' . $limit; + } + + $profile = new Profile(); + + $profile->query(sprintf($qry, $this->id, $tag)); + + return $profile; + } } -- cgit v1.2.3-54-g00ecf