diff options
author | Siebrand Mazeland <s.mazeland@xs4all.nl> | 2010-01-13 23:10:00 +0100 |
---|---|---|
committer | Siebrand Mazeland <s.mazeland@xs4all.nl> | 2010-01-13 23:10:00 +0100 |
commit | 108c51fa6859ec56269078ef9bd0459fdbd9b1ba (patch) | |
tree | c45dc1036d80ba0fdc58473819cde12bcc03eb32 /actions/leavegroup.php | |
parent | f7f82982ec9a8671195efdc278c2987aa92c083c (diff) | |
parent | 25ed2d2c872e59fd99b54fdf0dec1ca448feca00 (diff) |
Merge branch '0.9.x' of git://gitorious.org/statusnet/mainline into 0.9.x
Diffstat (limited to 'actions/leavegroup.php')
-rw-r--r-- | actions/leavegroup.php | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/actions/leavegroup.php b/actions/leavegroup.php index b0f973e1a..9b9d83b6c 100644 --- a/actions/leavegroup.php +++ b/actions/leavegroup.php @@ -110,22 +110,15 @@ class LeavegroupAction extends Action $cur = common_current_user(); - $member = new Group_member(); - - $member->group_id = $this->group->id; - $member->profile_id = $cur->id; - - if (!$member->find(true)) { - $this->serverError(_('Could not find membership record.')); - return; - } - - $result = $member->delete(); - - if (!$result) { - common_log_db_error($member, 'DELETE', __FILE__); + try { + if (Event::handle('StartLeaveGroup', array($this->group, $cur))) { + Group_member::leave($this->group->id, $cur->id); + Event::handle('EndLeaveGroup', array($this->group, $cur)); + } + } catch (Exception $e) { $this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'), $cur->nickname, $this->group->nickname)); + return; } if ($this->boolean('ajax')) { |