]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/usergroups.php
Added missing type-hint for EndPublicGroupNav (it is Menu).
[quix0rs-gnu-social.git] / actions / usergroups.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * User groups information
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  Personal
23  * @package   StatusNet
24  * @author    Evan Prodromou <evan@status.net>
25  * @author    Sarven Capadisli <csarven@status.net>
26  * @copyright 2008-2009 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/grouplist.php';
36
37 /**
38  * User groups page
39  *
40  * Show the groups a user belongs to
41  *
42  * @category Personal
43  * @package  StatusNet
44  * @author   Evan Prodromou <evan@status.net>
45  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
46  * @link     http://status.net/
47  */
48 class UsergroupsAction extends GalleryAction
49 {
50     function title()
51     {
52         if ($this->page == 1) {
53             // TRANS: Page title for first page of groups for a user.
54             // TRANS: %s is a nickname.
55             return sprintf(_('%s groups'), $this->getTarget()->getNickname());
56         } else {
57             // TRANS: Page title for all but the first page of groups for a user.
58             // TRANS: %1$s is a nickname, %2$d is a page number.
59             return sprintf(_('%1$s groups, page %2$d'),
60                            $this->getTarget()->getNickname(),
61                            $this->page);
62         }
63     }
64
65     function showPageNotice()
66     {
67         if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
68             $this->element('p', 'instructions',
69                            // TRANS: Page notice for page with an overview of all subscribed groups
70                            // TRANS: of the logged in user's own profile.
71                            _('These are the groups whose notices '.
72                              'you listen to.'));
73         } else {
74             $this->element('p', 'instructions',
75                            // TRANS: Page notice for page with an overview of all groups a user other
76                            // TRANS: than the logged in user. %s is the user nickname.
77                            sprintf(_('These are the groups whose '.
78                                      'notices %s listens to.'),
79                                    $this->target->getNickname()));
80         }
81     }
82
83     function showContent()
84     {
85         if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
86           $notice =
87           // TRANS: Page notice of user's groups page.
88           // TRANS: %%%%action.groupsearch%%%% and %%%%action.newgroup%%%% are URLs. Do not change them.
89           // TRANS: This message contains Markdown links in the form [link text](link).
90           sprintf(_('Groups let you find and talk with ' .
91                     'people of similar interests. ' .
92                     'You can [search for groups](%%%%action.groups%%%%) in your instance or ' .
93                     '[create a new group](%%%%action.newgroup%%%%). ' .
94                     'You can also follow groups ' .
95                     'from other GNU social instances: click on the remote button below ' .
96                     'and copy the group\'s link. ' .
97                     'You can find a list of GNU social groups [here](http://skilledtests.com/wiki/List_of_federated_GNU_social_groups)' .
98                     ''));
99           $this->elementStart('div', 'instructions');
100           $this->raw(common_markup_to_html($notice));
101           $this->elementEnd('div');
102         }
103
104         if (Event::handle('StartShowUserGroupsContent', array($this))) {
105             $offset = ($this->page-1) * GROUPS_PER_PAGE;
106             $limit =  GROUPS_PER_PAGE + 1;
107
108             $groups = $this->getTarget()->getGroups($offset, $limit);
109
110             if ($groups instanceof User_group) {
111                 $gl = new GroupList($groups, $this->getTarget(), $this);
112                 $cnt = $gl->show();
113                 if (0 == $cnt) {
114                   $this->showEmptyListMessage();
115                 } else {
116                   $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
117                                     $this->page, 'usergroups',
118                                     array('nickname' => $this->getTarget()->getNickname()));
119                 }
120             }
121
122             Event::handle('EndShowUserGroupsContent', array($this));
123         }
124     }
125
126     function showEmptyListMessage()
127     {
128         // TRANS: Text on group page for a user that is not a member of any group.
129         // TRANS: %s is a user nickname.
130         $message = sprintf(_('%s is not a member of any group.'), $this->getTarget()->getNickname()) . ' ';
131         if (common_logged_in()) {
132             if ($this->scoped->sameAs($this->getTarget())) {
133                 // TRANS: Text on group page for a user that is not a member of any group. This message contains
134                 // TRANS: a Markdown link in the form [link text](link) and a variable that should not be changed.
135                 $message = _('You are not member of any group yet. After you join a group ' .
136                              'you can send messages to its members using the ' .
137                              'syntax "!groupname".');
138             }
139         }
140         $this->elementStart('div', 'guide');
141         $this->raw(common_markup_to_html($message));
142         $this->elementEnd('div');
143     }
144
145     function showProfileBlock()
146     {
147         $block = new AccountProfileBlock($this, $this->getTarget());
148         $block->show();
149     }
150 }