3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2008, 2009, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
22 // @todo FIXME: Documentation needed.
23 class SubeditAction extends Action
27 function prepare($args)
29 parent::prepare($args);
31 if (!common_logged_in()) {
32 // TRANS: Client error displayed trying a change a subscription while not logged in.
33 $this->clientError(_('Not logged in.'));
37 $token = $this->trimmed('token');
39 if (!$token || $token != common_session_token()) {
40 $this->clientError(_('There was a problem with your session token. '.
41 'Try again, please.'));
45 $id = $this->trimmed('profile');
48 // TRANS: Client error displayed trying a change a subscription without providing a profile.
49 $this->clientError(_('No profile specified.'));
53 $this->profile = Profile::staticGet('id', $id);
55 if (!$this->profile) {
56 // TRANS: Client error displayed trying a change a subscription for a non-existant profile ID.
57 $this->clientError(_('No profile with that ID.'));
64 function handle($args)
66 parent::handle($args);
67 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
68 $cur = common_current_user();
70 $sub = Subscription::pkeyGet(array('subscriber' => $cur->id,
71 'subscribed' => $this->profile->id));
74 // TRANS: Client error displayed trying a change a subscription for a non-subscribed profile.
75 $this->clientError(_('You are not subscribed to that profile.'));
81 $sub->jabber = $this->boolean('jabber');
82 $sub->sms = $this->boolean('sms');
84 $result = $sub->update($orig);
87 common_log_db_error($sub, 'UPDATE', __FILE__);
88 // TRANS: Server error displayed when updating a subscription fails with a database error.
89 $this->serverError(_('Could not save subscription.'));
93 common_redirect(common_local_url('subscriptions',
94 array('nickname' => $cur->nickname)),