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->user->nickname);
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->user->nickname,
65 function showContent()
67 $this->elementStart('p', array('id' => 'new_group'));
68 $this->element('a', array('href' => common_local_url('newgroup'),
70 // TRANS: Link text on group page to create a new group.
71 _('Create a new group'));
72 $this->elementEnd('p');
74 $this->elementStart('p', array('id' => 'group_search'));
75 $this->element('a', array('href' => common_local_url('groupsearch'),
77 // TRANS: Link text on group page to search for groups.
78 _('Search for more groups'));
79 $this->elementEnd('p');
81 if (Event::handle('StartShowUserGroupsContent', array($this))) {
82 $offset = ($this->page-1) * GROUPS_PER_PAGE;
83 $limit = GROUPS_PER_PAGE + 1;
85 $groups = $this->user->getGroups($offset, $limit);
87 if ($groups instanceof User_group) {
88 $gl = new GroupList($groups, $this->user, $this);
90 $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
91 $this->page, 'usergroups',
92 array('nickname' => $this->user->nickname));
94 $this->showEmptyListMessage();
97 Event::handle('EndShowUserGroupsContent', array($this));
101 function showEmptyListMessage()
103 // TRANS: Text on group page for a user that is not a member of any group.
104 // TRANS: %s is a user nickname.
105 $message = sprintf(_('%s is not a member of any group.'), $this->user->nickname) . ' ';
107 if (common_logged_in()) {
108 $current_user = common_current_user();
109 if ($this->user->id === $current_user->id) {
110 // TRANS: Text on group page for a user that is not a member of any group. This message contains
111 // TRANS: a Markdown link in the form [link text](link) and a variable that should not be changed.
112 $message .= _('Try [searching for groups](%%action.groupsearch%%) and joining them.');
115 $this->elementStart('div', 'guide');
116 $this->raw(common_markup_to_html($message));
117 $this->elementEnd('div');
120 function showProfileBlock()
122 $block = new AccountProfileBlock($this, $this->profile);