From 07f5797f2fd1a425027190d424e359a1b4c4c8be Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 17 Jun 2009 15:04:57 -0700 Subject: Make the personal tag streams actually work --- classes/Profile.php | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'classes/Profile.php') diff --git a/classes/Profile.php b/classes/Profile.php index 4a459b974..2f432ae8e 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -153,18 +153,16 @@ class Profile extends Memcached_DataObject return null; } - function getTaggedNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null, $tag=null) + function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, $since=null) { - // XXX: I'm not sure this is going to be any faster. It probably isn't. $ids = Notice::stream(array($this, '_streamTaggedDirect'), - array(), - 'profile:notice_ids:' . $this->id, - $offset, $limit, $since_id, $before_id, $since, $tag); - common_debug(print_r($ids, true)); + array($tag), + 'profile:notice_ids_tagged:' . $this->id . ':' . $tag, + $offset, $limit, $since_id, $max_id, $since); return Notice::getStreamByIds($ids); } - function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) + function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, $since=null) { // XXX: I'm not sure this is going to be any faster. It probably isn't. $ids = Notice::stream(array($this, '_streamDirect'), @@ -175,18 +173,23 @@ class Profile extends Memcached_DataObject return Notice::getStreamByIds($ids); } - function _streamTaggedDirect($offset, $limit, $since_id, $before_id, $since=null, $tag=null) + function _streamTaggedDirect($tag, $offset, $limit, $since_id, $max_id, $since) { - common_debug('_streamTaggedDirect()'); + // XXX It would be nice to do this without a join + $notice = new Notice(); - $notice->profile_id = $this->id; - $query = "select id from notice join notice_tag on id=notice_id where tag='" . $notice->escape($tag) . "' and profile_id=" . $notice->escape($notice->profile_id); + + $query = + "select id from notice join notice_tag on id=notice_id where tag='". + $notice->escape($tag) . + "' and profile_id=" . $notice->escape($this->id); + if ($since_id != 0) { $query .= " and id > $since_id"; } - if ($before_id != 0) { - $query .= " and id < $before_id"; + if ($max_id != 0) { + $query .= " and id < $max_id"; } if (!is_null($since)) { @@ -198,21 +201,19 @@ class Profile extends Memcached_DataObject if (!is_null($offset)) { $query .= " limit $offset, $limit"; } + $notice->query($query); + $ids = array(); while ($notice->fetch()) { - common_debug(print_r($notice, true)); $ids[] = $notice->id; } return $ids; } - - - - function _streamDirect($offset, $limit, $since_id, $before_id, $since = null) + function _streamDirect($offset, $limit, $since_id, $max_id, $since = null) { $notice = new Notice(); -- cgit v1.2.3-54-g00ecf From 793a6a1155996a7bcdc068fc891e7063934bdb19 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 20 Jun 2009 16:00:04 -0700 Subject: change Controlez-Vous to Control Yourself --- actions/accesstoken.php | 2 +- actions/all.php | 2 +- actions/allrss.php | 2 +- actions/api.php | 2 +- actions/avatarbynickname.php | 2 +- actions/block.php | 2 +- actions/disfavor.php | 2 +- actions/doc.php | 2 +- actions/facebookhome.php | 2 +- actions/facebookinvite.php | 2 +- actions/facebooklogin.php | 2 +- actions/facebookremove.php | 2 +- actions/facebooksettings.php | 2 +- actions/favor.php | 2 +- actions/favoritesrss.php | 2 +- actions/file.php | 2 +- actions/finishopenidlogin.php | 2 +- actions/finishremotesubscribe.php | 2 +- actions/foaf.php | 2 +- actions/groupblock.php | 2 +- actions/groupsearch.php | 2 +- actions/groupunblock.php | 2 +- actions/invite.php | 2 +- actions/logout.php | 2 +- actions/makeadmin.php | 2 +- actions/microsummary.php | 2 +- actions/noticesearch.php | 2 +- actions/noticesearchrss.php | 2 +- actions/nudge.php | 2 +- actions/openidlogin.php | 2 +- actions/opensearch.php | 2 +- actions/peoplesearch.php | 2 +- actions/postnotice.php | 2 +- actions/publicrss.php | 2 +- actions/publicxrds.php | 2 +- actions/recoverpassword.php | 2 +- actions/remotesubscribe.php | 2 +- actions/repliesrss.php | 2 +- actions/requesttoken.php | 2 +- actions/subedit.php | 2 +- actions/subscribe.php | 2 +- actions/sup.php | 2 +- actions/tag.php | 2 +- actions/tagother.php | 2 +- actions/tagrss.php | 2 +- actions/twitapiaccount.php | 2 +- actions/twitapiblocks.php | 2 +- actions/twitapidirect_messages.php | 2 +- actions/twitapifavorites.php | 2 +- actions/twitapifriendships.php | 2 +- actions/twitapihelp.php | 2 +- actions/twitapinotifications.php | 2 +- actions/twitapistatuses.php | 2 +- actions/twitapiusers.php | 2 +- actions/unblock.php | 2 +- actions/unsubscribe.php | 2 +- actions/updateprofile.php | 2 +- actions/userauthorization.php | 2 +- actions/userbyid.php | 2 +- actions/userrss.php | 2 +- actions/xrds.php | 2 +- classes/File.php | 2 +- classes/File_oembed.php | 2 +- classes/File_redirection.php | 2 +- classes/File_thumbnail.php | 2 +- classes/File_to_post.php | 2 +- classes/Group_block.php | 2 +- classes/Memcached_DataObject.php | 2 +- classes/Notice.php | 2 +- classes/Notice_tag.php | 2 +- classes/Profile.php | 2 +- classes/Profile_block.php | 2 +- classes/Remote_profile.php | 2 +- classes/Subscription.php | 2 +- index.php | 2 +- install.php | 2 +- lib/Shorturl_api.php | 2 +- lib/arraywrapper.php | 2 +- lib/channel.php | 2 +- lib/clienterroraction.php | 2 +- lib/command.php | 2 +- lib/commandinterpreter.php | 2 +- lib/common.php | 2 +- lib/daemon.php | 2 +- lib/dberroraction.php | 2 +- lib/error.php | 2 +- lib/facebookutil.php | 2 +- lib/galleryaction.php | 2 +- lib/oauthstore.php | 2 +- lib/omb.php | 2 +- lib/openid.php | 2 +- lib/peoplesearchresults.php | 2 +- lib/queuehandler.php | 2 +- lib/search_engines.php | 2 +- lib/searchaction.php | 2 +- lib/servererroraction.php | 2 +- lib/subs.php | 2 +- lib/twitter.php | 2 +- lib/twitterapi.php | 2 +- lib/util.php | 2 +- lib/xmppqueuehandler.php | 2 +- scripts/enjitqueuehandler.php | 2 +- scripts/facebookqueuehandler.php | 2 +- scripts/fixup_hashtags.php | 2 +- scripts/fixup_inboxes.php | 2 +- scripts/fixup_notices_rendered.php | 2 +- scripts/fixup_replies.php | 2 +- scripts/getpiddir.php | 2 +- scripts/getvaliddaemons.php | 2 +- scripts/inbox_users.php | 2 +- scripts/jabberqueuehandler.php | 2 +- scripts/maildaemon.php | 2 +- scripts/ombqueuehandler.php | 2 +- scripts/pingqueuehandler.php | 2 +- scripts/publicqueuehandler.php | 2 +- scripts/setpassword.php | 2 +- scripts/smsqueuehandler.php | 2 +- scripts/sphinx-cron.sh | 2 +- scripts/sphinx-indexer.sh | 2 +- scripts/startdaemons.sh | 2 +- scripts/stopdaemons.sh | 2 +- scripts/synctwitterfriends.php | 2 +- scripts/twitterqueuehandler.php | 2 +- scripts/twitterstatusfetcher.php | 2 +- scripts/uncache_users.php | 2 +- scripts/xmppconfirmhandler.php | 2 +- scripts/xmppdaemon.php | 2 +- 127 files changed, 127 insertions(+), 127 deletions(-) (limited to 'classes/Profile.php') diff --git a/actions/accesstoken.php b/actions/accesstoken.php index 46b43c702..01aa77574 100644 --- a/actions/accesstoken.php +++ b/actions/accesstoken.php @@ -12,7 +12,7 @@ * @link http://laconi.ca/ * * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, Controlez-Vous, Inc. + * Copyright (C) 2008, Control Yourself, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/actions/all.php b/actions/all.php index 80fc9d54b..f436fabd1 100644 --- a/actions/all.php +++ b/actions/all.php @@ -1,7 +1,7 @@ Date: Sat, 20 Jun 2009 16:12:55 -0700 Subject: Update copyright dates in files modified in 2009 --- actions/accesstoken.php | 2 +- actions/all.php | 2 +- actions/allrss.php | 2 +- actions/api.php | 2 +- actions/avatarbynickname.php | 2 +- actions/block.php | 2 +- actions/disfavor.php | 2 +- actions/doc.php | 2 +- actions/facebookhome.php | 2 +- actions/facebookinvite.php | 2 +- actions/facebooklogin.php | 2 +- actions/facebookremove.php | 2 +- actions/facebooksettings.php | 2 +- actions/favor.php | 2 +- actions/favoritesrss.php | 2 +- actions/file.php | 2 +- actions/finishopenidlogin.php | 2 +- actions/finishremotesubscribe.php | 2 +- actions/foaf.php | 2 +- actions/groupblock.php | 2 +- actions/groupsearch.php | 2 +- actions/groupunblock.php | 2 +- actions/invite.php | 2 +- actions/logout.php | 2 +- actions/makeadmin.php | 2 +- actions/microsummary.php | 2 +- actions/noticesearch.php | 2 +- actions/noticesearchrss.php | 2 +- actions/nudge.php | 2 +- actions/openidlogin.php | 2 +- actions/opensearch.php | 2 +- actions/peoplesearch.php | 2 +- actions/postnotice.php | 2 +- actions/publicrss.php | 2 +- actions/publicxrds.php | 2 +- actions/recoverpassword.php | 2 +- actions/remotesubscribe.php | 2 +- actions/repliesrss.php | 2 +- actions/requesttoken.php | 2 +- actions/subedit.php | 2 +- actions/subscribe.php | 2 +- actions/sup.php | 2 +- actions/tag.php | 2 +- actions/tagother.php | 2 +- actions/tagrss.php | 2 +- actions/twitapiaccount.php | 2 +- actions/twitapiblocks.php | 2 +- actions/twitapidirect_messages.php | 2 +- actions/twitapifavorites.php | 2 +- actions/twitapifriendships.php | 2 +- actions/twitapihelp.php | 2 +- actions/twitapinotifications.php | 2 +- actions/twitapistatuses.php | 2 +- actions/twitapiusers.php | 2 +- actions/unblock.php | 2 +- actions/unsubscribe.php | 2 +- actions/updateprofile.php | 2 +- actions/userauthorization.php | 2 +- actions/userbyid.php | 2 +- actions/userrss.php | 2 +- actions/xrds.php | 2 +- classes/File.php | 2 +- classes/File_oembed.php | 2 +- classes/File_redirection.php | 2 +- classes/File_thumbnail.php | 2 +- classes/File_to_post.php | 2 +- classes/Group_block.php | 2 +- classes/Memcached_DataObject.php | 2 +- classes/Notice.php | 2 +- classes/Notice_tag.php | 2 +- classes/Profile.php | 2 +- classes/Profile_block.php | 2 +- classes/Remote_profile.php | 2 +- classes/Subscription.php | 2 +- index.php | 2 +- lib/Shorturl_api.php | 2 +- lib/arraywrapper.php | 2 +- lib/channel.php | 2 +- lib/clienterroraction.php | 2 +- lib/command.php | 2 +- lib/commandinterpreter.php | 2 +- lib/common.php | 2 +- lib/daemon.php | 2 +- lib/dberroraction.php | 2 +- lib/error.php | 2 +- lib/facebookutil.php | 2 +- lib/galleryaction.php | 2 +- lib/oauthstore.php | 2 +- lib/omb.php | 2 +- lib/openid.php | 2 +- lib/peoplesearchresults.php | 2 +- lib/queuehandler.php | 2 +- lib/search_engines.php | 2 +- lib/searchaction.php | 2 +- lib/servererroraction.php | 2 +- lib/subs.php | 2 +- lib/twitter.php | 2 +- lib/twitterapi.php | 2 +- lib/util.php | 2 +- lib/xmppqueuehandler.php | 2 +- scripts/enjitqueuehandler.php | 2 +- scripts/facebookqueuehandler.php | 2 +- scripts/fixup_hashtags.php | 2 +- scripts/fixup_inboxes.php | 2 +- scripts/fixup_notices_rendered.php | 2 +- scripts/fixup_replies.php | 2 +- scripts/getpiddir.php | 2 +- scripts/getvaliddaemons.php | 2 +- scripts/inbox_users.php | 2 +- scripts/jabberqueuehandler.php | 2 +- scripts/maildaemon.php | 2 +- scripts/ombqueuehandler.php | 2 +- scripts/pingqueuehandler.php | 2 +- scripts/publicqueuehandler.php | 2 +- scripts/setpassword.php | 2 +- scripts/smsqueuehandler.php | 2 +- scripts/sphinx-cron.sh | 2 +- scripts/sphinx-indexer.sh | 2 +- scripts/startdaemons.sh | 2 +- scripts/stopdaemons.sh | 2 +- scripts/synctwitterfriends.php | 2 +- scripts/twitterqueuehandler.php | 2 +- scripts/twitterstatusfetcher.php | 2 +- scripts/uncache_users.php | 2 +- scripts/xmppconfirmhandler.php | 2 +- scripts/xmppdaemon.php | 2 +- 126 files changed, 126 insertions(+), 126 deletions(-) (limited to 'classes/Profile.php') diff --git a/actions/accesstoken.php b/actions/accesstoken.php index 01aa77574..2a8cd1713 100644 --- a/actions/accesstoken.php +++ b/actions/accesstoken.php @@ -12,7 +12,7 @@ * @link http://laconi.ca/ * * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, Control Yourself, Inc. + * Copyright (C) 2008, 2009, Control Yourself, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/actions/all.php b/actions/all.php index f436fabd1..f06ead2a8 100644 --- a/actions/all.php +++ b/actions/all.php @@ -1,7 +1,7 @@ Date: Thu, 25 Jun 2009 23:00:46 -0700 Subject: break up big inbox queries into lots of small ones --- classes/Group_inbox.php | 6 +++ classes/Notice.php | 112 ++++++++++++++++++++++++++++++++--------------- classes/Notice_inbox.php | 1 + classes/Profile.php | 48 ++++++++++++++++++++ classes/User.php | 46 +++---------------- classes/User_group.php | 24 ++++++++++ 6 files changed, 161 insertions(+), 76 deletions(-) (limited to 'classes/Profile.php') diff --git a/classes/Group_inbox.php b/classes/Group_inbox.php index b80ba4272..1af7439f7 100644 --- a/classes/Group_inbox.php +++ b/classes/Group_inbox.php @@ -14,8 +14,14 @@ class Group_inbox extends Memcached_DataObject public $created; // datetime() not_null /* Static get */ + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Group_inbox',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + function &pkeyGet($kv) + { + return Memcached_DataObject::pkeyGet('Group_inbox', $kv); + } } diff --git a/classes/Notice.php b/classes/Notice.php index 5bcfa896e..fdcef1bc2 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -832,24 +832,60 @@ class Notice extends Memcached_DataObject $enabled = common_config('inboxes', 'enabled'); if ($enabled === true || $enabled === 'transitional') { - $inbox = new Notice_inbox(); - $UT = common_config('db','type')=='pgsql'?'"user"':'user'; - $qry = 'INSERT INTO notice_inbox (user_id, notice_id, created) ' . - "SELECT $UT.id, " . $this->id . ", '" . $this->created . "' " . - "FROM $UT JOIN subscription ON $UT.id = subscription.subscriber " . - 'WHERE subscription.subscribed = ' . $this->profile_id . ' ' . - 'AND NOT EXISTS (SELECT user_id, notice_id ' . - 'FROM notice_inbox ' . - "WHERE user_id = $UT.id " . - 'AND notice_id = ' . $this->id . ' )'; - if ($enabled === 'transitional') { - $qry .= " AND $UT.inboxed = 1"; + + $users = $this->getSubscribedUsers(); + + // FIXME: kind of ignoring 'transitional'... + // we'll probably stop supporting inboxless mode + // in 0.9.x + + foreach ($users as $id) { + $this->addToUserInbox($id, NOTICE_INBOX_SOURCE_SUB); } - $inbox->query($qry); } + return; } + function getSubscribedUsers() + { + $user = new User(); + + $qry = + 'SELECT id ' . + 'FROM user JOIN subscription '. + 'ON user.id = subscription.subscriber ' . + 'WHERE subscription.subscribed = %d '; + + $user->query(sprintf($qry, $this->profile_id)); + + $ids = array(); + + while ($user->fetch()) { + $ids[] = $user->id; + } + + $user->free(); + + return $ids; + } + + function addToUserInbox($user_id, $source) + { + $inbox = Notice_inbox::pkeyGet(array('user_id' => $user_id, + 'notice_id' => $this->id)); + if (empty($inbox)) { + $inbox = new Notice_inbox(); + $inbox->user_id = $user_id; + $inbox->notice_id = $this->id; + $inbox->source = $source; + $inbox->created = $this->created; + return $inbox->insert(); + } + + return true; + } + function saveGroups() { $enabled = common_config('inboxes', 'enabled'); @@ -888,13 +924,7 @@ class Notice extends Memcached_DataObject if ($profile->isMember($group)) { - $gi = new Group_inbox(); - - $gi->group_id = $group->id; - $gi->notice_id = $this->id; - $gi->created = common_sql_now(); - - $result = $gi->insert(); + $result = $this->addToGroupInbox($group); if (!$result) { common_log_db_error($gi, 'INSERT', __FILE__); @@ -902,27 +932,37 @@ class Notice extends Memcached_DataObject // FIXME: do this in an offline daemon - $this->addToGroupInboxes($group); + $this->addToGroupMemberInboxes($group); } } } - function addToGroupInboxes($group) + function addToGroupInbox($group) + { + $gi = Group_inbox::pkeyGet(array('group_id' => $group->id, + 'notice_id' => $this->id)); + + if (empty($gi)) { + + $gi = new Group_inbox(); + + $gi->group_id = $group->id; + $gi->notice_id = $this->id; + $gi->created = $this->created; + + return $gi->insert(); + } + + return true; + } + + function addToGroupMemberInboxes($group) { - $inbox = new Notice_inbox(); - $UT = common_config('db','type')=='pgsql'?'"user"':'user'; - $qry = 'INSERT INTO notice_inbox (user_id, notice_id, created, source) ' . - "SELECT $UT.id, " . $this->id . ", '" . $this->created . "', " . NOTICE_INBOX_SOURCE_GROUP . " " . - "FROM $UT JOIN group_member ON $UT.id = group_member.profile_id " . - 'WHERE group_member.group_id = ' . $group->id . ' ' . - 'AND NOT EXISTS (SELECT user_id, notice_id ' . - 'FROM notice_inbox ' . - "WHERE user_id = $UT.id " . - 'AND notice_id = ' . $this->id . ' )'; - if ($enabled === 'transitional') { - $qry .= " AND $UT.inboxed = 1"; - } - $result = $inbox->query($qry); + $users = $group->getUserMembers(); + + foreach ($users as $id) { + $this->addToUserInbox($id, NOTICE_INBOX_SOURCE_GROUP); + } } function saveReplies() diff --git a/classes/Notice_inbox.php b/classes/Notice_inbox.php index 4ca2e9ae3..940381f84 100644 --- a/classes/Notice_inbox.php +++ b/classes/Notice_inbox.php @@ -27,6 +27,7 @@ define('INBOX_CACHE_WINDOW', 101); define('NOTICE_INBOX_SOURCE_SUB', 1); define('NOTICE_INBOX_SOURCE_GROUP', 2); +define('NOTICE_INBOX_SOURCE_REPLY', 3); define('NOTICE_INBOX_SOURCE_GATEWAY', -1); class Notice_inbox extends Memcached_DataObject diff --git a/classes/Profile.php b/classes/Profile.php index 6b27c80cb..a0ed6b3ca 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -289,4 +289,52 @@ class Profile extends Memcached_DataObject return Avatar::defaultImage($size); } } + + function getSubscriptions($offset=0, $limit=null) + { + $qry = + 'SELECT profile.* ' . + 'FROM profile JOIN subscription ' . + 'ON profile.id = subscription.subscribed ' . + 'WHERE subscription.subscriber = %d ' . + '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)); + + return $profile; + } + + function getSubscribers($offset=0, $limit=null) + { + $qry = + 'SELECT profile.* ' . + 'FROM profile JOIN subscription ' . + 'ON profile.id = subscription.subscriber ' . + 'WHERE subscription.subscribed = %d ' . + '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)); + + return $profile; + } } diff --git a/classes/User.php b/classes/User.php index a01a3106f..62a3f8a66 100644 --- a/classes/User.php +++ b/classes/User.php @@ -600,50 +600,16 @@ class User extends Memcached_DataObject function getSubscriptions($offset=0, $limit=null) { - $qry = - 'SELECT profile.* ' . - 'FROM profile JOIN subscription ' . - 'ON profile.id = subscription.subscribed ' . - 'WHERE subscription.subscriber = %d ' . - '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)); - - return $profile; + $profile = $this->getProfile(); + assert(!empty($profile)); + return $profile->getSubscriptions($offset, $limit); } function getSubscribers($offset=0, $limit=null) { - $qry = - 'SELECT profile.* ' . - 'FROM profile JOIN subscription ' . - 'ON profile.id = subscription.subscriber ' . - 'WHERE subscription.subscribed = %d ' . - '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)); - - return $profile; + $profile = $this->getProfile(); + assert(!empty($profile)); + return $profile->getSubscribers($offset, $limit); } function getTaggedSubscribers($tag, $offset=0, $limit=null) diff --git a/classes/User_group.php b/classes/User_group.php index 8a56b9e52..9b4b01ead 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -246,4 +246,28 @@ class User_group extends Memcached_DataObject return Design::staticGet('id', $this->design_id); } + function getUserMembers() + { + // XXX: cache this + + $user = new User(); + + $qry = + 'SELECT id ' . + 'FROM user JOIN group_member '. + 'ON user.id = group_member.profile_id ' . + 'WHERE group_member.group_id = %d '; + + $user->query(sprintf($qry, $this->id)); + + $ids = array(); + + while ($user->fetch()) { + $ids[] = $user->id; + } + + $user->free(); + + return $ids; + } } -- cgit v1.2.3-54-g00ecf