X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fleavegroup.php;h=f2182c58d2c6df73bc06dbe111b317dbebd44c80;hb=e98d5d0c0cee37acae440c15b3ea62ba036d4c82;hp=e0e2c278904249edc54b640909e4296f09b7f9de;hpb=c00491cd7a29a9ef16d6e6bfa54505d4c9a522fe;p=quix0rs-gnu-social.git diff --git a/actions/leavegroup.php b/actions/leavegroup.php index e0e2c27890..f2182c58d2 100644 --- a/actions/leavegroup.php +++ b/actions/leavegroup.php @@ -27,9 +27,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } /** * Leave a group @@ -50,7 +48,7 @@ class LeavegroupAction extends Action /** * Prepare to run */ - function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); @@ -91,9 +89,7 @@ class LeavegroupAction extends Action $this->clientError(_('No such group.'), 404); } - $cur = common_current_user(); - - if (!$cur->isMember($this->group)) { + if (!$this->scoped->isMember($this->group)) { // TRANS: Client error displayed when trying to join a group while already a member. $this->clientError(_('You are not a member of that group.'), 403); } @@ -106,24 +102,20 @@ class LeavegroupAction extends Action * * On POST, add the current user to the group * - * @param array $args unused - * * @return void */ - function handle($args) + protected function handle() { - parent::handle($args); - - $cur = common_current_user(); + parent::handle(); try { - $cur->leaveGroup($this->group); + $this->scoped->leaveGroup($this->group); } catch (Exception $e) { - common_log(LOG_ERR, "Error when {$cur->nickname} tried to leave {$this->group->nickname}: " . $e->getMessage()); + common_log(LOG_ERR, "Error when {$this->scoped->nickname} tried to leave {$this->group->nickname}: " . $e->getMessage()); // TRANS: Server error displayed when leaving a group failed in the database. // TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed. $this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'), - $cur->nickname, $this->group->nickname)); + $this->scoped->nickname, $this->group->nickname)); return; } @@ -132,7 +124,7 @@ class LeavegroupAction extends Action $this->elementStart('head'); // TRANS: Title for leave group page after leaving. $this->element('title', null, sprintf(_m('TITLE','%1$s left group %2$s'), - $cur->nickname, + $this->scoped->nickname, $this->group->nickname)); $this->elementEnd('head'); $this->elementStart('body');