summaryrefslogtreecommitdiff
path: root/actions/leavegroup.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-01-13 02:16:13 -0800
committerEvan Prodromou <evan@status.net>2010-01-13 02:16:13 -0800
commit430bd69312a27f9f97bda78566a78c9f7eec1f14 (patch)
treee5f043e4356e8523b0978a9e35cb602af8dbf60b /actions/leavegroup.php
parent23599da91e9d4abbd6e73ef3f44c58f302a5231a (diff)
add events for subscribing to people and joining groups
Diffstat (limited to 'actions/leavegroup.php')
-rw-r--r--actions/leavegroup.php21
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')) {