summaryrefslogtreecommitdiff
path: root/classes/Fave.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/Fave.php')
-rw-r--r--classes/Fave.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/classes/Fave.php b/classes/Fave.php
index 9922ae45c..3aa23e7b4 100644
--- a/classes/Fave.php
+++ b/classes/Fave.php
@@ -138,6 +138,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 +158,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;
+ }
}