/**
* Convert a notice into an activity for export.
*
- * @param User $cur Current user
+ * @param Profile $scoped The currently logged in/scoped profile
*
* @return Activity activity object representing this Notice.
*/
- function asActivity($cur=null)
+ function asActivity(Profile $scoped=null)
{
$act = self::cacheGet(Cache::codeKey('notice:as-activity:'.$this->id));
$profile = $this->getProfile();
$act->actor = $profile->asActivityObject();
- $act->actor->extra[] = $profile->profileInfo($cur);
+ $act->actor->extra[] = $profile->profileInfo($scoped);
$act->verb = $this->verb;
if ($this->repeat_of) {
$repeated = Notice::getKV('id', $this->repeat_of);
if ($repeated instanceof Notice) {
- $act->objects[] = $repeated->asActivity($cur);
+ $act->objects[] = $repeated->asActivity($scoped);
}
} else {
$act->objects[] = $this->asActivityObject();
function asAtomEntry($namespace=false,
$source=false,
$author=true,
- $cur=null)
+ Profile $scoped=null)
{
- $act = $this->asActivity($cur);
- $act->extra[] = $this->noticeInfo($cur);
+ $act = $this->asActivity($scoped);
+ $act->extra[] = $this->noticeInfo($scoped);
return $act->asString($namespace, $author, $source);
}
* Clients use some extra notice info in the atom stream.
* This gives it to them.
*
- * @param User $cur Current user
+ * @param Profile $scoped The currently logged in/scoped profile
*
* @return array representation of <statusnet:notice_info> element
*/
- function noticeInfo($cur)
+ function noticeInfo(Profile $scoped=null)
{
// local notice ID (useful to clients for ordering)
// favorite and repeated
- $scoped = null;
- if (!empty($cur)) {
- $scoped = $cur->getProfile();
+ if ($scoped instanceof Profile) {
$noticeInfoAttr['repeated'] = ($scoped->hasRepeated($this)) ? "true" : "false";
}
* Clients use some extra profile info in the atom stream.
* This gives it to them.
*
- * @param User $cur Current user
+ * @param Profile $scoped The currently logged in/scoped profile
*
* @return array representation of <statusnet:profile_info> element or null
*/
- function profileInfo($cur)
+ function profileInfo(Profile $scoped=null)
{
$profileInfoAttr = array('local_id' => $this->id);
- if ($cur != null) {
+ if ($scoped instanceof Profile) {
// Whether the current user is a subscribed to this profile
- $profileInfoAttr['following'] = $cur->isSubscribed($this) ? 'true' : 'false';
+ $profileInfoAttr['following'] = $scoped->isSubscribed($this) ? 'true' : 'false';
// Whether the current user is has blocked this profile
- $profileInfoAttr['blocking'] = $cur->hasBlocked($this) ? 'true' : 'false';
+ $profileInfoAttr['blocking'] = $scoped->hasBlocked($this) ? 'true' : 'false';
}
return array('statusnet:profile_info', $profileInfoAttr, null);
$notice = Notice::getKV('id', $fave->notice_id);
if (!empty($notice)) {
$cur = common_current_user();
- $target = $notice->asActivity($cur);
+ $target = $notice->asActivity($cur->getProfile());
if ($target->verb == ActivityVerb::POST) {
// "I like the thing you posted"
$activity->objects = $target->objects;