]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ActivityVerb/actions/activityverb.php
1121056de6aa4e608074fe4496798ff3f0776813
[quix0rs-gnu-social.git] / plugins / ActivityVerb / actions / activityverb.php
1 <?php
2 /**
3  * GNU social - a federating social network
4  *
5  * Class for deleting a notice
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Plugin
23  * @package   GNUsocial
24  * @author    Mikael Nordfeldth <mmn@hethane.se>
25  * @copyright 2015 Free Software Foundaction, Inc.
26  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27  * @link      https://gnu.io/social
28  */
29
30 if (!defined('GNUSOCIAL')) { exit(1); }
31
32 class ActivityverbAction extends ManagedAction
33 {
34     protected $needLogin = true;
35     protected $canPost   = true;
36
37     protected $verb      = null;
38     
39     protected function doPreparation($args)
40     {
41         $this->verb = $this->trimmed('verb');
42         if (empty($this->verb)) {
43             throw new ServerException('A verb has not been specified.');
44         }
45
46         $this->notice = Notice::getById($this->trimmed('id'));
47
48         if (!$this->notice->inScope($this->scoped)) {
49             // TRANS: %1$s is a user nickname, %2$d is a notice ID (number).
50             throw new ClientException(sprintf(_('%1$s has no access to notice %2$d.'),
51                                         $this->scoped->getNickname(), $this->notice->getID()), 403);
52         }
53     }
54
55     protected function doPost()
56     {
57         if (Event::handle('ActivityVerbDoPost', array($this, $this->verb, $this->notice, $this->scoped))) {
58             // TRANS: Error when a POST method for an activity verb has not been handled by a plugin.
59             throw new ClientException(_('Could not show content for verb "%1$s".'));
60         }
61     }
62
63     protected function showContent()
64     {
65         if (Event::handle('ActivityVerbShowContent', array($this, $this->verb, $this->notice, $this->scoped))) {
66             // TRANS: Error when a page for an activity verb has not been handled by a plugin.
67             throw new ClientException(_('Could not show content for verb "%1$s".'));
68         }
69     }
70 }