]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/repeat.php
Translator comments added
[quix0rs-gnu-social.git] / actions / repeat.php
1 <?php
2
3 /**
4  * Repeat action.
5  *
6  * PHP version 5
7  *
8  * @category Action
9  * @package  StatusNet
10  * @author   Evan Prodromou <evan@status.net>
11  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12  * @link     http://status.net/
13  *
14  * StatusNet - the distributed open-source microblogging tool
15  * Copyright (C) 2008, 2009, StatusNet, Inc.
16  *
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.
21  *
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.
26  *
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/>.
29  */
30
31 if (!defined('STATUSNET')) {
32     exit(1);
33 }
34
35 /**
36  * Repeat action
37  *
38  * @category Action
39  * @package  StatusNet
40  * @author   Evan Prodromou <evan@status.net>
41  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
42  * @link     http://status.net/
43  */
44 class RepeatAction extends Action
45 {
46     var $user = null;
47     var $notice = null;
48
49     function prepare($args)
50     {
51         parent::prepare($args);
52
53         $this->user = common_current_user();
54
55         if (empty($this->user)) {
56             $this->clientError(_('Only logged-in users can repeat notices.'));
57             return false;
58         }
59
60         $id = $this->trimmed('notice');
61
62         if (empty($id)) {
63             $this->clientError(_('No notice specified.'));
64             return false;
65         }
66
67         $this->notice = Notice::staticGet('id', $id);
68
69         if (empty($this->notice)) {
70             $this->clientError(_('No notice specified.'));
71             return false;
72         }
73
74         if ($this->user->id == $this->notice->profile_id) {
75             $this->clientError(_("You cannot repeat your own notice."));
76             return false;
77         }
78
79         $token  = $this->trimmed('token-'.$id);
80
81         if (empty($token) || $token != common_session_token()) {
82             $this->clientError(_('There was a problem with your session token. Try again, please.'));
83             return false;
84         }
85
86         $profile = $this->user->getProfile();
87
88         if ($profile->hasRepeated($id)) {
89             $this->clientError(_('You already repeated that notice.'));
90             return false;
91         }
92
93         return true;
94     }
95
96     /**
97      * Class handler.
98      *
99      * @param array $args query arguments
100      *
101      * @return void
102      */
103     function handle($args)
104     {
105         $repeat = $this->notice->repeat($this->user->id, 'web');
106
107
108
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'),
117                                 _('Repeated!'));
118             $this->elementEnd('body');
119             $this->elementEnd('html');
120         } else {
121             // FIXME!
122         }
123     }
124 }