X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FGroup_member.php;h=939a9cde76e8cf3049fc484a0e97db48473bcd7b;hb=3a1f1a49b22c2be4234a78cd36016a373d3ca5fc;hp=2239461beb5e08b3b4253e0f76b3c472159d8b73;hpb=f9a4728fcc5d93a019bc72f44c836fa51c2e8ea7;p=quix0rs-gnu-social.git diff --git a/classes/Group_member.php b/classes/Group_member.php index 2239461beb..939a9cde76 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; + } }