]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/groupnav.php
Merge branch '1.0.x' into testing
[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 class GroupNav extends Menu
52 {
53     var $group = null;
54
55     /**
56      * Construction
57      *
58      * @param Action $action current action, used for output
59      */
60     function __construct($action=null, $group=null)
61     {
62         parent::__construct($action);
63         $this->group = $group;
64     }
65
66     /**
67      * Show the menu
68      *
69      * @return void
70      */
71     function show()
72     {
73         $action_name = $this->action->trimmed('action');
74         $nickname = $this->group->nickname;
75
76         $this->out->elementStart('ul', array('class' => 'nav'));
77         if (Event::handle('StartGroupGroupNav', array($this))) {
78             $this->out->menuItem(common_local_url('showgroup', array('nickname' =>
79                                                                      $nickname)),
80                                  // TRANS: Menu item in the group navigation page.
81                                  _m('MENU','Group'),
82                                  // TRANS: Tooltip for menu item in the group navigation page.
83                                  // TRANS: %s is the nickname of the group.
84                                  sprintf(_m('TOOLTIP','%s group'), $nickname),
85                                  $action_name == 'showgroup',
86                                  'nav_group_group');
87             $this->out->menuItem(common_local_url('groupmembers', array('nickname' =>
88                                                                         $nickname)),
89                                  // TRANS: Menu item in the group navigation page.
90                                  _m('MENU','Members'),
91                                  // TRANS: Tooltip for menu item in the group navigation page.
92                                  // TRANS: %s is the nickname of the group.
93                                  sprintf(_m('TOOLTIP','%s group members'), $nickname),
94                                  $action_name == 'groupmembers',
95                                  'nav_group_members');
96
97             $cur = common_current_user();
98
99             if ($cur && $cur->isAdmin($this->group)) {
100                 $pending = $this->countPendingMembers();
101                 if ($pending || $this->group->join_policy == User_group::JOIN_POLICY_MODERATE) {
102                     $this->out->menuItem(common_local_url('groupqueue', array('nickname' =>
103                                                                               $nickname)),
104                                          // TRANS: Menu item in the group navigation page. Only shown for group administrators.
105                                          // TRANS: %d is the number of pending members.
106                                          sprintf(_m('MENU','Pending members (%d)','Pending members (%d)',$pending), $pending),
107                                          // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators.
108                                          // TRANS: %s is the nickname of the group.
109                                          sprintf(_m('TOOLTIP','%s pending members'), $nickname),
110                                          $action_name == 'groupqueue',
111                                          'nav_group_pending');
112                 }
113                 $this->out->menuItem(common_local_url('blockedfromgroup', array('nickname' =>
114                                                                                 $nickname)),
115                                      // TRANS: Menu item in the group navigation page. Only shown for group administrators.
116                                      _m('MENU','Blocked'),
117                                      // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators.
118                                      // TRANS: %s is the nickname of the group.
119                                      sprintf(_m('TOOLTIP','%s blocked users'), $nickname),
120                                      $action_name == 'blockedfromgroup',
121                                      'nav_group_blocked');
122                 $this->out->menuItem(common_local_url('editgroup', array('nickname' =>
123                                                                          $nickname)),
124                                      // TRANS: Menu item in the group navigation page. Only shown for group administrators.
125                                      _m('MENU','Admin'),
126                                      // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators.
127                                      // TRANS: %s is the nickname of the group.
128                                      sprintf(_m('TOOLTIP','Edit %s group properties'), $nickname),
129                                      $action_name == 'editgroup',
130                                      'nav_group_admin');
131                 $this->out->menuItem(common_local_url('grouplogo', array('nickname' =>
132                                                                          $nickname)),
133                                      // TRANS: Menu item in the group navigation page. Only shown for group administrators.
134                                      _m('MENU','Logo'),
135                                      // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators.
136                                      // TRANS: %s is the nickname of the group.
137                                      sprintf(_m('TOOLTIP','Add or edit %s logo'), $nickname),
138                                      $action_name == 'grouplogo',
139                                      'nav_group_logo');
140                 $this->out->menuItem(common_local_url('groupdesignsettings', array('nickname' =>
141                                                                       $nickname)),
142                                      // TRANS: Menu item in the group navigation page. Only shown for group administrators.
143                                      _m('MENU','Design'),
144                                      // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators.
145                                      // TRANS: %s is the nickname of the group.
146                                      sprintf(_m('TOOLTIP','Add or edit %s design'), $nickname),
147                                      $action_name == 'groupdesignsettings',
148                                      'nav_group_design');
149             }
150             Event::handle('EndGroupGroupNav', array($this));
151         }
152         $this->out->elementEnd('ul');
153     }
154
155     function countPendingMembers()
156     {
157         $req = new Group_join_queue();
158         $req->group_id = $this->group->id;
159         return $req->count();
160     }
161 }