]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/userrss.php
Merge remote-tracking branch 'upstream/master' into social-master
[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('STATUSNET') && !defined('LACONICA')) { exit(1); }
21
22 require_once(INSTALLDIR.'/lib/rssaction.php');
23
24 // Formatting of RSS handled by Rss10Action
25
26 class UserrssAction extends Rss10Action
27 {
28     var $tag  = null;
29
30     function prepare(array $args=array())
31     {
32         parent::prepare($args);
33         $nickname   = $this->trimmed('nickname');
34         $this->user = User::getKV('nickname', $nickname);
35         $this->tag  = $this->trimmed('tag');
36
37         if (!$this->user) {
38             // TRANS: Client error displayed when user not found for an action.
39             $this->clientError(_('No such user.'));
40         }
41
42         if (!empty($this->tag)) {
43             $this->notices = $this->getTaggedNotices();
44         } else {
45             $this->notices = $this->getNotices();
46         }
47
48         return true;
49     }
50
51     function getTaggedNotices()
52     {
53         $notice = $this->user->getTaggedNotices(
54             $this->tag,
55             0,
56             ($this->limit == 0) ? NOTICES_PER_PAGE : $this->limit,
57             0,
58             0
59         );
60
61         $notices = array();
62         while ($notice->fetch()) {
63             $notices[] = clone($notice);
64         }
65
66         return $notices;
67     }
68
69
70     function getNotices()
71     {
72         $notice = $this->user->getNotices(
73             0,
74             ($this->limit == 0) ? NOTICES_PER_PAGE : $this->limit
75         );
76
77         $notices = array();
78         while ($notice->fetch()) {
79             $notices[] = clone($notice);
80         }
81
82         return $notices;
83     }
84
85     function getChannel()
86     {
87         $user = $this->user;
88         $profile = $user->getProfile();
89         $c = array('url' => common_local_url('userrss',
90                                              array('nickname' =>
91                                                    $user->nickname)),
92                    // TRANS: Message is used as link title. %s is a user nickname.
93                    'title' => sprintf(_('%s timeline'), $user->nickname),
94                    'link' => $profile->profileurl,
95                    // TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
96                    'description' => sprintf(_('Updates from %1$s on %2$s!'),
97                                             $user->nickname, common_config('site', 'name')));
98         return $c;
99     }
100
101     function getImage()
102     {
103         $profile = $this->user->getProfile();
104         return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
105     }
106
107     // override parent to add X-SUP-ID URL
108
109     function initRss($limit=0)
110     {
111         $url = common_local_url('sup', null, null, $this->user->id);
112         header('X-SUP-ID: '.$url);
113         parent::initRss($limit);
114     }
115
116     function isReadOnly(array $args=array())
117     {
118         return true;
119     }
120 }