3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2008-2010, StatusNet, Inc.
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Shashi Gowda <connect2shashi@gmail.com>
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
27 * @link http://status.net/
30 if (!defined('STATUSNET')) {
34 require_once INSTALLDIR . '/lib/togglepeopletag.php';
39 * Subscribing to a profile. Does not work for OMB 0.1 remote subscriptions,
40 * but may work for other remote subscription protocols, like OStatus.
44 * - subscribeto: a profile ID
45 * - token: session token to prevent CSRF attacks
46 * - ajax: boolean; whether to return Ajax or full-browser results
48 * Only works if the current user is logged in.
52 * @author Shashi Gowda <connect2shashi@gmail.com>
53 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
54 * @link http://status.net/
56 class RemovepeopletagAction extends Action
63 * Check pre-requisites and instantiate attributes
65 * @param Array $args array of arguments (URL, GET, POST)
67 * @return boolean success flag
69 function prepare($args)
71 parent::prepare($args);
75 $token = $this->trimmed('token');
77 if (!$token || $token != common_session_token()) {
78 // TRANS: Client error displayed when the session token does not match or is not given.
79 $this->clientError(_('There was a problem with your session token.'.
80 ' Try again, please.'));
83 // Only for logged-in users
85 $this->user = common_current_user();
87 if (empty($this->user)) {
88 // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
89 $this->clientError(_('Not logged in.'));
92 // Profile to subscribe to
94 $tagged_id = $this->arg('tagged');
96 $this->tagged = Profile::getKV('id', $tagged_id);
98 if (empty($this->tagged)) {
99 // TRANS: Client error displayed when referring to a non-existing profile.
100 $this->clientError(_('No such profile.'));
103 $id = $this->arg('peopletag_id');
104 $this->peopletag = Profile_list::getKV('id', $id);
106 if (empty($this->peopletag)) {
107 // TRANS: Client error displayed trying to reference a non-existing list.
108 $this->clientError(_('No such list.'));
117 * Does the subscription and returns results.
119 * @param Array $args unused.
123 function handle($args)
125 // Throws exception on error
127 $ptag = Profile_tag::unTag($this->user->id, $this->tagged->id,
128 $this->peopletag->tag);
131 $user = User::getKV('id', $this->tagged->id);
134 // TRANS: Client error displayed when an unknown error occurs while delisting a user.
135 // TRANS: %s is a username.
136 sprintf(_('There was an unexpected error while delisting %s.'),
139 // TRANS: Client error displayed when an unknown error occurs while listing a user.
140 // TRANS: %s is a profile URL.
141 $this->clientError(sprintf(_('There was a problem listing %s. ' .
142 'The remote server is probably not responding correctly, ' .
143 'please try retrying later.'), $this->profile->profileurl));
146 if ($this->boolean('ajax')) {
147 $this->startHTML('text/xml;charset=utf-8');
148 $this->elementStart('head');
149 // TRANS: Title after removing a user from a list.
150 $this->element('title', null, _('Unlisted'));
151 $this->elementEnd('head');
152 $this->elementStart('body');
153 $unsubscribe = new TagButton($this, $this->tagged, $this->peopletag);
154 $unsubscribe->show();
155 $this->elementEnd('body');
158 $url = common_local_url('subscriptions',
159 array('nickname' => $this->user->nickname));
160 common_redirect($url, 303);