summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-02-25 13:34:43 -0800
committerZach Copley <zach@status.net>2010-02-25 13:34:43 -0800
commite61edb55d9c92c0c93de3a591928f4760b6cea16 (patch)
tree782a1dcb09a17e0badb883c7c3a4d13a743418bc /lib
parent7e0872c7ca9827220ad9859abaeea268c9d4fee6 (diff)
Rationalize group activity stuff
Diffstat (limited to 'lib')
-rw-r--r--lib/activity.php61
1 files changed, 59 insertions, 2 deletions
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',