GitHost.io will be shut down on June 1, 2019. At that point this instance will be unreachable and all data will be irrevocably deleted. More details at https://about.gitlab.com/gitlab-hosted/#githost-is-shutting-down-on-june-1st-2019

grouprss.php 3.7 KB
Newer Older
Robin Millette's avatar
Robin Millette committed
1 2
<?php
/**
3
 * StatusNet, the distributed open-source microblogging tool
Robin Millette's avatar
Robin Millette committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * Group main page
 *
 * PHP version 5
 *
 * LICENCE: 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/>.
 *
 * @category  Group
23
 * @package   StatusNet
24 25
 * @author    Evan Prodromou <evan@status.net>
 * @author    Sarven Capadisli <csarven@status.net>
26
 * @copyright 2008-2009 StatusNet, Inc.
Robin Millette's avatar
Robin Millette committed
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/
Robin Millette's avatar
Robin Millette committed
29 30
 */

31
if (!defined('GNUSOCIAL')) { exit(1); }
Robin Millette's avatar
Robin Millette committed
32

33
define('MEMBERS_PER_SECTION', 27);
Robin Millette's avatar
Robin Millette committed
34 35 36 37 38

/**
 * Group RSS feed
 *
 * @category Group
39
 * @package  StatusNet
40
 * @author   Evan Prodromou <evan@status.net>
Robin Millette's avatar
Robin Millette committed
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/
Robin Millette's avatar
Robin Millette committed
43
 */
44
class GroupRssAction extends TargetedRss10Action
Robin Millette's avatar
Robin Millette committed
45 46
{
    /** group we're viewing. */
47
    protected $group = null;
Robin Millette's avatar
Robin Millette committed
48 49 50 51 52 53

    /**
     * Is this page read-only?
     *
     * @return boolean true
     */
54
    function isReadOnly($args)
Robin Millette's avatar
Robin Millette committed
55 56 57 58
    {
        return true;
    }

59
    protected function doStreamPreparation()
Robin Millette's avatar
Robin Millette committed
60 61 62 63 64 65 66 67 68 69 70 71 72
    {

        $nickname_arg = $this->arg('nickname');
        $nickname = common_canonical_nickname($nickname_arg);

        // Permanent redirect on non-canonical nickname

        if ($nickname_arg != $nickname) {
            $args = array('nickname' => $nickname);
            common_redirect(common_local_url('showgroup', $args), 301);
        }

        if (!$nickname) {
73
            // TRANS: Client error displayed when requesting a group RSS feed without providing a group nickname.
74
            $this->clientError(_('No nickname.'), 404);
Robin Millette's avatar
Robin Millette committed
75 76
        }

77
        $local = Local_group::getKV('nickname', $nickname);
78

79
        if (!$local instanceof Local_group) {
80
            // TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
81 82 83
            $this->clientError(_('No such group.'), 404);
        }

84 85
        $this->group = $local->getGroup();
        $this->target = $this->group->getProfile();
Robin Millette's avatar
Robin Millette committed
86 87
    }

88
    protected function getNotices()
Robin Millette's avatar
Robin Millette committed
89
    {
90 91
        $stream = $this->group->getNotices(0, $this->limit);
        return $stream->fetchAll();
Robin Millette's avatar
Robin Millette committed
92 93 94 95 96 97
    }

    function getChannel()
    {
        $c = array('url' => common_local_url('grouprss',
                                             array('nickname' =>
98
                                                   $this->target->getNickname())),
99
                   // TRANS: Message is used as link title. %s is a user nickname.
100 101
                   'title' => sprintf(_('%s timeline'), $this->target->getNickname()),
                   'link' => common_local_url('showgroup', array('nickname' => $this->target->getNickname())),
102
                   // TRANS: Message is used as link description. %1$s is a group name, %2$s is a site name.
103
                   'description' => sprintf(_('Updates from members of %1$s on %2$s!'),
104
                                            $this->target->getNickname(), common_config('site', 'name')));
Robin Millette's avatar
Robin Millette committed
105 106 107 108 109 110 111 112
        return $c;
    }

    function getImage()
    {
        return $this->group->homepage_logo;
    }
}