]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/grouprss.php
Improved type-hint for following methods:
[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('STATUSNET') && !defined('LACONICA')) {
32     exit(1);
33 }
34
35 require_once INSTALLDIR.'/lib/rssaction.php';
36
37 define('MEMBERS_PER_SECTION', 27);
38
39 /**
40  * Group RSS feed
41  *
42  * @category Group
43  * @package  StatusNet
44  * @author   Evan Prodromou <evan@status.net>
45  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
46  * @link     http://status.net/
47  */
48 class groupRssAction extends Rss10Action
49 {
50     /** group we're viewing. */
51     var $group = null;
52
53     /**
54      * Is this page read-only?
55      *
56      * @return boolean true
57      */
58     function isReadOnly(array $args=array())
59     {
60         return true;
61     }
62
63     /**
64      * Prepare the action
65      *
66      * Reads and validates arguments and instantiates the attributes.
67      *
68      * @param array $args $_REQUEST args
69      *
70      * @return boolean success flag
71      */
72     function prepare(array $args=array())
73     {
74         parent::prepare($args);
75
76         $nickname_arg = $this->arg('nickname');
77         $nickname = common_canonical_nickname($nickname_arg);
78
79         // Permanent redirect on non-canonical nickname
80
81         if ($nickname_arg != $nickname) {
82             $args = array('nickname' => $nickname);
83             common_redirect(common_local_url('showgroup', $args), 301);
84         }
85
86         if (!$nickname) {
87             // TRANS: Client error displayed when requesting a group RSS feed without providing a group nickname.
88             $this->clientError(_('No nickname.'), 404);
89         }
90
91         $local = Local_group::getKV('nickname', $nickname);
92
93         if (!$local) {
94             // TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
95             $this->clientError(_('No such group.'), 404);
96         }
97
98         $this->group = User_group::getKV('id', $local->group_id);
99
100         if (!$this->group) {
101             // TRANS: Client error displayed when requesting a group RSS feed for an object that is not a group.
102             $this->clientError(_('No such group.'), 404);
103         }
104
105         $this->notices = $this->getNotices($this->limit);
106         return true;
107     }
108
109     function getNotices($limit=0)
110     {
111         $group = $this->group;
112
113         if (is_null($group)) {
114             return null;
115         }
116
117         $notices = array();
118         $notice = $group->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
119
120         while ($notice->fetch()) {
121             $notices[] = clone($notice);
122         }
123
124         return $notices;
125     }
126
127     function getChannel()
128     {
129         $group = $this->group;
130         $c = array('url' => common_local_url('grouprss',
131                                              array('nickname' =>
132                                                    $group->nickname)),
133                    // TRANS: Message is used as link title. %s is a user nickname.
134                    'title' => sprintf(_('%s timeline'), $group->nickname),
135                    'link' => common_local_url('showgroup', array('nickname' => $group->nickname)),
136                    // TRANS: Message is used as link description. %1$s is a group name, %2$s is a site name.
137                    'description' => sprintf(_('Updates from members of %1$s on %2$s!'),
138                                             $group->nickname, common_config('site', 'name')));
139         return $c;
140     }
141
142     function getImage()
143     {
144         return $this->group->homepage_logo;
145     }
146 }