X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=actions%2Fmakeadmin.php;h=9ccb442308b2910b0fd815dd80fd03bfb9aa4629;hb=9a53be4669e53ba343f4c6433405ae8de747a86f;hp=7866f42c15ff015dd44ce6df6f65b51844300363;hpb=865b716f0919b6e5133133cd6be53f4143660324;p=quix0rs-gnu-social.git diff --git a/actions/makeadmin.php b/actions/makeadmin.php index 7866f42c15..9ccb442308 100644 --- a/actions/makeadmin.php +++ b/actions/makeadmin.php @@ -27,7 +27,7 @@ * along with this program. If not, see . */ -if (!defined('STATUSNET')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } @@ -41,7 +41,7 @@ if (!defined('STATUSNET')) { * @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->returnToArgs(); + } - 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)); } + }