]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/favoritesrss.php
Merge remote branch 'gitorious/1.0.x' into 1.0.x
[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  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 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  StatusNet
45  * @author   Evan Prodromou <evan@status.net>
46  * @author   Robin Millette <millette@status.net>
47  * @author   Zach Copley <zach@status.net>
48  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
49  * @link     http://status.net/
50  */
51 class FavoritesrssAction extends Rss10Action
52 {
53
54     /** The user whose favorites to display */
55
56     var $user = null;
57
58     /**
59      * Find the user to display by supplied nickname
60      *
61      * @param array $args Arguments from $_REQUEST
62      *
63      * @return boolean success
64      */
65
66     function prepare($args)
67     {
68         parent::prepare($args);
69
70         $nickname   = $this->trimmed('nickname');
71         $this->user = User::staticGet('nickname', $nickname);
72
73         if (!$this->user) {
74             $this->clientError(_('No such user.'));
75             return false;
76         } else {
77             $this->notices = $this->getNotices($this->limit);
78             return true;
79         }
80     }
81
82     /**
83      * Get notices
84      *
85      * @param integer $limit max number of notices to return
86      *
87      * @return array notices
88      */
89     function getNotices($limit=0)
90     {
91         $user    = $this->user;
92         $notice  = $user->favoriteNotices(false, 0, $limit);
93         $notices = array();
94         while ($notice->fetch()) {
95             $notices[] = clone($notice);
96         }
97         return $notices;
98     }
99
100      /**
101      * Get channel.
102      *
103      * @return array associative array on channel information
104      */
105     function getChannel()
106     {
107         $user = $this->user;
108         $c    = array('url' => common_local_url('favoritesrss',
109                                         array('nickname' =>
110                                         $user->nickname)),
111                    'title' => sprintf(_("%s's favorite notices"), $user->nickname),
112                    'link' => common_local_url('showfavorites',
113                                         array('nickname' =>
114                                         $user->nickname)),
115                    'description' => sprintf(_('Updates favored by %1$s on %2$s!'),
116                                         $user->nickname, common_config('site', 'name')));
117         return $c;
118     }
119
120     /**
121      * Get image.
122      *
123      * @return void
124     */
125     function getImage()
126     {
127         return null;
128     }
129
130 }