]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/userbyid.php
Merge branch 'testing'
[quix0rs-gnu-social.git] / actions / userbyid.php
1 <?php
2
3 /**
4  * User by ID action class.
5  *
6  * PHP version 5
7  *
8  * @category Action
9  * @package  StatusNet
10  * @author   Evan Prodromou <evan@status.net>
11  * @author   Robin Millette <millette@status.net>
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('STATUSNET') && !defined('LACONICA')) {
33     exit(1);
34 }
35
36 /**
37  * User by ID action class.
38  *
39  * @category Action
40  * @package  StatusNet
41  * @author   Evan Prodromou <evan@status.net>
42  * @author   Robin Millette <millette@status.net>
43  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
44  * @link     http://status.net/
45  */
46 class UserbyidAction extends Action
47 {
48      /**
49      * Is read only?
50      *
51      * @return boolean true
52      */
53     function isReadOnly($args)
54     {
55         return true;
56     }
57
58      /**
59      * Class handler.
60      *
61      * @param array $args array of arguments
62      *
63      * @return nothing
64      */
65     function handle($args)
66     {
67         parent::handle($args);
68         $id = $this->trimmed('id');
69         if (!$id) {
70             $this->clientError(_('No ID.'));
71         }
72         $user = User::staticGet($id);
73         if (!$user) {
74             $this->clientError(_('No such user.'));
75         }
76
77         // Support redirecting to FOAF rdf/xml if the agent prefers it...
78         // Internet Explorer doesn't specify "text/html" and does list "*/*"
79         // at least through version 8. We need to list text/html up front to
80         // ensure that only user-agents who specifically ask for RDF get it.
81         $page_prefs = 'text/html,application/xhtml+xml,application/rdf+xml,application/xml;q=0.3,text/xml;q=0.2';
82         $httpaccept = isset($_SERVER['HTTP_ACCEPT'])
83                       ? $_SERVER['HTTP_ACCEPT'] : null;
84         $type       = common_negotiate_type(common_accept_to_prefs($httpaccept),
85                       common_accept_to_prefs($page_prefs));
86         $page       = $type == 'application/rdf+xml' ? 'foaf' : 'showstream';
87         $url        = common_local_url($page, array('nickname' => $user->nickname));
88         common_redirect($url, 303);
89     }
90 }