3 * StatusNet, the distributed open-source microblogging tool
5 * Local navigation for subscriptions group of pages
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.
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.
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/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @copyright 2008-2011 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/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
34 require_once INSTALLDIR.'/lib/widget.php';
37 * Local nav menu for subscriptions, subscribers
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/
45 class SubGroupNav extends Menu
52 * @param Action $action current action, used for output
53 * @param User $user Current user or NULL if "guest"
55 function __construct(Action $action=null, User $user=null)
57 parent::__construct($action);
68 $cur = common_current_user();
69 $action = $this->action->trimmed('action');
71 $this->out->elementStart('ul', array('class' => 'nav'));
73 if (Event::handle('StartSubGroupNav', array($this))) {
75 $this->out->menuItem(common_local_url('showstream', array('nickname' =>
76 $this->user->nickname)),
77 // TRANS: Menu item in local navigation menu.
79 (empty($profile)) ? $this->user->nickname : $profile->getBestName(),
80 $action == 'showstream',
82 $this->out->menuItem(common_local_url('subscriptions',
84 $this->user->nickname)),
85 // TRANS: Menu item in local navigation menu.
86 _m('MENU','Subscriptions'),
87 // TRANS: Menu item title in local navigation menu.
88 // TRANS: %s is a user nickname.
89 sprintf(_('People %s subscribes to.'),
90 $this->user->nickname),
91 $action == 'subscriptions',
93 $this->out->menuItem(common_local_url('subscribers',
95 $this->user->nickname)),
96 // TRANS: Menu item in local navigation menu.
97 _m('MENU','Subscribers'),
98 // TRANS: Menu item title in local navigation menu.
99 // TRANS: %s is a user nickname.
100 sprintf(_('People subscribed to %s.'),
101 $this->user->nickname),
102 $action == 'subscribers',
104 if ($cur && $cur->id == $this->user->id) {
105 // Possibly site admins should be able to get in here too
106 $pending = $this->countPendingSubs();
107 if ($pending || $cur->subscribe_policy == User::SUBSCRIBE_POLICY_MODERATE) {
108 $this->out->menuItem(common_local_url('subqueue',
110 $this->user->nickname)),
111 // TRANS: Menu item in local navigation menu.
112 // TRANS: %d is the number of pending subscription requests.
113 sprintf(_m('MENU','Pending (%d)'), $pending),
114 // TRANS: Menu item title in local navigation menu.
115 sprintf(_('Approve pending subscription requests.'),
116 $this->user->nickname),
117 $action == 'subqueueaction',
121 $this->out->menuItem(common_local_url('usergroups',
123 $this->user->nickname)),
124 // TRANS: Menu item in local navigation menu.
126 // TRANS: Menu item title in local navigation menu.
127 // TRANS: %s is a user nickname.
128 sprintf(_('Groups %s is a member of.'),
129 $this->user->nickname),
130 $action == 'usergroups',
132 $this->out->menuItem(common_local_url('peopletagsubscriptions',
134 $this->user->nickname)),
135 // TRANS: Menu item title in local navigation menu.
137 // TRANS: Menu item title in local navigation menu.
138 // TRANS: %s is a user nickname.
139 sprintf(_('List subscriptions by %s.'),
140 $this->user->nickname),
141 in_array($action, array('peopletagsbyuser', 'peopletagsubscriptions', 'peopletagsforuser')),
142 'nav_timeline_peopletags');
144 if (common_config('invite', 'enabled') && !is_null($cur) && $this->user->id === $cur->id) {
145 $this->out->menuItem(common_local_url('invite'),
146 // TRANS: Menu item in local navigation menu.
148 // TRANS: Menu item title in local navigation menu.
149 // TRANS: %s is the StatusNet sitename.
150 sprintf(_('Invite friends and colleagues to join you on %s.'),
151 common_config('site', 'name')),
156 Event::handle('EndSubGroupNav', array($this));
159 $this->out->elementEnd('ul');
162 function countPendingSubs()
164 $req = new Subscription_queue();
165 $req->subscribed = $this->user->id;
166 return $req->count();