]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/repeat.php
Merge branch 'fixes/private_scope_on_tags' into social-master
[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('GNUSOCIAL')) { exit(1); }
31
32 /**
33  * Repeat action
34  *
35  * @category Action
36  * @package  StatusNet
37  * @author   Evan Prodromou <evan@status.net>
38  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
39  * @link     http://status.net/
40  */
41 class RepeatAction extends FormAction
42 {
43     protected $needPost = true; // At least for now, until repeat interface is available
44
45     protected $notice = null;   // Notice that is being repeated.
46     protected $repeat = null;   // The resulting repeat object/notice.
47
48     protected function prepare(array $args=array())
49     {
50         parent::prepare($args);
51
52         $id = $this->trimmed('notice');
53
54         if (empty($id)) {
55             // TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID.
56             $this->clientError(_('No notice specified.'));
57         }
58
59         $this->notice = Notice::getKV('id', $id);
60
61         if (!$this->notice instanceof Notice) {
62             // TRANS: Client error displayed when trying to repeat a non-existing notice.
63             $this->clientError(_('Notice not found.'));
64         }
65
66         $this->repeat = $this->notice->repeat($this->scoped, 'web');
67         if (!$this->repeat instanceof Notice) {
68             // TRANS: Error when unable to repeat a notice for unknown reason.
69             $this->clientError(_('Could not repeat notice for unknown reason. Please contact the webmaster!'));
70         }
71
72         return true;
73     }
74
75     /**
76      * Class handler.
77      *
78      * @param array $args query arguments
79      *
80      * @return void
81      */
82     protected function showContent()
83     {
84         $this->element('p', array('id' => 'repeat_response',
85                                   'class' => 'repeated'),
86                             // TRANS: Confirmation text after repeating a notice.
87                             _('Repeated!'));
88     }
89 }