]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/atomusernoticefeed.php
Pass auth user into Atom feed generators (needed for outputting favorited status...
[quix0rs-gnu-social.git] / lib / atomusernoticefeed.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Class for building an in-memory Atom feed for a particular user's
6  * timeline.
7  *
8  * PHP version 5
9  *
10  * LICENCE: This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  * @category  Feed
24  * @package   StatusNet
25  * @author    Zach Copley <zach@status.net>
26  * @copyright 2010 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET'))
32 {
33     exit(1);
34 }
35
36 /**
37  * Class for user notice feeds.  May contain a reference to the user.
38  *
39  * @category Feed
40  * @package  StatusNet
41  * @author   Zach Copley <zach@status.net>
42  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43  * @link     http://status.net/
44  */
45 class AtomUserNoticeFeed extends AtomNoticeFeed
46 {
47     private $user;
48
49     /**
50      * Constructor
51      *
52      * @param User    $user    the user for the feed
53      * @param User    $cur     the current authenticated user, if any
54      * @param boolean $indent  flag to turn indenting on or off
55      *
56      * @return void
57      */
58
59     function __construct($user, $cur = null, $indent = true) {
60         parent::__construct($cur, $indent);
61         $this->user = $user;
62         if (!empty($user)) {
63             $profile = $user->getProfile();
64             $this->addAuthor($profile->nickname, $user->uri);
65             $this->setActivitySubject($profile->asActivityNoun('subject'));
66         }
67
68         $title      = sprintf(_("%s timeline"), $user->nickname);
69         $this->setTitle($title);
70
71         $sitename   = common_config('site', 'name');
72         $subtitle   = sprintf(
73             _('Updates from %1$s on %2$s!'),
74             $user->nickname, $sitename
75         );
76         $this->setSubtitle($subtitle);
77
78         $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
79         $logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
80         $this->setLogo($logo);
81
82         $this->setUpdated('now');
83
84         $this->addLink(
85             common_local_url(
86                 'showstream',
87                 array('nickname' => $user->nickname)
88             )
89         );
90         
91         $self = common_local_url('ApiTimelineUser',
92                                  array('id' => $user->id,
93                                        'format' => 'atom'));
94         $this->setId($self);
95         $this->setSelfLink($self);
96
97         $this->addLink(
98             common_local_url('sup', null, null, $user->id),
99             array(
100                 'rel' => 'http://api.friendfeed.com/2008/03#sup',
101                 'type' => 'application/json'
102             )
103         );
104     }
105
106     function getUser()
107     {
108         return $this->user;
109     }
110
111     function showSource()
112     {
113         return false;
114     }
115
116     function showAuthor()
117     {
118         return false;
119     }
120 }