3 * GNU social - a federating social network
4 * Copyright (C) 2015, Free Software Foundation, Inc.
5 * Copyright (C) before that, StatusNet, Inc.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
23 abstract class AtompubAction extends ApiAuthAction
25 protected $_profile = null;
26 protected $target = null;
28 protected function prepare(array $args=array())
30 parent::prepare($args);
32 return $this->atompubPrepare();
35 protected function atompubPrepare() {
39 protected function handle()
43 switch ($_SERVER['REQUEST_METHOD']) {
54 $this->handleDelete();
57 // TRANS: Client exception thrown when using an unsupported HTTP method.
58 throw new ClientException(_('HTTP method not supported.'), 405);
64 protected function handleHead()
69 protected function handleGet()
71 throw new ClientException(_('HTTP method not supported.'), 405);
74 protected function handlePost()
76 throw new ClientException(_('HTTP method not supported.'), 405);
79 protected function handleDelete()
81 throw new ClientException(_('HTTP method not supported.'), 405);
84 function isReadOnly($args)
86 // GET/HEAD is readonly, POST and DELETE (etc?) are readwrite.
87 return in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD'));
90 function requiresAuth()
92 // GET/HEAD don't require auth, POST and DELETE (etc?) require it.
93 return !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD'));