X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fmakeadmin.php;h=4e6e97a5693c8c2456059afe5b19a463688c862d;hb=b483a0549f115b2d5f2cfb3d447e6cc5c4f469f3;hp=6fc2cf9ab594929a472401fb996d6ae0b940604c;hpb=6328add622641e5f5721cc34d27d4d872c86a561;p=quix0rs-gnu-social.git diff --git a/actions/makeadmin.php b/actions/makeadmin.php index 6fc2cf9ab5..4e6e97a569 100644 --- a/actions/makeadmin.php +++ b/actions/makeadmin.php @@ -5,13 +5,13 @@ * PHP version 5 * * @category Action - * @package Laconica - * @author Evan Prodromou + * @package StatusNet + * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 - * @link http://laconi.ca/ + * @link http://status.net/ * - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 2009, StatusNet, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -27,7 +27,7 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } @@ -35,13 +35,13 @@ if (!defined('LACONICA')) { * Make another user an admin of a group * * @category Action - * @package Laconica - * @author Evan Prodromou + * @package StatusNet + * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 - * @link http://laconi.ca/ + * @link http://status.net/ */ -class MakeadminAction extends Action +class MakeadminAction extends RedirectingAction { var $profile = null; var $group = null; @@ -87,12 +87,13 @@ class MakeadminAction extends Action return false; } $user = common_current_user(); - if (!$user->isAdmin($this->group)) { + if (!$user->isAdmin($this->group) && + !$user->hasRight(Right::MAKEGROUPADMIN)) { $this->clientError(_('Only an admin can make another user an admin.'), 401); return false; } if ($this->profile->isAdmin($this->group)) { - $this->clientError(sprintf(_('%s is already an admin for group "%s".'), + $this->clientError(sprintf(_('%1$s is already an admin for group "%2$s".'), $this->profile->getBestName(), $this->group->getBestName()), 401); @@ -129,7 +130,7 @@ class MakeadminAction extends Action 'profile_id' => $this->profile->id)); if (empty($member)) { - $this->serverError(_('Can\'t get membership record for %s in group %s'), + $this->serverError(_('Can\'t get membership record for %1$s in group %2$s.'), $this->profile->getBestName(), $this->group->getBestName()); } @@ -142,25 +143,24 @@ class MakeadminAction extends Action if (!$result) { common_log_db_error($member, 'UPDATE', __FILE__); - $this->serverError(_('Can\'t make %s an admin for group %s'), + $this->serverError(_('Can\'t make %1$s an admin for group %2$s.'), $this->profile->getBestName(), $this->group->getBestName()); } - foreach ($this->args as $k => $v) { - if ($k == 'returnto-action') { - $action = $v; - } else if (substr($k, 0, 9) == 'returnto-') { - $args[substr($k, 9)] = $v; - } - } + $this->returnToPrevious(); + } - if ($action) { - common_redirect(common_local_url($action, $args), 303); - } else { - common_redirect(common_local_url('groupmembers', - array('nickname' => $this->group->nickname)), - 303); - } + /** + * If we reached this form without returnto arguments, default to + * the top of the group's member list. + * + * @return string URL + */ + function defaultReturnTo() + { + return common_local_url('groupmembers', + array('nickname' => $this->group->nickname)); } + }