]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/makeadmin.php
Switch autoloader from '__autoload' magic function name to registering our function...
[quix0rs-gnu-social.git] / actions / makeadmin.php
index 9ad7d6e7c821a247cdc1961e1cbed593dc785991..4e6e97a5693c8c2456059afe5b19a463688c862d 100644 (file)
@@ -41,7 +41,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
  * @link     http://status.net/
  */
 
-class MakeadminAction extends Action
+class MakeadminAction extends RedirectingAction
 {
     var $profile = null;
     var $group = null;
@@ -87,7 +87,8 @@ 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;
         }
@@ -147,20 +148,19 @@ class MakeadminAction extends Action
                                $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));
     }
+
 }