]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/subqueue.php
ba473456004ef06ffa364d1fc7ad4b59e56415bd
[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('STATUSNET') && !defined('LACONICA')) {
31     exit(1);
32 }
33
34 require_once(INSTALLDIR.'/lib/profilelist.php');
35
36 /**
37  * List of group members
38  *
39  * @category Group
40  * @package  StatusNet
41  * @author   Evan Prodromou <evan@status.net>
42  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43  * @link     http://status.net/
44  */
45 class SubqueueAction extends GalleryAction
46 {
47     protected $needLogin = true;
48
49     protected function prepare(array $args=array())
50     {
51         parent::prepare($args);
52
53         if ($this->scoped->id != $this->target->id) {
54             // TRANS: Client error displayed when trying to approve group applicants without being a group administrator.
55             $this->clientError(_('You may only approve your own pending subscriptions.'));
56         }
57         return true;
58     }
59
60     function title()
61     {
62         if ($this->page == 1) {
63             // TRANS: Title of the first page showing pending subscribers still awaiting approval.
64             // TRANS: %s is the name of the user.
65             return sprintf(_('%s subscribers awaiting approval'),
66                            $this->target->getNickname());
67         } else {
68             // TRANS: Title of all but the first page showing pending subscribersmembers still awaiting approval.
69             // TRANS: %1$s is the name of the user, %2$d is the page number of the members list.
70             return sprintf(_('%1$s subscribers awaiting approval, page %2$d'),
71                            $this->target->getNickname(),
72                            $this->page);
73         }
74     }
75
76     function showPageNotice()
77     {
78         $this->element('p', 'instructions',
79                        // TRANS: Page notice for group members page.
80                        _('A list of users awaiting approval to subscribe to you.'));
81     }
82
83
84     function showContent()
85     {
86         $offset = ($this->page-1) * PROFILES_PER_PAGE;
87         $limit =  PROFILES_PER_PAGE + 1;
88
89         $cnt = 0;
90
91         $members = $this->target->getRequests($offset, $limit);
92
93         if ($members) {
94             // @fixme change!
95             $member_list = new SubQueueList($members, $this);
96             $cnt = $member_list->show();
97         }
98
99         $members->free();
100
101         $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
102                           $this->page, 'subqueue',
103                           array('nickname' => $this->target->getNickname())); // urgh
104     }
105 }
106
107 class SubQueueList extends ProfileList
108 {
109     function newListItem($profile)
110     {
111         return new SubQueueListItem($profile, $this->action);
112     }
113 }
114
115 class SubQueueListItem extends ProfileListItem
116 {
117     function showActions()
118     {
119         $this->startActions();
120         if (Event::handle('StartProfileListItemActionElements', array($this))) {
121             $this->showApproveButtons();
122             Event::handle('EndProfileListItemActionElements', array($this));
123         }
124         $this->endActions();
125     }
126
127     function showApproveButtons()
128     {
129         $this->out->elementStart('li', 'entity_approval');
130         $form = new ApproveSubForm($this->out, $this->profile);
131         $form->show();
132         $this->out->elementEnd('li');
133     }
134 }