3 * Unblock a user action class.
9 * @author Evan Prodromou <evan@controlyourself.ca>
10 * @author Robin Millette <millette@controlyourself.ca>
11 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12 * @link http://laconi.ca/
14 * Laconica - a distributed open-source microblogging tool
15 * Copyright (C) 2008, Controlez-Vous, Inc.
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU Affero General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Affero General Public License for more details.
27 * You should have received a copy of the GNU Affero General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 if (!defined('LACONICA')) {
36 * Unblock a user action class.
40 * @author Evan Prodromou <evan@controlyourself.ca>
41 * @author Robin Millette <millette@controlyourself.ca>
42 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43 * @link http://laconi.ca/
45 class UnblockAction extends Action
50 * Take arguments for running
52 * @param array $args $_REQUEST args
54 * @return boolean success flag
56 function prepare($args)
58 parent::prepare($args);
59 if (!common_logged_in()) {
60 $this->clientError(_('Not logged in.'));
63 $token = $this->trimmed('token');
64 if (!$token || $token != common_session_token()) {
65 $this->clientError(_('There was a problem with your session token. Try again, please.'));
68 $id = $this->trimmed('unblockto');
70 $this->clientError(_('No profile specified.'));
73 $this->profile = Profile::staticGet('id', $id);
74 if (!$this->profile) {
75 $this->clientError(_('No profile with that ID.'));
84 * Shows a page with list of favorite notices
86 * @param array $args $_REQUEST args; handled in prepare()
90 function handle($args)
92 parent::handle($args);
93 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
94 $this->unblockProfile();
103 function unblockProfile()
105 $cur = common_current_user();
106 $result = $cur->unblock($this->profile);
108 $this->serverError(_('Error removing the block.'));
111 foreach ($this->args as $k => $v) {
112 if ($k == 'returnto-action') {
114 } else if (substr($k, 0, 9) == 'returnto-') {
115 $args[substr($k, 9)] = $v;
119 common_redirect(common_local_url($action, $args), 303);
121 common_redirect(common_local_url('subscriptions',
122 array('nickname' => $cur->nickname)),