3 * StatusNet, the distributed open-source microblogging tool
5 * User groups information
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 * @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/
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/grouplist.php';
40 * Show the groups a user belongs to
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/
48 class UsergroupsAction extends GalleryAction
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());
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(),
65 function showPageNotice()
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 '.
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()));
83 function showContent()
85 if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
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)' .
99 $this->elementStart('div', 'instructions');
100 $this->raw(common_markup_to_html($notice));
101 $this->elementEnd('div');
104 if (Event::handle('StartShowUserGroupsContent', array($this))) {
105 $offset = ($this->page-1) * GROUPS_PER_PAGE;
106 $limit = GROUPS_PER_PAGE + 1;
108 $groups = $this->getTarget()->getGroups($offset, $limit);
110 if ($groups instanceof User_group) {
111 $gl = new GroupList($groups, $this->getTarget(), $this);
114 $this->showEmptyListMessage();
116 $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
117 $this->page, 'usergroups',
118 array('nickname' => $this->getTarget()->getNickname()));
122 Event::handle('EndShowUserGroupsContent', array($this));
126 function showEmptyListMessage()
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".');
140 $this->elementStart('div', 'guide');
141 $this->raw(common_markup_to_html($message));
142 $this->elementEnd('div');
145 function showProfileBlock()
147 $block = new AccountProfileBlock($this, $this->getTarget());