From 5dbaaed4e68ecae1c78b9493add89df3557c8e98 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 8 Apr 2010 19:06:55 -0700 Subject: Maintain 'page' parameter for block from subscribers list, block & make-admin from group members list. Refactored some of the returnto handling code. It looks like we have several different ways of handling this in the software, icky! Marked the session-based functions with fixmes (they'll stomp on other forms when multiple tabs/windows are used) and combined some commonish bits of code between ProfileFormAction and the group block & makeadmin actions where they're using hidden form parameters. Extended that to allow passing dynamic parameters (eg 'page') as well as static ones (action, target user/group). --- actions/groupblock.php | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'actions/groupblock.php') diff --git a/actions/groupblock.php b/actions/groupblock.php index 88d7634a2..fc95c0e66 100644 --- a/actions/groupblock.php +++ b/actions/groupblock.php @@ -41,7 +41,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @link http://status.net/ */ -class GroupblockAction extends Action +class GroupblockAction extends RedirectingAction { var $profile = null; var $group = null; @@ -117,9 +117,7 @@ class GroupblockAction extends Action parent::handle($args); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($this->arg('no')) { - common_redirect(common_local_url('groupmembers', - array('nickname' => $this->group->nickname)), - 303); + $this->returnToArgs(); } elseif ($this->arg('yes')) { $this->blockProfile(); } elseif ($this->arg('blockto')) { @@ -196,23 +194,20 @@ class GroupblockAction extends Action $this->serverError(_("Database error blocking user from group.")); return false; } + + $this->returnToArgs(); + } - // Now, gotta figure where we go back to - foreach ($this->args as $k => $v) { - if ($k == 'returnto-action') { - $action = $v; - } elseif (substr($k, 0, 9) == 'returnto-') { - $args[substr($k, 9)] = $v; - } - } - - 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)); } function showScripts() -- cgit v1.2.3-54-g00ecf