3 * StatusNet, the distributed open-source microblogging tool
5 * Unsubscribe to a peopletag
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Shashi Gowda <connect2shashi@gmail.com>
25 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
26 * @link http://status.net/
29 if (!defined('STATUSNET') && !defined('LACONICA')) {
34 * Unsubscribe to a peopletag
36 * This is the action for subscribing to a peopletag. It works more or less like the join action
41 * @author Shashi Gowda <connect2shashi@gmail.com>
42 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43 * @link http://status.net/
45 class UnsubscribepeopletagAction extends Action
47 var $peopletag = null;
54 function prepare($args)
56 parent::prepare($args);
58 if (!common_logged_in()) {
59 // TRANS: Client error displayed when trying to perform an action while not logged in.
60 $this->clientError(_('You must be logged in to unsubscribe to a people tag.'));
63 // Only allow POST requests
65 if ($_SERVER['REQUEST_METHOD'] != 'POST') {
66 // TRANS: Client error displayed when trying to use another method than POST.
67 $this->clientError(_('This action only accepts POST requests.'));
73 $token = $this->trimmed('token');
75 if (!$token || $token != common_session_token()) {
76 // TRANS: Client error displayed when the session token does not match or is not given.
77 $this->clientError(_('There was a problem with your session token.'.
78 ' Try again, please.'));
82 $tagger_arg = $this->trimmed('tagger');
83 $tag_arg = $this->trimmed('tag');
85 $id = intval($this->arg('id'));
87 $this->peopletag = Profile_list::staticGet('id', $id);
89 // TRANS: Client error displayed when trying to perform an action without providing an ID.
90 $this->clientError(_('No ID given.'), 404);
94 if (!$this->peopletag || $this->peopletag->private) {
95 // TRANS: Client error displayed trying to reference a non-existing people tag.
96 $this->clientError(_('No such people tag.'), 404);
100 $this->tagger = Profile::staticGet('id', $this->peopletag->tagger);
108 * On POST, add the current user to the group
110 * @param array $args unused
114 function handle($args)
116 parent::handle($args);
118 $cur = common_current_user();
120 Profile_tag_subscription::remove($this->peopletag, $cur);
122 if ($this->boolean('ajax')) {
123 $this->startHTML('text/xml;charset=utf-8');
124 $this->elementStart('head');
125 // TRANS: Page title for form that allows unsubscribing from a people tag.
126 // TRANS: %1$s is a nickname, %2$s is a people tag, %3$s is a tagger nickname.
127 $this->element('title', null, sprintf(_('%1$s unsubscribed to people tag %2$s by %3$s'),
129 $this->peopletag->tag,
130 $this->tagger->nickname));
131 $this->elementEnd('head');
132 $this->elementStart('body');
133 $lf = new SubscribePeopletagForm($this, $this->peopletag);
135 $this->elementEnd('body');
136 $this->elementEnd('html');
138 if (common_get_returnto()) {
139 common_redirect(common_get_returnto(), 303);
142 common_redirect(common_local_url('peopletagsbyuser',
143 array('nickname' => $this->tagger->nickname)),