summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorSarven Capadisli <csarven@status.net>2010-01-13 21:13:21 +0000
committerSarven Capadisli <csarven@status.net>2010-01-13 21:13:21 +0000
commit25ed2d2c872e59fd99b54fdf0dec1ca448feca00 (patch)
tree8d882d0d647b09ec2e060d0bdb20646b8a505cf1 /classes
parent5d88e6435f5b6725c09480a7d7cd4a8a80a62202 (diff)
parentd018ab7b0ce907a2400d7cd2294362e4d85f4717 (diff)
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'classes')
-rw-r--r--classes/Notice.php69
1 files changed, 62 insertions, 7 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index 02cd20391..a43ce867b 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -335,7 +335,11 @@ class Notice extends Memcached_DataObject
$notice->saveTags();
- $notice->addToInboxes();
+ $groups = $notice->saveGroups();
+
+ $recipients = $notice->saveReplies();
+
+ $notice->addToInboxes($groups, $recipients);
$notice->saveUrls();
@@ -822,7 +826,7 @@ class Notice extends Memcached_DataObject
return $ids;
}
- function whoGets()
+ function whoGets($groups=null, $recipients=null)
{
$c = self::memcache();
@@ -833,6 +837,14 @@ class Notice extends Memcached_DataObject
}
}
+ if (is_null($groups)) {
+ $groups = $this->getGroups();
+ }
+
+ if (is_null($recipients)) {
+ $recipients = $this->getReplies();
+ }
+
$users = $this->getSubscribedUsers();
// FIXME: kind of ignoring 'transitional'...
@@ -845,7 +857,6 @@ class Notice extends Memcached_DataObject
$ni[$id] = NOTICE_INBOX_SOURCE_SUB;
}
- $groups = $this->saveGroups();
$profile = $this->getProfile();
foreach ($groups as $group) {
@@ -860,8 +871,6 @@ class Notice extends Memcached_DataObject
}
}
- $recipients = $this->saveReplies();
-
foreach ($recipients as $recipient) {
if (!array_key_exists($recipient, $ni)) {
@@ -880,9 +889,9 @@ class Notice extends Memcached_DataObject
return $ni;
}
- function addToInboxes()
+ function addToInboxes($groups, $recipients)
{
- $ni = $this->whoGets();
+ $ni = $this->whoGets($groups, $recipients);
Inbox::bulkInsert($this->id, array_keys($ni));
@@ -1086,6 +1095,52 @@ class Notice extends Memcached_DataObject
return $recipientIds;
}
+ function getReplies()
+ {
+ // XXX: cache me
+
+ $ids = array();
+
+ $reply = new Reply();
+ $reply->selectAdd();
+ $reply->selectAdd('profile_id');
+ $reply->notice_id = $this->id;
+
+ if ($reply->find()) {
+ while($reply->fetch()) {
+ $ids[] = $reply->profile_id;
+ }
+ }
+
+ $reply->free();
+
+ return $ids;
+ }
+
+ function getGroups()
+ {
+ // XXX: cache me
+
+ $ids = array();
+
+ $gi = new Group_inbox();
+
+ $gi->selectAdd();
+ $gi->selectAdd('group_id');
+
+ $gi->notice_id = $this->id;
+
+ if ($gi->find()) {
+ while ($gi->fetch()) {
+ $ids[] = $gi->group_id;
+ }
+ }
+
+ $gi->free();
+
+ return $ids;
+ }
+
function asAtomEntry($namespace=false, $source=false)
{
$profile = $this->getProfile();