git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

subgroupnav.php 7.89 KB
Newer Older
1 2
<?php
/**
3
 * StatusNet, the distributed open-source microblogging tool
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * Local navigation for subscriptions group of pages
 *
 * PHP version 5
 *
 * LICENCE: This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  Subs
23
 * @package   StatusNet
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/
28 29
 */

30
if (!defined('STATUSNET') && !defined('LACONICA')) {
31 32 33 34 35 36 37 38 39
    exit(1);
}

require_once INSTALLDIR.'/lib/widget.php';

/**
 * Local nav menu for subscriptions, subscribers
 *
 * @category Subs
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 SubGroupNav extends Menu
46 47 48 49 50 51 52
{
    var $user = null;

    /**
     * Construction
     *
     * @param Action $action current action, used for output
53
     * @param User   $user   Current user or NULL if "guest"
54
     */
55
    function __construct(Action $action=null, User $user=null)
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
    {
        parent::__construct($action);
        $this->user = $user;
    }

    /**
     * Show the menu
     *
     * @return void
     */
    function show()
    {
        $cur = common_current_user();
        $action = $this->action->trimmed('action');

        $this->out->elementStart('ul', array('class' => 'nav'));

73 74
        if (Event::handle('StartSubGroupNav', array($this))) {

75 76
            $this->out->menuItem(common_local_url('showstream', array('nickname' =>
                                                                      $this->user->nickname)),
Siebrand Mazeland's avatar
Siebrand Mazeland committed
77 78
                                 // TRANS: Menu item in local navigation menu.
                                 _m('MENU','Profile'),
79 80 81
                                 (empty($profile)) ? $this->user->nickname : $profile->getBestName(),
                                 $action == 'showstream',
                                 'nav_profile');
82 83 84
            $this->out->menuItem(common_local_url('subscriptions',
                                                  array('nickname' =>
                                                        $this->user->nickname)),
Siebrand Mazeland's avatar
Siebrand Mazeland committed
85 86 87 88 89
                                 // TRANS: Menu item in local navigation menu.
                                 _m('MENU','Subscriptions'),
                                 // TRANS: Menu item title in local navigation menu.
                                 // TRANS: %s is a user nickname.
                                 sprintf(_('People %s subscribes to.'),
90 91 92 93 94 95
                                         $this->user->nickname),
                                 $action == 'subscriptions',
                                 'nav_subscriptions');
            $this->out->menuItem(common_local_url('subscribers',
                                                  array('nickname' =>
                                                        $this->user->nickname)),
Siebrand Mazeland's avatar
Siebrand Mazeland committed
96 97 98 99 100
                                 // TRANS: Menu item in local navigation menu.
                                 _m('MENU','Subscribers'),
                                 // TRANS: Menu item title in local navigation menu.
                                 // TRANS: %s is a user nickname.
                                 sprintf(_('People subscribed to %s.'),
101 102 103
                                         $this->user->nickname),
                                 $action == 'subscribers',
                                 'nav_subscribers');
104 105 106 107 108 109 110
            if ($cur && $cur->id == $this->user->id) {
                // Possibly site admins should be able to get in here too
                $pending = $this->countPendingSubs();
                if ($pending || $cur->subscribe_policy == User::SUBSCRIBE_POLICY_MODERATE) {
                    $this->out->menuItem(common_local_url('subqueue',
                                                          array('nickname' =>
                                                                $this->user->nickname)),
Siebrand Mazeland's avatar
Siebrand Mazeland committed
111
                                         // TRANS: Menu item in local navigation menu.
Siebrand Mazeland's avatar
Siebrand Mazeland committed
112
                                         // TRANS: %d is the number of pending subscription requests.
Siebrand Mazeland's avatar
Siebrand Mazeland committed
113 114 115
                                         sprintf(_m('MENU','Pending (%d)'), $pending),
                                         // TRANS: Menu item title in local navigation menu.
                                         sprintf(_('Approve pending subscription requests.'),
116 117 118 119 120
                                                 $this->user->nickname),
                                         $action == 'subqueueaction',
                                         'nav_subscribers');
                }
            }
121 122 123
            $this->out->menuItem(common_local_url('usergroups',
                                                  array('nickname' =>
                                                        $this->user->nickname)),
Siebrand Mazeland's avatar
Siebrand Mazeland committed
124 125 126 127 128
                                 // TRANS: Menu item in local navigation menu.
                                 _m('MENU','Groups'),
                                 // TRANS: Menu item title in local navigation menu.
                                 // TRANS: %s is a user nickname.
                                 sprintf(_('Groups %s is a member of.'),
129 130 131
                                         $this->user->nickname),
                                 $action == 'usergroups',
                                 'nav_usergroups');
132
            $this->out->menuItem(common_local_url('peopletagsubscriptions',
Shashi Gowda's avatar
Shashi Gowda committed
133 134
                                                  array('nickname' =>
                                                        $this->user->nickname)),
135
                                 // TRANS: Menu item title in local navigation menu.
136
                                 _m('MENU','Lists'),
137 138
                                 // TRANS: Menu item title in local navigation menu.
                                 // TRANS: %s is a user nickname.
139
                                 sprintf(_('List subscriptions by %s.'),
Shashi Gowda's avatar
Shashi Gowda committed
140
                                         $this->user->nickname),
141
                                 in_array($action, array('peopletagsbyuser', 'peopletagsubscriptions', 'peopletagsforuser')),
Shashi Gowda's avatar
Shashi Gowda committed
142 143
                                 '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'),
Siebrand Mazeland's avatar
Siebrand Mazeland committed
146 147 148
                                     // TRANS: Menu item in local navigation menu.
                                     _m('MENU','Invite'),
                                     // TRANS: Menu item title in local navigation menu.
149
                                     // TRANS: %s is the StatusNet sitename.
Siebrand Mazeland's avatar
Siebrand Mazeland committed
150
                                     sprintf(_('Invite friends and colleagues to join you on %s.'),
151 152 153 154 155 156
                                             common_config('site', 'name')),
                                     $action == 'invite',
                                     'nav_invite');
            }

            Event::handle('EndSubGroupNav', array($this));
157
        }
158

159 160
        $this->out->elementEnd('ul');
    }
161 162 163 164 165 166 167

    function countPendingSubs()
    {
        $req = new Subscription_queue();
        $req->subscribed = $this->user->id;
        return $req->count();
    }
168
}