From e61edb55d9c92c0c93de3a591928f4760b6cea16 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 25 Feb 2010 13:34:43 -0800 Subject: Rationalize group activity stuff --- lib/activity.php | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/activity.php b/lib/activity.php index e592aad6f..0863cf8fa 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -223,6 +223,37 @@ class PoCo return $poco; } + function fromGroup($group) + { + if (empty($group)) { + return null; + } + + $poco = new PoCo(); + + $poco->preferredUsername = $group->nickname; + $poco->displayName = $group->getBestName(); + + $poco->note = $group->description; + + $paddy = new PoCoAddress(); + $paddy->formatted = $group->location; + $poco->address = $paddy; + + if (!empty($group->homepage)) { + array_push( + $poco->urls, + new PoCoURL( + 'homepage', + $group->homepage, + true + ) + ); + } + + return $poco; + } + function getPrimaryURL() { foreach ($this->urls as $url) { @@ -621,6 +652,21 @@ class ActivityObject return $object; } + static function fromGroup($group) + { + $object = new ActivityObject(); + + $object->type = ActivityObject::GROUP; + $object->id = $group->getUri(); + $object->title = $group->getBestName(); + $object->link = $group->getUri(); + $object->avatar = $group->getAvatar(); + + $object->poco = PoCo::fromGroup($group); + + return $object; + } + function asString($tag='activity:object') { $xs = new XMLStringer(true); @@ -656,8 +702,7 @@ class ActivityObject ); } - if ($this->type == ActivityObject::PERSON - || $this->type == ActivityObject::GROUP) { + if ($this->type == ActivityObject::PERSON) { $xs->element( 'link', array( 'type' => empty($this->avatar) ? 'image/png' : $this->avatar->mediatype, @@ -670,6 +715,18 @@ class ActivityObject ); } + // XXX: Gotta figure out mime-type! Gar. + + if ($this->type == ActivityObject::GROUP) { + $xs->element( + 'link', array( + 'rel' => 'avatar', + 'href' => $this->avatar + ), + null + ); + } + if (!empty($this->geopoint)) { $xs->element( 'georss:point', -- cgit v1.2.3-54-g00ecf