- $member = new Group_member();
-
- $member->group_id = $this->group->id;
- $member->profile_id = $this->user->id;
- $member->created = common_sql_now();
-
- $result = $member->insert();
-
- if (!$result) {
- common_log_db_error($member, 'INSERT', __FILE__);
- $this->serverError(
- sprintf(
- _('Could not join user %1$s to group %2$s.'),
- $this->user->nickname,
- $this->group->nickname
- )
- );
- return;
+ try {
+ $this->scoped->joinGroup($this->group);
+ } catch (Exception $e) {
+ // TRANS: Server error displayed when joining a group failed in the database.
+ // TRANS: %1$s is the joining user's nickname, $2$s is the group nickname for which the join failed.
+ $this->serverError(sprintf(_('Could not join user %1$s to group %2$s.'),
+ $this->scoped->nickname, $this->group->nickname));