summaryrefslogtreecommitdiff
path: root/classes/User_group.php
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 /classes/User_group.php
parent7e0872c7ca9827220ad9859abaeea268c9d4fee6 (diff)
Rationalize group activity stuff
Diffstat (limited to 'classes/User_group.php')
-rw-r--r--classes/User_group.php46
1 files changed, 31 insertions, 15 deletions
diff --git a/classes/User_group.php b/classes/User_group.php
index f24bef764..7240e2703 100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
@@ -399,25 +399,41 @@ class User_group extends Memcached_DataObject
return $xs->getString();
}
+ /**
+ * Returns an XML string fragment with group information as an
+ * Activity Streams <activity:subject> element.
+ *
+ * Assumes that 'activity' namespace has been previously defined.
+ *
+ * @return string
+ */
function asActivitySubject()
{
- $xs = new XMLStringer(true);
+ return $this->asActivityNoun('subject');
+ }
- $xs->elementStart('activity:subject');
- $xs->element('activity:object', null, 'http://activitystrea.ms/schema/1.0/group');
- $xs->element('id', null, $this->permalink());
- $xs->element('title', null, $this->getBestName());
- $xs->element(
- 'link', array(
- 'rel' => 'avatar',
- 'href' => empty($this->homepage_logo)
- ? User_group::defaultLogo(AVATAR_PROFILE_SIZE)
- : $this->homepage_logo
- )
- );
- $xs->elementEnd('activity:subject');
+ /**
+ * Returns an XML string fragment with group information as an
+ * Activity Streams noun object with the given element type.
+ *
+ * Assumes that 'activity', 'georss', and 'poco' namespace has been
+ * previously defined.
+ *
+ * @param string $element one of 'actor', 'subject', 'object', 'target'
+ *
+ * @return string
+ */
+ function asActivityNoun($element)
+ {
+ $noun = ActivityObject::fromGroup($this);
+ return $noun->asString('activity:' . $element);
+ }
- return $xs->getString();
+ function getAvatar()
+ {
+ return empty($this->homepage_logo)
+ ? User_group::defaultLogo(AVATAR_PROFILE_SIZE)
+ : $this->homepage_logo;
}
static function register($fields) {