9 * @author Evan Prodromou <evan@status.net>
10 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11 * @link http://status.net/
13 * StatusNet - the distributed open-source microblogging tool
14 * Copyright (C) 2008, 2009, StatusNet, Inc.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Affero General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Affero General Public License for more details.
26 * You should have received a copy of the GNU Affero General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 if (!defined('STATUSNET')) {
39 * @author Evan Prodromou <evan@status.net>
40 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
41 * @link http://status.net/
43 class RepeatAction extends Action
48 function prepare($args)
50 parent::prepare($args);
52 $this->user = common_current_user();
54 if (empty($this->user)) {
55 // TRANS: Client error displayed when trying to repeat a notice while not logged in.
56 $this->clientError(_('Only logged-in users can repeat notices.'));
60 $id = $this->trimmed('notice');
63 // TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID.
64 $this->clientError(_('No notice specified.'));
68 $this->notice = Notice::staticGet('id', $id);
70 if (empty($this->notice)) {
71 // TRANS: Client error displayed when trying to repeat a non-existing notice.
72 $this->clientError(_('No notice specified.'));
76 if ($this->user->id == $this->notice->profile_id) {
77 // TRANS: Client error displayed when trying to repeat an own notice.
78 $this->clientError(_('You cannot repeat your own notice.'));
82 $token = $this->trimmed('token-'.$id);
84 if (empty($token) || $token != common_session_token()) {
85 $this->clientError(_('There was a problem with your session token. Try again, please.'));
89 $profile = $this->user->getProfile();
91 if ($profile->hasRepeated($id)) {
92 // TRANS: Client error displayed when trying to repeat an already repeated notice.
93 $this->clientError(_('You already repeated that notice.'));
103 * @param array $args query arguments
107 function handle($args)
109 $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 // TRANS: Title after repeating a notice.
115 $this->element('title', null, _('Repeated'));
116 $this->elementEnd('head');
117 $this->elementStart('body');
118 $this->element('p', array('id' => 'repeat_response',
119 'class' => 'repeated'),
120 // TRANS: Confirmation text after repeating a notice.
122 $this->elementEnd('body');
123 $this->elementEnd('html');