3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2010, StatusNet, Inc.
6 * Download a backup of your own account to the browser
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Evan Prodromou <evan@status.net>
26 * @copyright 2010 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28 * @link http://status.net/
31 if (!defined('GNUSOCIAL')) { exit(1); }
34 * Download a backup of your own account to the browser
36 * We go through some hoops to make this only respond to POST, since
37 * it's kind of expensive and there's probably some downside to having
38 * your account in all kinds of search engines.
42 * @author Evan Prodromou <evan@status.net>
43 * @copyright 2010 StatusNet, Inc.
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
45 * @link http://status.net/
47 class BackupaccountAction extends FormAction
49 protected $form = 'BackupAccount';
53 // TRANS: Title for backup account page.
54 return _('Backup account');
57 protected function doPreparation()
59 if (!$this->scoped->hasRight(Right::BACKUPACCOUNT)) {
60 // TRANS: Client exception thrown when trying to backup an account without having backup rights.
61 throw new ClientException(_('You may not backup your account.'), 403);
67 protected function doPost()
69 $stream = new UserActivityStream($this->scoped->getUser(), true, UserActivityStream::OUTPUT_RAW);
71 header('Content-Disposition: attachment; filename='.urlencode($this->scoped->getNickname()).'.atom');
72 header('Content-Type: application/atom+xml; charset=utf-8');
74 // @fixme atom feed logic is in getString...
75 // but we just want it to output to the outputter.
76 $this->raw($stream->getString());
79 public function isReadOnly($args) {
83 function lastModified()
85 // For comparison with If-Last-Modified
86 // If not applicable, return null