diff options
author | Evan Prodromou <evan@status.net> | 2010-09-23 09:50:46 -0400 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-09-23 09:50:46 -0400 |
commit | 0f1fc36a05c8d858827718255bef20e8d0c0d3f6 (patch) | |
tree | 7be7f3fabe27e9780c37de7483807d28ef3dfcf4 /classes/Group_member.php | |
parent | 77609e0c4a1b76748ab320027b0696aced92b52c (diff) | |
parent | 5f409a0d7caa3b075657eef947deb7b62452b82d (diff) |
Merge branch '0.9.x'
Diffstat (limited to 'classes/Group_member.php')
-rw-r--r-- | classes/Group_member.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/classes/Group_member.php b/classes/Group_member.php index 2239461be..939a9cde7 100644 --- a/classes/Group_member.php +++ b/classes/Group_member.php @@ -65,4 +65,54 @@ class Group_member extends Memcached_DataObject return true; } + + function getMember() + { + $member = Profile::staticGet('id', $this->profile_id); + + if (empty($member)) { + throw new Exception("Profile ID {$this->profile_id} invalid."); + } + + return $member; + } + + function getGroup() + { + $group = User_group::staticGet('id', $this->group_id); + + if (empty($group)) { + throw new Exception("Group ID {$this->group_id} invalid."); + } + + return $group; + } + + function asActivity() + { + $member = $this->getMember(); + $group = $this->getGroup(); + + $act = new Activity(); + + $act->id = TagURI::mint('join:%d:%d:%s', + $member->id, + $group->id, + common_date_iso8601($this->created)); + + $act->actor = ActivityObject::fromProfile($member); + $act->verb = ActivityVerb::JOIN; + $act->objects[] = ActivityObject::fromGroup($group); + + $act->time = strtotime($this->created); + $act->title = _("Join"); + + // TRANS: Success message for subscribe to group attempt through OStatus. + // TRANS: %1$s is the member name, %2$s is the subscribed group's name. + $act->content = sprintf(_('%1$s has joined group %2$s.'), + $member->getBestName(), + $group->getBestName()); + + return $act; + } } |