3 * StatusNet, the distributed open-source microblogging tool
5 * An AtomPub service document for a user
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 Evan Prodromou <evan@status.net>
25 * @copyright 2010 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
27 * @link http://status.net/
30 require_once INSTALLDIR.'/lib/apibareauth.php';
33 * Shows an AtomPub service document for a user
37 * @author Evan Prodromou <evan@status.net>
38 * @copyright 2010 StatusNet, Inc.
39 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
40 * @link http://status.net/
43 class ApiAtomServiceAction extends ApiBareAuthAction
46 * Take arguments for running
48 * @param array $args $_REQUEST args
50 * @return boolean success flag
54 function prepare($args)
56 parent::prepare($args);
57 $this->user = $this->getTargetUser($this->arg('id'));
59 if (empty($this->user)) {
60 $this->clientError(_('No such user.'), 404, $this->format);
68 * Handle the arguments. In our case, show a service document.
70 * @param Array $args unused.
75 function handle($args)
77 parent::handle($args);
79 header('Content-Type: application/atomsvc+xml');
82 $this->elementStart('service', array('xmlns' => 'http://www.w3.org/2007/app',
83 'xmlns:atom' => 'http://www.w3.org/2005/Atom',
84 'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/'));
85 $this->elementStart('workspace');
86 $this->element('atom:title', null, _('Main'));
87 $this->elementStart('collection',
88 array('href' => common_local_url('ApiTimelineUser',
89 array('id' => $this->user->id,
90 'format' => 'atom'))));
91 $this->element('atom:title',
93 sprintf(_("%s timeline"),
94 $this->user->nickname));
95 $this->element('accept', null, 'application/atom+xml;type=entry');
96 $this->element('activity:verb', null, ActivityVerb::POST);
97 $this->elementEnd('collection');
98 $this->elementStart('collection',
99 array('href' => common_local_url('AtomPubSubscriptionFeed',
100 array('subscriber' => $this->user->id))));
101 $this->element('atom:title',
103 sprintf(_("%s subscriptions"),
104 $this->user->nickname));
105 $this->element('accept', null, 'application/atom+xml;type=entry');
106 $this->element('activity:verb', null, ActivityVerb::FOLLOW);
107 $this->elementEnd('collection');
108 $this->elementStart('collection',
109 array('href' => common_local_url('AtomPubFavoriteFeed',
110 array('profile' => $this->user->id))));
111 $this->element('atom:title',
113 sprintf(_("%s favorites"),
114 $this->user->nickname));
115 $this->element('accept', null, 'application/atom+xml;type=entry');
116 $this->element('activity:verb', null, ActivityVerb::FAVORITE);
117 $this->elementEnd('collection');
118 $this->elementStart('collection',
119 array('href' => common_local_url('AtomPubMembershipFeed',
120 array('profile' => $this->user->id))));
121 $this->element('atom:title',
123 sprintf(_("%s memberships"),
124 $this->user->nickname));
125 $this->element('accept', null, 'application/atom+xml;type=entry');
126 $this->element('activity:verb', null, ActivityVerb::JOIN);
127 $this->elementEnd('collection');
128 $this->elementEnd('workspace');
129 $this->elementEnd('service');