summaryrefslogtreecommitdiff
path: root/lib/activity.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/activity.php')
-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',