favoritesrss.php 3.52 KB
Newer Older
Evan Prodromou's avatar
Evan Prodromou committed
1
<?php
Robin Millette's avatar
Robin Millette committed
2 3 4 5 6 7 8

/**
 * RSS feed for user favorites action class.
 *
 * PHP version 5
 *
 * @category Action
9
 * @package  StatusNet
10 11
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
Robin Millette's avatar
Robin Millette committed
12
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
13
 * @link     http://status.net/
Robin Millette's avatar
Robin Millette committed
14
 *
15
 * StatusNet - the distributed open-source microblogging tool
16
 * Copyright (C) 2008, 2009, StatusNet, Inc.
Evan Prodromou's avatar
Evan Prodromou committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

32
if (!defined('STATUSNET') && !defined('LACONICA')) {
Robin Millette's avatar
Robin Millette committed
33 34
    exit(1);
}
Evan Prodromou's avatar
Evan Prodromou committed
35

Robin Millette's avatar
Robin Millette committed
36
require_once INSTALLDIR.'/lib/rssaction.php';
Evan Prodromou's avatar
Evan Prodromou committed
37

Robin Millette's avatar
Robin Millette committed
38 39 40 41 42 43
/**
 * RSS feed for user favorites action class.
 *
 * Formatting of RSS handled by Rss10Action
 *
 * @category Action
44
 * @package  StatusNet
45 46 47
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
 * @author   Zach Copley <zach@status.net>
Robin Millette's avatar
Robin Millette committed
48
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
49
 * @link     http://status.net/
Robin Millette's avatar
Robin Millette committed
50
 */
51 52
class FavoritesrssAction extends Rss10Action
{
53
    
54 55 56 57
    /** The user whose favorites to display */
    
    var $user = null;
        
Robin Millette's avatar
Robin Millette committed
58
    /**
59 60 61 62 63
     * Find the user to display by supplied nickname
     *
     * @param array $args Arguments from $_REQUEST
     *
     * @return boolean success
Robin Millette's avatar
Robin Millette committed
64
     */
65 66

    function prepare($args)
67
    {
68 69
        parent::prepare($args);
        
Robin Millette's avatar
Robin Millette committed
70
        $nickname   = $this->trimmed('nickname');
71
        $this->user = User::staticGet('nickname', $nickname);
72

73
        if (!$this->user) {
74
            $this->clientError(_('No such user.'));
75 76 77 78 79
            return false;
        } else {
            return true;
        }
    }
80
    
Robin Millette's avatar
Robin Millette committed
81 82 83 84 85 86 87 88
    /**
     * Get notices
     *
     * @param integer $limit max number of notices to return
     *
     * @return array notices
     */
    function getNotices($limit=0)
89
    {
Robin Millette's avatar
Robin Millette committed
90 91
        $user    = $this->user;
        $notice  = $user->favoriteNotices(0, $limit);
92 93 94 95 96 97
        $notices = array();
        while ($notice->fetch()) {
            $notices[] = clone($notice);
        }
        return $notices;
    }
Evan Prodromou's avatar
Evan Prodromou committed
98

Robin Millette's avatar
Robin Millette committed
99 100 101 102 103 104
     /**
     * Get channel.
     *
     * @return array associative array on channel information
     */
    function getChannel()
105
    {
106
        $user = $this->user;
107 108 109
        $c    = array('url' => common_local_url('favoritesrss',
                                        array('nickname' =>
                                        $user->nickname)),
110
                   'title' => sprintf(_("%s's favorite notices"), $user->nickname),
111
                   'link' => common_local_url('showfavorites',
112 113
                                        array('nickname' =>
                                        $user->nickname)),
114 115
                   'description' => sprintf(_('Updates favored by %1$s on %2$s!'),
                                        $user->nickname, common_config('site', 'name')));
116 117
        return $c;
    }
Evan Prodromou's avatar
Evan Prodromou committed
118

Robin Millette's avatar
Robin Millette committed
119 120 121
    /**
     * Get image.
     *
122
     * @return void
Robin Millette's avatar
Robin Millette committed
123 124
    */
    function getImage()
125
    {
Evan Prodromou's avatar
Evan Prodromou committed
126
        return null;
127
    }
128

Robin Millette's avatar
Robin Millette committed
129
}