summaryrefslogtreecommitdiff
path: root/classes/Fave.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/Fave.php')
-rw-r--r--classes/Fave.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/classes/Fave.php b/classes/Fave.php
index 9922ae45c..4a9cfaae0 100644
--- a/classes/Fave.php
+++ b/classes/Fave.php
@@ -85,6 +85,19 @@ class Fave extends Memcached_DataObject
return $ids;
}
+ /**
+ * Note that the sorting for this is by order of *fave* not order of *notice*.
+ *
+ * @fixme add since_id, max_id support?
+ *
+ * @param <type> $user_id
+ * @param <type> $own
+ * @param <type> $offset
+ * @param <type> $limit
+ * @param <type> $since_id
+ * @param <type> $max_id
+ * @return <type>
+ */
function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id)
{
$fav = new Fave();
@@ -138,6 +151,9 @@ class Fave extends Memcached_DataObject
$act = new Activity();
$act->verb = ActivityVerb::FAVORITE;
+
+ // FIXME: rationalize this with URL below
+
$act->id = TagURI::mint('favor:%d:%d:%s',
$profile->id,
$notice->id,
@@ -155,6 +171,41 @@ class Fave extends Memcached_DataObject
$act->actor = ActivityObject::fromProfile($profile);
$act->objects[] = ActivityObject::fromNotice($notice);
+ $url = common_local_url('AtomPubShowFavorite',
+ array('profile' => $this->user_id,
+ 'notice' => $this->notice_id));
+
+ $act->selfLink = $url;
+ $act->editLink = $url;
+
return $act;
}
+
+ /**
+ * Fetch a stream of favorites by profile
+ *
+ * @param integer $profileId Profile that faved
+ * @param integer $offset Offset from last
+ * @param integer $limit Number to get
+ *
+ * @return mixed stream of faves, use fetch() to iterate
+ *
+ * @todo Cache results
+ * @todo integrate with Fave::stream()
+ */
+
+ static function byProfile($profileId, $offset, $limit)
+ {
+ $fav = new Fave();
+
+ $fav->user_id = $profileId;
+
+ $fav->orderBy('modified DESC');
+
+ $fav->limit($offset, $limit);
+
+ $fav->find();
+
+ return $fav;
+ }
}