git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

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

30
if (!defined('GNUSOCIAL')) { exit(1); }
31 32 33 34 35 36 37 38 39 40 41 42

/**
 * List of group members
 *
 * @category Group
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link     http://status.net/
 */
class SubqueueAction extends GalleryAction
{
43
    protected $needLogin = true;
44

45
    protected function prepare(array $args=array())
46 47 48
    {
        parent::prepare($args);

49
        if (!$this->target->sameAs($this->scoped)) {
50
            // TRANS: Client error displayed when trying to approve group applicants without being a group administrator.
51
            throw new ClientException(_('You may only approve your own pending subscriptions.'));
52 53 54 55 56 57 58 59 60 61
        }
        return true;
    }

    function title()
    {
        if ($this->page == 1) {
            // TRANS: Title of the first page showing pending subscribers still awaiting approval.
            // TRANS: %s is the name of the user.
            return sprintf(_('%s subscribers awaiting approval'),
62
                           $this->target->getNickname());
63 64 65 66
        } else {
            // TRANS: Title of all but the first page showing pending subscribersmembers still awaiting approval.
            // TRANS: %1$s is the name of the user, %2$d is the page number of the members list.
            return sprintf(_('%1$s subscribers awaiting approval, page %2$d'),
67
                           $this->target->getNickname(),
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
                           $this->page);
        }
    }

    function showPageNotice()
    {
        $this->element('p', 'instructions',
                       // TRANS: Page notice for group members page.
                       _('A list of users awaiting approval to subscribe to you.'));
    }


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

        $cnt = 0;

87 88 89 90 91 92
        try {
            $subqueue = $this->target->getRequests($offset, $limit);
        } catch (NoResultException $e) {
            // TRANS: If no pending subscription requests are found
            $this->element('div', null, _m('You have no pending subscription requests.'));
            return;
93 94
        }

95 96 97 98
        $list = new SubQueueList($subqueue, $this);
        $cnt = $list->show();

        $subqueue->free();
99 100 101

        $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
                          $this->page, 'subqueue',
102
                          array('nickname' => $this->target->getNickname())); // urgh
103 104
    }
}