3 * GNU social - a federating social network
5 * Class for deleting a notice
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.
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.
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/>.
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
30 if (!defined('GNUSOCIAL')) { exit(1); }
32 class ActivityverbAction extends ManagedAction
34 protected $needLogin = true;
35 protected $canPost = true;
37 protected $verb = null;
39 public function title()
42 Event::handle('ActivityVerbTitle', array($this, $this->verb, $this->notice, $this->scoped, &$title));
46 protected function doPreparation()
48 $this->verb = $this->trimmed('verb');
49 if (empty($this->verb)) {
50 throw new ServerException('A verb has not been specified.');
53 $this->notice = Notice::getByID($this->trimmed('id'));
55 if (!$this->notice->inScope($this->scoped)) {
56 // TRANS: %1$s is a user nickname, %2$d is a notice ID (number).
57 throw new ClientException(sprintf(_('%1$s has no access to notice %2$d.'),
58 $this->scoped->getNickname(), $this->notice->getID()), 403);
61 Event::handle('ActivityVerbDoPreparation', array($this, $this->verb, $this->notice, $this->scoped));
64 protected function doPost()
66 if (Event::handle('ActivityVerbDoPost', array($this, $this->verb, $this->notice, $this->scoped))) {
67 // TRANS: Error when a POST method for an activity verb has not been handled by a plugin.
68 throw new ClientException(sprintf(_('Could not handle POST for verb "%1$s".'), $this->verb));
72 protected function showContent()
74 if (Event::handle('ActivityVerbShowContent', array($this, $this->verb, $this->notice, $this->scoped))) {
75 // TRANS: Error when a page for an activity verb has not been handled by a plugin.
76 $this->element('div', 'error', sprintf(_('Could not show content for verb "%1$s".'), $this->verb));