X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fleavegroup.php;h=9b9d83b6caae243befbd9e43a43eb6b137be53f5;hb=68a2e46390092f034101bf1a1c9fc4a5ecc41b06;hp=60b22e147d735978090f36d0ecc10644ee07b6c2;hpb=9d87313eaebe8240393ac300a435f3b1332c8849;p=quix0rs-gnu-social.git diff --git a/actions/leavegroup.php b/actions/leavegroup.php index 60b22e147d..9b9d83b6ca 100644 --- a/actions/leavegroup.php +++ b/actions/leavegroup.php @@ -56,11 +56,6 @@ class LeavegroupAction extends Action { parent::prepare($args); - if (!common_config('inboxes','enabled')) { - $this->serverError(_('Inboxes must be enabled for groups to work.')); - return false; - } - if (!common_logged_in()) { $this->clientError(_('You must be logged in to leave a group.')); return false; @@ -115,28 +110,21 @@ 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, 'INSERT', __FILE__); - $this->serverError(sprintf(_('Could not remove user %s to group %s'), + 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')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); - $this->element('title', null, sprintf(_('%s left group %s'), + $this->element('title', null, sprintf(_('%1$s left group %2$s'), $cur->nickname, $this->group->nickname)); $this->elementEnd('head');