3 * Superclass for actions that redirect to a given return-to page on completion.
7 * StatusNet - the distributed open-source microblogging tool
8 * Copyright (C) 2009-2010, StatusNet, Inc.
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Evan Prodromou <evan@status.net>
26 * @author Brion Vibber <brion@status.net>
27 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
28 * @link http://status.net/
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
36 * Superclass for actions that redirect to a given return-to page on completion.
40 * @author Evan Prodromou <evan@status.net>
41 * @author Brion Vibber <brion@status.net>
42 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43 * @link http://status.net/
47 class RedirectingAction extends Action
51 * Redirect browser to the page our hidden parameters requested,
52 * or if none given, to the url given by $this->defaultReturnTo().
54 * To be called only after successful processing.
56 * @fixme rename this -- it obscures Action::returnToArgs() which
57 * returns a list of arguments, and is a bit confusing.
61 function returnToArgs()
63 // Now, gotta figure where we go back to
67 foreach ($this->args as $k => $v) {
68 if ($k == 'returnto-action') {
70 } else if (substr($k, 0, 15) == 'returnto-param-') {
71 $params[substr($k, 15)] = $v;
72 } elseif (substr($k, 0, 9) == 'returnto-') {
73 $args[substr($k, 9)] = $v;
78 common_redirect(common_local_url($action, $args, $params), 303);
80 $url = $this->defaultReturnToUrl();
82 common_redirect($url, 303);
86 * If we reached this form without returnto arguments, where should
87 * we go? May be overridden by subclasses to a reasonable destination
88 * for that action; default implementation throws an exception.
92 function defaultReturnTo()
94 $this->clientError(_("No return-to arguments."));