groupbyid.php 2.79 KB
Newer Older
1 2
<?php
/**
3
 * StatusNet, the distributed open-source microblogging tool
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * Permalink for group
 *
 * 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.
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 33 34 35 36 37 38 39 40 41 42 43 44
    exit(1);
}

require_once INSTALLDIR.'/lib/noticelist.php';
require_once INSTALLDIR.'/lib/feedlist.php';

/**
 * Permalink for a group
 *
 * The group nickname can change, but not the group ID. So we use
 * an URL with the ID in it as the permanent identifier.
 *
 * @category Group
45
 * @package  StatusNet
46
 * @author   Evan Prodromou <evan@status.net>
47
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
48
 * @link     http://status.net/
49 50 51 52 53 54 55 56 57 58 59
 */
class GroupbyidAction extends Action
{
    /** group we're viewing. */
    var $group = null;

    /**
     * Is this page read-only?
     *
     * @return boolean true
     */
60
    function isReadOnly($args)
61 62 63 64 65 66 67 68 69 70 71
    {
        return true;
    }

    function prepare($args)
    {
        parent::prepare($args);

        $id = $this->arg('id');

        if (!$id) {
72
            // TRANS: Client error displayed referring to a group's permalink without providing a group ID.
73
            $this->clientError(_('No ID.'));
74 75 76 77 78 79 80 81
            return false;
        }

        common_debug("Got ID $id");

        $this->group = User_group::staticGet('id', $id);

        if (!$this->group) {
82
            // TRANS: Client error displayed referring to a group's permalink for a non-existing group ID.
83
            $this->clientError(_('No such group.'), 404);
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
            return false;
        }

        return true;
    }

    /**
     * Handle the request
     *
     * Shows a profile for the group, some controls, and a list of
     * group notices.
     *
     * @return void
     */
    function handle($args)
    {
        common_redirect($this->group->homeUrl(), 303);
    }
102
}