]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/subqueue.php
Pending subscription requests now work as they should
[quix0rs-gnu-social.git] / actions / subqueue.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * List of group members
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  * @copyright 2008-2009 StatusNet, Inc.
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/
28  */
29
30 if (!defined('GNUSOCIAL')) { exit(1); }
31
32 /**
33  * List of group members
34  *
35  * @category Group
36  * @package  StatusNet
37  * @author   Evan Prodromou <evan@status.net>
38  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
39  * @link     http://status.net/
40  */
41 class SubqueueAction extends GalleryAction
42 {
43     protected $needLogin = true;
44
45     protected function prepare(array $args=array())
46     {
47         parent::prepare($args);
48
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         return true;
54     }
55
56     function title()
57     {
58         if ($this->page == 1) {
59             // TRANS: Title of the first page showing pending subscribers still awaiting approval.
60             // TRANS: %s is the name of the user.
61             return sprintf(_('%s subscribers awaiting approval'),
62                            $this->target->getNickname());
63         } else {
64             // TRANS: Title of all but the first page showing pending subscribersmembers still awaiting approval.
65             // TRANS: %1$s is the name of the user, %2$d is the page number of the members list.
66             return sprintf(_('%1$s subscribers awaiting approval, page %2$d'),
67                            $this->target->getNickname(),
68                            $this->page);
69         }
70     }
71
72     function showPageNotice()
73     {
74         $this->element('p', 'instructions',
75                        // TRANS: Page notice for group members page.
76                        _('A list of users awaiting approval to subscribe to you.'));
77     }
78
79
80     function showContent()
81     {
82         $offset = ($this->page-1) * PROFILES_PER_PAGE;
83         $limit =  PROFILES_PER_PAGE + 1;
84
85         $cnt = 0;
86
87         try {
88             $subqueue = $this->target->getRequests($offset, $limit);
89         } catch (NoResultException $e) {
90             // TRANS: If no pending subscription requests are found
91             $this->element('div', null, _m('You have no pending subscription requests.'));
92             return;
93         }
94
95         $list = new SubQueueList($subqueue, $this);
96         $cnt = $list->show();
97
98         $subqueue->free();
99
100         $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
101                           $this->page, 'subqueue',
102                           array('nickname' => $this->target->getNickname())); // urgh
103     }
104 }