/**
* Class for activity streams
*
- * Includes faves, notices, and subscriptions.
+ * Includes objects like notices, subscriptions and from plugins.
*
* We extend atomusernoticefeed since it does some nice setup for us.
*
class UserActivityStream extends AtomUserNoticeFeed
{
public $activities = array();
+ public $after = null;
const OUTPUT_STRING = 1;
const OUTPUT_RAW = 2;
$subscriptions = $this->getSubscriptions();
$subscribers = $this->getSubscribers();
$groups = $this->getGroups();
- $faves = $this->getFaves();
- $messagesFrom = $this->getMessagesFrom();
- $messagesTo = $this->getMessagesTo();
- $objs = array_merge($subscriptions, $subscribers, $groups, $faves, $notices, $messagesFrom, $messagesTo);
+ $objs = array_merge($subscriptions, $subscribers, $groups, $notices);
+
+ Event::handle('AppendUserActivityStreamObjects', array($this, &$objs));
$subscriptions = null;
$subscribers = null;
$groups = null;
- $faves = null;
unset($subscriptions);
unset($subscribers);
unset($groups);
- unset($faves);
// Sort by create date
}
/**
- * Interleave the pre-sorted subs/groups/faves with the user's
+ * Interleave the pre-sorted objects with the user's
* notices, all in reverse chron order.
*/
function renderEntries($format=Feed::ATOM, $handle=null)
$end = time() + 1;
foreach ($this->objs as $obj) {
+ set_time_limit(10);
+
try {
$act = $obj->asActivity();
} catch (Exception $e) {
$notices = $this->getNoticesBetween($start, $end);
foreach ($notices as $noticeAct) {
try {
- $nact = $noticeAct->asActivity($this->user);
+ $nact = $noticeAct->asActivity($this->user->getProfile());
if ($format == Feed::ATOM) {
$nact->outputTo($this, false, false);
} else {
try {
if ($format == Feed::ATOM) {
// Only show the author sub-element if it's different from default user
- $act->outputTo($this, false, ($act->actor->id != $this->user->uri));
+ $act->outputTo($this, false, ($act->actor->id != $this->user->getUri()));
} else {
if ($haveOne) {
fwrite($handle, ",");
}
foreach ($notices as $noticeAct) {
try {
- $nact = $noticeAct->asActivity($this->user);
+ $nact = $noticeAct->asActivity($this->user->getProfile());
if ($format == Feed::ATOM) {
$nact->outputTo($this, false, false);
} else {
return $subs;
}
- function getFaves()
- {
- $faves = array();
-
- $fave = new Fave();
-
- $fave->user_id = $this->user->id;
-
- if (!empty($this->after)) {
- $fave->whereAdd("modified > '" . common_sql_date($this->after) . "'");
- }
-
- if ($fave->find()) {
- while ($fave->fetch()) {
- $faves[] = clone($fave);
- }
- }
-
- return $faves;
- }
-
/**
*
* @param int $start unix timestamp for earliest
return $groups;
}
- function getMessagesTo()
- {
- $msgMap = Message::listGet('to_profile', array($this->user->id));
-
- $messages = $msgMap[$this->user->id];
-
- if (!empty($this->after)) {
- $messages = array_filter($messages, array($this, 'createdAfter'));
- }
-
- return $messages;
- }
-
- function getMessagesFrom()
- {
- $msgMap = Message::listGet('from_profile', array($this->user->id));
-
- $messages = $msgMap[$this->user->id];
-
- if (!empty($this->after)) {
- $messages = array_filter($messages, array($this, 'createdAfter'));
- }
-
- return $messages;
- }
-
function createdAfter($item) {
$created = strtotime((empty($item->created)) ? $item->modified : $item->created);
return ($created >= $this->after);