groupmembers.php 3.29 KB
Newer Older
Evan Prodromou's avatar
Evan Prodromou committed
1 2
<?php
/**
3
 * StatusNet, the distributed open-source microblogging tool
Evan Prodromou's avatar
Evan Prodromou committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * List of group members
 *
 * 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
 * @author    Evan Prodromou <evan@status.net>
25
 * @copyright 2008-2009 StatusNet, Inc.
Evan Prodromou's avatar
Evan Prodromou committed
26
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27
 * @link      http://status.net/
Evan Prodromou's avatar
Evan Prodromou committed
28 29
 */

30
if (!defined('STATUSNET') && !defined('LACONICA')) {
Evan Prodromou's avatar
Evan Prodromou committed
31 32 33 34 35 36 37 38 39 40
    exit(1);
}

require_once(INSTALLDIR.'/lib/profilelist.php');
require_once INSTALLDIR.'/lib/publicgroupnav.php';

/**
 * List of group members
 *
 * @category Group
41
 * @package  StatusNet
42
 * @author   Evan Prodromou <evan@status.net>
Evan Prodromou's avatar
Evan Prodromou committed
43
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
44
 * @link     http://status.net/
Evan Prodromou's avatar
Evan Prodromou committed
45
 */
46
class GroupmembersAction extends GroupAction
Evan Prodromou's avatar
Evan Prodromou committed
47 48 49
{
    var $page = null;

50
    function isReadOnly($args)
Evan Prodromou's avatar
Evan Prodromou committed
51 52 53 54 55 56 57
    {
        return true;
    }

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

59
        $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
Evan Prodromou's avatar
Evan Prodromou committed
60 61 62 63 64 65 66

        return true;
    }

    function title()
    {
        if ($this->page == 1) {
67 68
            // TRANS: Title of the page showing group members.
            // TRANS: %s is the name of the group.
Evan Prodromou's avatar
Evan Prodromou committed
69 70 71
            return sprintf(_('%s group members'),
                           $this->group->nickname);
        } else {
72 73
            // TRANS: Title of the page showing group members.
            // TRANS: %1$s is the name of the group, %2$d is the page number of the members list.
74
            return sprintf(_('%1$s group members, page %2$d'),
Evan Prodromou's avatar
Evan Prodromou committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88
                           $this->group->nickname,
                           $this->page);
        }
    }

    function handle($args)
    {
        parent::handle($args);
        $this->showPage();
    }

    function showPageNotice()
    {
        $this->element('p', 'instructions',
Siebrand Mazeland's avatar
Siebrand Mazeland committed
89
                       // TRANS: Page notice for group members page.
Evan Prodromou's avatar
Evan Prodromou committed
90 91 92 93 94 95 96 97
                       _('A list of the users in this group.'));
    }

    function showContent()
    {
        $offset = ($this->page-1) * PROFILES_PER_PAGE;
        $limit =  PROFILES_PER_PAGE + 1;

98 99
        $cnt = 0;

Evan Prodromou's avatar
Evan Prodromou committed
100 101 102
        $members = $this->group->getMembers($offset, $limit);

        if ($members) {
103
            $member_list = new GroupMemberList($members, $this->group, $this);
104
            $cnt = $member_list->show();
Evan Prodromou's avatar
Evan Prodromou committed
105 106 107 108 109 110 111 112
        }

        $members->free();

        $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
                          $this->page, 'groupmembers',
                          array('nickname' => $this->group->nickname));
    }
113
}