diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-01-22 22:38:10 +0000 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-01-22 22:38:10 +0000 |
commit | d6879bfe0c188b06f7b7730bb64af469d5c6e461 (patch) | |
tree | 3c85fbb8093001d5272a04cb4d1bf7c1751d061b /classes | |
parent | 04d498784ff1892607a3aee65d76104192fe4af2 (diff) |
Debug some of the subscriptions+tags problems
Diffstat (limited to 'classes')
-rw-r--r-- | classes/User.php | 54 |
1 files changed, 54 insertions, 0 deletions
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; + } } |