10 * @author Evan Prodromou <evan@controlyourself.ca>
11 * @author Robin Millette <millette@controlyourself.ca>
12 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
13 * @link http://laconi.ca/
15 * Laconica - a distributed open-source microblogging tool
16 * Copyright (C) 2008, 2009, Control Yourself, Inc.
18 * This program is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU Affero General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU Affero General Public License for more details.
28 * You should have received a copy of the GNU Affero General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 if (!defined('LACONICA')) {
36 require_once INSTALLDIR.'/lib/omb.php';
37 require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
38 require_once INSTALLDIR.'/extlib/libomb/xrds_mapper.php';
45 * @author Evan Prodromou <evan@controlyourself.ca>
46 * @author Robin Millette <millette@controlyourself.ca>
47 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
48 * @link http://laconi.ca/
50 class XrdsAction extends Action
55 * @return boolean true
65 * @param array $args query arguments
69 function handle($args)
71 parent::handle($args);
72 $nickname = $this->trimmed('nickname');
73 $user = User::staticGet('nickname', $nickname);
75 $this->clientError(_('No such user.'));
78 $this->showXrds($user);
82 * Show XRDS for a user.
84 * @param class $user XRDS for this user.
88 function showXrds($user)
90 $srv = new OMB_Service_Provider(profile_to_omb_profile($user->uri,
91 $user->getProfile()));
92 /* Use libomb’s default XRDS Writer. */
94 $srv->writeXRDS(new Laconica_XRDS_Mapper(), $xrds_writer);
98 class Laconica_XRDS_Mapper implements OMB_XRDS_Mapper
102 public function __construct()
105 OAUTH_ENDPOINT_REQUEST => 'requesttoken',
106 OAUTH_ENDPOINT_AUTHORIZE => 'userauthorization',
107 OAUTH_ENDPOINT_ACCESS => 'accesstoken',
108 OMB_ENDPOINT_POSTNOTICE => 'postnotice',
109 OMB_ENDPOINT_UPDATEPROFILE => 'updateprofile');
112 public function getURL($action)
114 return common_local_url($this->urls[$action]);