]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/favoritesrss.php
Merge branch 'master' of ssh://zach@dev.controlyourself.ca/var/www/trunk
[quix0rs-gnu-social.git] / actions / favoritesrss.php
1 <?php
2
3 /**
4  * RSS feed for user favorites action class.
5  *
6  * PHP version 5
7  *
8  * @category Action
9  * @package  Laconica
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/
14  *
15  * Laconica - a distributed open-source microblogging tool
16  * Copyright (C) 2008, Controlez-Vous, 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/rssaction.php';
37
38 /**
39  * RSS feed for user favorites action class.
40  *
41  * Formatting of RSS handled by Rss10Action
42  *
43  * @category Action
44  * @package  Laconica
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/
49  */
50 class FavoritesrssAction extends Rss10Action
51 {
52     var $user = null;
53     
54     /**
55      * Initialization.
56      * 
57      * @return boolean false if user doesn't exist
58      */
59     function init()
60     {
61         $nickname   = $this->trimmed('nickname');
62         $this->user = User::staticGet('nickname', $nickname);
63         if (!$this->user) {
64             $this->clientError(_('No such user.'));
65             return false;
66         } else {
67             return true;
68         }
69     }
70
71     /**
72      * Get notices
73      *
74      * @param integer $limit max number of notices to return
75      *
76      * @return array notices
77      */
78     function getNotices($limit=0)
79     {
80         $user    = $this->user;
81         $notice  = $user->favoriteNotices(0, $limit);
82         $notices = array();
83         while ($notice->fetch()) {
84             $notices[] = clone($notice);
85         }
86         return $notices;
87     }
88
89      /**
90      * Get channel.
91      *
92      * @return array associative array on channel information
93      */
94     function getChannel()
95     {
96         $user = $this->user;
97         $c     = array('url' => common_local_url('favoritesrss',
98                                              array('nickname' =>
99                                                    $user->nickname)),
100                    'title' => sprintf(_("%s favorite notices"), $user->nickname),
101                    'link' => common_local_url('showfavorites',
102                                              array('nickname' =>
103                                                    $user->nickname)),
104                    'description' => sprintf(_('Feed of favorite notices of %s'), $user->nickname));
105         return $c;
106     }
107
108     /**
109      * Get image.
110      *
111      * @return voir
112     */
113     function getImage()
114     {
115         return null;
116     }
117
118     function isReadOnly()
119     {
120         return true;
121     }
122 }
123