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/
44 class RepeatAction extends Action
49 function prepare($args)
51 parent::prepare($args);
53 $this->user = common_current_user();
55 if (empty($this->user)) {
56 $this->clientError(_('Only logged-in users can repeat notices.'));
60 $id = $this->trimmed('notice');
63 $this->clientError(_('No notice specified.'));
67 $this->notice = Notice::staticGet('id', $id);
69 if (empty($this->notice)) {
70 $this->clientError(_('No notice specified.'));
74 if ($this->user->id == $this->notice->profile_id) {
75 $this->clientError(_('You cannot repeat your own notice.'));
79 $token = $this->trimmed('token-'.$id);
81 if (empty($token) || $token != common_session_token()) {
82 $this->clientError(_('There was a problem with your session token. Try again, please.'));
86 $profile = $this->user->getProfile();
88 if ($profile->hasRepeated($id)) {
89 $this->clientError(_('You already repeated that notice.'));
99 * @param array $args query arguments
103 function handle($args)
105 $repeat = $this->notice->repeat($this->user->id, 'web');
109 if ($this->boolean('ajax')) {
110 $this->startHTML('text/xml;charset=utf-8');
111 $this->elementStart('head');
112 $this->element('title', null, _('Repeated'));
113 $this->elementEnd('head');
114 $this->elementStart('body');
115 $this->element('p', array('id' => 'repeat_response',
116 'class' => 'repeated'),
118 $this->elementEnd('body');
119 $this->elementEnd('html');