]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/groupnav.php
6a4f5f7e30c508c5d5ec958b6aa580a86a0a3a8c
[quix0rs-gnu-social.git] / lib / groupnav.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Tabset for a particular group
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  Action
23  * @package   StatusNet
24  * @author    Evan Prodromou <evan@status.net>
25  * @author    Sarven Capadisli <csarven@status.net>
26  * @copyright 2008 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     exit(1);
33 }
34
35 require_once INSTALLDIR.'/lib/widget.php';
36
37 /**
38  * Tabset for a group
39  *
40  * Shows a group of tabs for a particular user group
41  *
42  * @category Output
43  * @package  StatusNet
44  * @author   Evan Prodromou <evan@status.net>
45  * @author   Sarven Capadisli <csarven@status.net>
46  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
47  * @link     http://status.net/
48  *
49  * @see      HTMLOutputter
50  */
51
52 class GroupNav extends Menu
53 {
54     var $group = null;
55
56     /**
57      * Construction
58      *
59      * @param Action $action current action, used for output
60      */
61
62     function __construct($action=null, $group=null)
63     {
64         parent::__construct($action);
65         $this->group = $group;
66     }
67
68     /**
69      * Show the menu
70      *
71      * @return void
72      */
73
74     function show()
75     {
76         $action_name = $this->action->trimmed('action');
77         $nickname = $this->group->nickname;
78
79         $this->out->elementStart('ul', array('class' => 'nav'));
80         if (Event::handle('StartGroupGroupNav', array($this))) {
81             $this->out->menuItem(common_local_url('showgroup', array('nickname' =>
82                                                                      $nickname)),
83                                  // TRANS: Menu item in the group navigation page.
84                                  _m('MENU','Group'),
85                                  // TRANS: Tooltip for menu item in the group navigation page.
86                                  // TRANS: %s is the nickname of the group.
87                                  sprintf(_m('TOOLTIP','%s group'), $nickname),
88                                  $action_name == 'showgroup',
89                                  'nav_group_group');
90             $this->out->menuItem(common_local_url('groupmembers', array('nickname' =>
91                                                                         $nickname)),
92                                  // TRANS: Menu item in the group navigation page.
93                                  _m('MENU','Members'),
94                                  // TRANS: Tooltip for menu item in the group navigation page.
95                                  // TRANS: %s is the nickname of the group.
96                                  sprintf(_m('TOOLTIP','%s group members'), $nickname),
97                                  $action_name == 'groupmembers',
98                                  'nav_group_members');
99
100             $cur = common_current_user();
101
102             if ($cur && $cur->isAdmin($this->group)) {
103                 $pending = $this->countPendingMembers();
104                 if ($pending || $this->group->join_policy == User_group::JOIN_POLICY_MODERATE) {
105                     $this->out->menuItem(common_local_url('groupqueue', array('nickname' =>
106                                                                               $nickname)),
107                                          // TRANS: Menu item in the group navigation page. Only shown for group administrators.
108                                          sprintf(_m('MENU','Pending members (%d)'), $pending),
109                                          // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators.
110                                          // TRANS: %s is the nickname of the group.
111                                          sprintf(_m('TOOLTIP','%s pending members'), $nickname),
112                                          $action_name == 'groupqueue',
113                                          'nav_group_pending');
114                 }
115                 $this->out->menuItem(common_local_url('blockedfromgroup', array('nickname' =>
116                                                                                 $nickname)),
117                                      // TRANS: Menu item in the group navigation page. Only shown for group administrators.
118                                      _m('MENU','Blocked'),
119                                      // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators.
120                                      // TRANS: %s is the nickname of the group.
121                                      sprintf(_m('TOOLTIP','%s blocked users'), $nickname),
122                                      $action_name == 'blockedfromgroup',
123                                      'nav_group_blocked');
124                 $this->out->menuItem(common_local_url('editgroup', array('nickname' =>
125                                                                          $nickname)),
126                                      // TRANS: Menu item in the group navigation page. Only shown for group administrators.
127                                      _m('MENU','Admin'),
128                                      // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators.
129                                      // TRANS: %s is the nickname of the group.
130                                      sprintf(_m('TOOLTIP','Edit %s group properties'), $nickname),
131                                      $action_name == 'editgroup',
132                                      'nav_group_admin');
133                 $this->out->menuItem(common_local_url('grouplogo', array('nickname' =>
134                                                                          $nickname)),
135                                      // TRANS: Menu item in the group navigation page. Only shown for group administrators.
136                                      _m('MENU','Logo'),
137                                      // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators.
138                                      // TRANS: %s is the nickname of the group.
139                                      sprintf(_m('TOOLTIP','Add or edit %s logo'), $nickname),
140                                      $action_name == 'grouplogo',
141                                      'nav_group_logo');
142                 $this->out->menuItem(common_local_url('groupdesignsettings', array('nickname' =>
143                                                                       $nickname)),
144                                      // TRANS: Menu item in the group navigation page. Only shown for group administrators.
145                                      _m('MENU','Design'),
146                                      // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators.
147                                      // TRANS: %s is the nickname of the group.
148                                      sprintf(_m('TOOLTIP','Add or edit %s design'), $nickname),
149                                      $action_name == 'groupdesignsettings',
150                                      'nav_group_design');
151             }
152             Event::handle('EndGroupGroupNav', array($this));
153         }
154         $this->out->elementEnd('ul');
155     }
156
157     function countPendingMembers()
158     {
159         $req = new Group_join_queue();
160         $req->group_id = $this->group->id;
161         return $req->count();
162     }
163 }