Add Group_member::asActivity() to record group joins
This commit is contained in:
parent
eec540723e
commit
43ad609600
@ -65,4 +65,54 @@ class Group_member extends Memcached_DataObject
|
|||||||
|
|
||||||
return true;
|
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->object = ActivityObject::fromGroup($group);
|
||||||
|
|
||||||
|
$act->time = strtotime($this->created);
|
||||||
|
$act->title = _m("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(_m("%1$s has joined group %2$s."),
|
||||||
|
$member->getBestName(),
|
||||||
|
$group->getBestName());
|
||||||
|
|
||||||
|
return $act;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user