10 * @author Evan Prodromou <evan@status.net>
11 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12 * @link http://status.net/
14 * StatusNet - the distributed open-source microblogging tool
15 * Copyright (C) 2008, 2009, StatusNet, 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('STATUSNET')) {
40 * @author Evan Prodromou <evan@status.net>
41 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
42 * @link http://status.net/
45 class RepeatAction extends Action
50 function prepare($args)
52 parent::prepare($args);
54 $this->user = common_current_user();
56 if (empty($this->user)) {
57 $this->clientError(_('Only logged-in users can repeat notices.'));
61 $id = $this->trimmed('notice');
64 $this->clientError(_('No notice specified.'));
68 $this->notice = Notice::staticGet('id', $id);
70 if (empty($this->notice)) {
71 $this->clientError(_('No notice specified.'));
75 if ($this->user->id == $this->notice->profile_id) {
76 $this->clientError(_("You can't repeat your own notice."));
80 $token = $this->trimmed('token-'.$id);
82 if (empty($token) || $token != common_session_token()) {
83 $this->clientError(_('There was a problem with your session token. Try again, please.'));
87 $profile = $this->user->getProfile();
89 if ($profile->hasRepeated($id)) {
90 $this->clientError(_('You already repeated that notice.'));
100 * @param array $args query arguments
105 function handle($args)
107 $repeat = $this->notice->repeat($this->user->id, 'web');
111 if ($this->boolean('ajax')) {
112 $this->startHTML('text/xml;charset=utf-8');
113 $this->elementStart('head');
114 $this->element('title', null, _('Repeated'));
115 $this->elementEnd('head');
116 $this->elementStart('body');
117 $this->element('p', array('id' => 'repeat_response',
118 'class' => 'repeated'),
120 $this->elementEnd('body');
121 $this->elementEnd('html');