]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/grouprss.php
/:nickname/all/rss had to be before /:tagger/all/:tag
[quix0rs-gnu-social.git] / actions / grouprss.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Group main page
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Group
23  * @package   StatusNet
24  * @author    Evan Prodromou <evan@status.net>
25  * @author    Sarven Capadisli <csarven@status.net>
26  * @copyright 2008-2009 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('GNUSOCIAL')) { exit(1); }
32
33 define('MEMBERS_PER_SECTION', 27);
34
35 /**
36  * Group RSS feed
37  *
38  * @category Group
39  * @package  StatusNet
40  * @author   Evan Prodromou <evan@status.net>
41  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
42  * @link     http://status.net/
43  */
44 class groupRssAction extends Rss10Action
45 {
46     /** group we're viewing. */
47     var $group = null;
48
49     /**
50      * Is this page read-only?
51      *
52      * @return boolean true
53      */
54     function isReadOnly($args)
55     {
56         return true;
57     }
58
59     /**
60      * Prepare the action
61      *
62      * Reads and validates arguments and instantiates the attributes.
63      *
64      * @param array $args $_REQUEST args
65      *
66      * @return boolean success flag
67      */
68     function prepare($args)
69     {
70         parent::prepare($args);
71
72         $nickname_arg = $this->arg('nickname');
73         $nickname = common_canonical_nickname($nickname_arg);
74
75         // Permanent redirect on non-canonical nickname
76
77         if ($nickname_arg != $nickname) {
78             $args = array('nickname' => $nickname);
79             common_redirect(common_local_url('showgroup', $args), 301);
80         }
81
82         if (!$nickname) {
83             // TRANS: Client error displayed when requesting a group RSS feed without providing a group nickname.
84             $this->clientError(_('No nickname.'), 404);
85         }
86
87         $local = Local_group::getKV('nickname', $nickname);
88
89         if (!$local) {
90             // TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
91             $this->clientError(_('No such group.'), 404);
92         }
93
94         $this->group = User_group::getKV('id', $local->group_id);
95
96         if (!$this->group) {
97             // TRANS: Client error displayed when requesting a group RSS feed for an object that is not a group.
98             $this->clientError(_('No such group.'), 404);
99         }
100
101         $this->notices = $this->getNotices($this->limit);
102         return true;
103     }
104
105     function getNotices($limit=0)
106     {
107         $group = $this->group;
108
109         if (is_null($group)) {
110             return null;
111         }
112
113         $notices = array();
114         $notice = $group->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
115
116         while ($notice->fetch()) {
117             $notices[] = clone($notice);
118         }
119
120         return $notices;
121     }
122
123     function getChannel()
124     {
125         $group = $this->group;
126         $c = array('url' => common_local_url('grouprss',
127                                              array('nickname' =>
128                                                    $group->nickname)),
129                    // TRANS: Message is used as link title. %s is a user nickname.
130                    'title' => sprintf(_('%s timeline'), $group->nickname),
131                    'link' => common_local_url('showgroup', array('nickname' => $group->nickname)),
132                    // TRANS: Message is used as link description. %1$s is a group name, %2$s is a site name.
133                    'description' => sprintf(_('Updates from members of %1$s on %2$s!'),
134                                             $group->nickname, common_config('site', 'name')));
135         return $c;
136     }
137
138     function getImage()
139     {
140         return $this->group->homepage_logo;
141     }
142 }