]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/publicxrds.php
change laconi.ca to status.net
[quix0rs-gnu-social.git] / actions / publicxrds.php
1 <?php
2
3 /**
4  * Public XRDS for OpenID
5  *
6  * PHP version 5
7  *
8  * @category Action
9  * @package  StatusNet
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://status.net/
14  *
15  * StatusNet - the distributed open-source microblogging tool
16  * Copyright (C) 2008, 2009, StatusNet, Inc.
17  *
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.
22  *
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.
27  *
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/>.
30  */
31
32 if (!defined('LACONICA')) {
33     exit(1);
34 }
35
36 require_once INSTALLDIR.'/lib/openid.php';
37
38 /**
39  * Public XRDS for OpenID
40  *
41  * @category Action
42  * @package  StatusNet
43  * @author   Evan Prodromou <evan@controlyourself.ca>
44  * @author   Robin Millette <millette@controlyourself.ca>
45  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
46  * @link     http://status.net/
47  *
48  * @todo factor out similarities with XrdsAction
49  */
50 class PublicxrdsAction extends Action
51 {
52     /**
53      * Is read only?
54      *
55      * @return boolean true
56      */
57     function isReadOnly($args)
58     {
59         return true;
60     }
61
62     /**
63      * Class handler.
64      *
65      * @param array $args array of arguments
66      *
67      * @return nothing
68      */
69     function handle($args)
70     {
71         parent::handle($args);
72         header('Content-Type: application/xrds+xml');
73         $this->startXML();
74         $this->elementStart('XRDS', array('xmlns' => 'xri://$xrds'));
75         $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
76                                           'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
77                                           'version' => '2.0'));
78         $this->element('Type', null, 'xri://$xrds*simple');
79         foreach (array('finishopenidlogin', 'finishaddopenid') as $finish) {
80             $this->showService(Auth_OpenID_RP_RETURN_TO_URL_TYPE,
81                                 common_local_url($finish));
82         }
83         $this->elementEnd('XRD');
84         $this->elementEnd('XRDS');
85         $this->endXML();
86     }
87
88     /**
89      * Show service.
90      *
91      * @param string $type    XRDS type
92      * @param string $uri     URI
93      * @param array  $params  type parameters, null by default
94      * @param array  $sigs    type signatures, null by default
95      * @param string $localId local ID, null by default
96      *
97      * @return void
98      */
99     function showService($type, $uri, $params=null, $sigs=null, $localId=null)
100     {
101         $this->elementStart('Service');
102         if ($uri) {
103             $this->element('URI', null, $uri);
104         }
105         $this->element('Type', null, $type);
106         if ($params) {
107             foreach ($params as $param) {
108                 $this->element('Type', null, $param);
109             }
110         }
111         if ($sigs) {
112             foreach ($sigs as $sig) {
113                 $this->element('Type', null, $sig);
114             }
115         }
116         if ($localId) {
117             $this->element('LocalID', null, $localId);
118         }
119         $this->elementEnd('Service');
120     }
121 }
122