summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorRobin Millette <millette@plantard.controlezvous.ca>2009-01-23 01:01:01 +0000
committerRobin Millette <millette@plantard.controlezvous.ca>2009-01-23 01:01:01 +0000
commit8a65c5175c3b734d4c53d6a3c3af51c5a645dff2 (patch)
tree6e85645d2e51d517f88413c119ddc4eed26f633b /classes
parent4a4efc3b0a453a0e345f4ec5bd8e970130589ae6 (diff)
parent1132e66f84c188f8267165d99d95d04047b6b23b (diff)
Merge branch 'master' of /var/www/trunk
Diffstat (limited to 'classes')
-rw-r--r--classes/Memcached_DataObject.php5
-rw-r--r--classes/User.php54
2 files changed, 55 insertions, 4 deletions
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php
index 97e1ed736..5f71f716b 100644
--- a/classes/Memcached_DataObject.php
+++ b/classes/Memcached_DataObject.php
@@ -218,10 +218,7 @@ class Memcached_DataObject extends DB_DataObject
}
$inst = new $cls();
- $result = $inst->query($qry);
- if (!$result) {
- return $inst;
- }
+ $inst->query($qry);
$cached = array();
while ($inst->fetch()) {
$cached[] = clone($inst);
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;
+ }
}