]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Share/actions/repeat.php
repeat actions to Share plugin
[quix0rs-gnu-social.git] / plugins / Share / 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 $notice = null;   // Notice that is being repeated.
44     protected $repeat = null;   // The resulting repeat object/notice.
45
46     function title()
47     {
48         return _m('TITLE', 'Repeat notice');
49     }
50
51     protected function doPreparation()
52     {
53         $id = $this->trimmed('notice');
54
55         if (empty($id)) {
56             // TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID.
57             $this->clientError(_('No notice specified.'));
58         }
59
60         $this->notice = Notice::getKV('id', $id);
61
62         if (!$this->notice instanceof Notice) {
63             // TRANS: Client error displayed when trying to repeat a non-existing notice.
64             $this->clientError(_('Notice not found.'));
65         }
66
67         $this->repeat = $this->notice->repeat($this->scoped, 'web');
68         if (!$this->repeat instanceof Notice) {
69             // TRANS: Error when unable to repeat a notice for unknown reason.
70             $this->clientError(_('Could not repeat notice for unknown reason. Please contact the webmaster!'));
71         }
72
73         return true;
74     }
75
76     /**
77      * Class handler.
78      *
79      * @param array $args query arguments
80      *
81      * @return void
82      */
83     protected function showContent()
84     {
85         $this->element('p', array('id' => 'repeat_response',
86                                   'class' => 'repeated'),
87                             // TRANS: Confirmation text after repeating a notice.
88                             _('Repeated!'));
89     }
90 }