]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/repeat.php
Protected function prepare with array $args defaulting to array()
[quix0rs-gnu-social.git] / actions / repeat.php
1 <?php
2 /**
3  * Repeat action.
4  *
5  * PHP version 5
6  *
7  * @category Action
8  * @package  StatusNet
9  * @author   Evan Prodromou <evan@status.net>
10  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11  * @link     http://status.net/
12  *
13  * StatusNet - the distributed open-source microblogging tool
14  * Copyright (C) 2008, 2009, StatusNet, Inc.
15  *
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.
20  *
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.
25  *
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/>.
28  */
29
30 if (!defined('STATUSNET')) {
31     exit(1);
32 }
33
34 /**
35  * Repeat action
36  *
37  * @category Action
38  * @package  StatusNet
39  * @author   Evan Prodromou <evan@status.net>
40  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
41  * @link     http://status.net/
42  */
43 class RepeatAction extends Action
44 {
45     var $user = null;
46     var $notice = null;
47
48     protected $needLogin = true;
49
50     protected function prepare(array $args=array())
51     {
52         parent::prepare($args);
53
54         $id = $this->trimmed('notice');
55
56         if (empty($id)) {
57             // TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID.
58             $this->clientError(_('No notice specified.'));
59             return false;
60         }
61
62         $this->notice = Notice::getKV('id', $id);
63
64         if (!($this->notice instanceof Notice)) {
65             // TRANS: Client error displayed when trying to repeat a non-existing notice.
66             $this->clientError(_('No notice specified.'));
67             return false;
68         }
69
70         $token = $this->trimmed('token-'.$id);
71
72         if (empty($token) || $token != common_session_token()) {
73             // TRANS: Client error displayed when the session token does not match or is not given.
74             $this->clientError(_('There was a problem with your session token. Try again, please.'));
75             return false;
76         }
77
78         return true;
79     }
80
81     /**
82      * Class handler.
83      *
84      * @param array $args query arguments
85      *
86      * @return void
87      */
88     protected function handle()
89     {
90         parent::handle();
91
92         $repeat = $this->notice->repeat($this->scoped->id, 'web');
93
94         if ($this->boolean('ajax')) {
95             $this->startHTML('text/xml;charset=utf-8');
96             $this->elementStart('head');
97             // TRANS: Title after repeating a notice.
98             $this->element('title', null, _('Repeated'));
99             $this->elementEnd('head');
100             $this->elementStart('body');
101             $this->element('p', array('id' => 'repeat_response',
102                                       'class' => 'repeated'),
103                                 // TRANS: Confirmation text after repeating a notice.
104                                 _('Repeated!'));
105             $this->elementEnd('body');
106             $this->endHTML();
107         } else {
108             // @todo FIXME!
109         }
110     }
111 }