]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/userrss.php
fd49a0e89904df6eff0605d3430f279005090937
[quix0rs-gnu-social.git] / actions / userrss.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2008, 2009, StatusNet, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('GNUSOCIAL')) { exit(1); }
21
22 // Formatting of RSS handled by Rss10Action
23
24 class UserrssAction extends TargetedRss10Action
25 {
26     protected $tag = null;
27
28     protected function doStreamPreparation()
29     {
30         $this->tag  = $this->trimmed('tag');
31     }
32
33     protected function getNotices()
34     {
35         if (!empty($this->tag)) {
36             $stream = $this->target->getTaggedNotices($this->tag, 0, $this->limit);
37             return $stream->fetchAll();
38         }
39         // otherwise we fetch a normal user stream
40
41         $stream = $this->target->getNotices(0, $this->limit);
42         return $stream->fetchAll();
43     }
44
45     function getChannel()
46     {
47         $c = array('url' => common_local_url('userrss',
48                                              array('nickname' =>
49                                                    $this->target->getNickname())),
50                    // TRANS: Message is used as link title. %s is a user nickname.
51                    'title' => sprintf(_('%s timeline'), $this->target->getNickname()),
52                    'link' => $this->target->getUrl(),
53                    // TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
54                    'description' => sprintf(_('Updates from %1$s on %2$s!'),
55                                             $this->target->getNickname(), common_config('site', 'name')));
56         return $c;
57     }
58
59     // override parent to add X-SUP-ID URL
60
61     function initRss()
62     {
63         $url = common_local_url('sup', null, null, $this->target->getID());
64         header('X-SUP-ID: '.$url);
65         parent::initRss();
66     }
67
68     function isReadOnly($args)
69     {
70         return true;
71     }
72 }