3 * Laconica, the distributed open-source microblogging tool
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@controlyourself.ca>
25 * @author Sarven Capadisli <csarven@controlyourself.ca>
26 * @copyright 2008-2009 Control Yourself, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28 * @link http://laconi.ca/
31 if (!defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/noticelist.php';
36 require_once INSTALLDIR.'/lib/feedlist.php';
38 define('MEMBERS_PER_SECTION', 81);
45 * @author Evan Prodromou <evan@controlyourself.ca>
46 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
47 * @link http://laconi.ca/
50 class ShowgroupAction extends Action
52 /** group we're viewing. */
54 /** page we're viewing. */
58 * Is this page read-only?
60 * @return boolean true
71 * @return string page title, with page number
76 if ($this->page == 1) {
77 return sprintf(_("%s group"), $this->group->nickname);
79 return sprintf(_("%s group, page %d"),
80 $this->group->nickname,
88 * Reads and validates arguments and instantiates the attributes.
90 * @param array $args $_REQUEST args
92 * @return boolean success flag
95 function prepare($args)
97 parent::prepare($args);
99 if (!common_config('inboxes','enabled')) {
100 $this->serverError(_('Inboxes must be enabled for groups to work'));
104 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
106 $nickname_arg = $this->arg('nickname');
107 $nickname = common_canonical_nickname($nickname_arg);
109 // Permanent redirect on non-canonical nickname
111 if ($nickname_arg != $nickname) {
112 $args = array('nickname' => $nickname);
113 if ($this->page != 1) {
114 $args['page'] = $this->page;
116 common_redirect(common_local_url('showgroup', $args), 301);
121 $this->clientError(_('No nickname'), 404);
125 $this->group = User_group::staticGet('nickname', $nickname);
128 $this->clientError(_('No such group'), 404);
138 * Shows a profile for the group, some controls, and a list of
144 function handle($args)
155 function showLocalNav()
157 $nav = new GroupNav($this, $this->group);
162 * Show the page content
164 * Shows a group profile and a list of group notices
167 function showContent()
169 $this->showGroupProfile();
170 $this->showGroupNotices();
174 * Show the group notices
179 function showGroupNotices()
181 $notice = $this->group->getNotices(($this->page-1)*NOTICES_PER_PAGE,
182 NOTICES_PER_PAGE + 1);
184 $nl = new NoticeList($notice, $this);
187 $this->pagination($this->page > 1,
188 $cnt > NOTICES_PER_PAGE,
191 array('nickname' => $this->group->nickname));
195 * Show the group profile
197 * Information about the group
202 function showGroupProfile()
204 $this->elementStart('div', array('id' => 'group_profile',
205 'class' => 'vcard author'));
207 $this->element('h2', null, _('Group profile'));
209 $this->elementStart('dl', 'group_depiction');
210 $this->element('dt', null, _('Photo'));
211 $this->elementStart('dd');
213 $logo = ($this->group->homepage_logo) ?
214 $this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
216 $this->element('img', array('src' => $logo,
217 'class' => 'photo avatar',
218 'width' => AVATAR_PROFILE_SIZE,
219 'height' => AVATAR_PROFILE_SIZE,
220 'alt' => $this->group->nickname));
221 $this->elementEnd('dd');
222 $this->elementEnd('dl');
224 $this->elementStart('dl', 'group_nickname');
225 $this->element('dt', null, _('Nickname'));
226 $this->elementStart('dd');
227 $hasFN = ($this->group->fullname) ? 'nickname url uid' : 'fn nickname url uid';
228 $this->element('a', array('href' => $this->group->homeUrl(),
229 'rel' => 'me', 'class' => $hasFN),
230 $this->group->nickname);
231 $this->elementEnd('dd');
232 $this->elementEnd('dl');
234 if ($this->group->fullname) {
235 $this->elementStart('dl', 'group_fn');
236 $this->element('dt', null, _('Full name'));
237 $this->elementStart('dd');
238 $this->element('span', 'fn', $this->group->fullname);
239 $this->elementEnd('dd');
240 $this->elementEnd('dl');
243 if ($this->group->location) {
244 $this->elementStart('dl', 'group_location');
245 $this->element('dt', null, _('Location'));
246 $this->element('dd', 'location', $this->group->location);
247 $this->elementEnd('dl');
250 if ($this->group->homepage) {
251 $this->elementStart('dl', 'group_url');
252 $this->element('dt', null, _('URL'));
253 $this->elementStart('dd');
254 $this->element('a', array('href' => $this->group->homepage,
255 'rel' => 'me', 'class' => 'url'),
256 $this->group->homepage);
257 $this->elementEnd('dd');
258 $this->elementEnd('dl');
261 if ($this->group->description) {
262 $this->elementStart('dl', 'group_note');
263 $this->element('dt', null, _('Note'));
264 $this->element('dd', 'note', $this->group->description);
265 $this->elementEnd('dl');
268 $this->elementEnd('div');
270 $this->elementStart('div', array('id' => 'group_actions'));
271 $this->element('h2', null, _('Group actions'));
272 $this->elementStart('ul');
273 $this->elementStart('li', array('id' => 'group_subscribe'));
274 $cur = common_current_user();
276 if ($cur->isMember($this->group)) {
277 $lf = new LeaveForm($this, $this->group);
280 $jf = new JoinForm($this, $this->group);
285 $this->elementEnd('li');
287 $this->elementEnd('ul');
288 $this->elementEnd('div');
292 * Show a list of links to feeds this page produces
297 function showExportData()
299 $fl = new FeedList($this);
300 $fl->show(array(0=>array('href'=>common_local_url('grouprss',
301 array('nickname' => $this->group->nickname)),
303 'version' => 'RSS 1.0',
304 'item' => 'notices')));
308 * Show a list of links to feeds this page produces
316 common_local_url('grouprss',
317 array('nickname' => $this->group->nickname));
319 $this->element('link', array('rel' => 'alternate',
321 'type' => 'application/rss+xml',
322 'title' => sprintf(_('Notice feed for %s group'),
323 $this->group->nickname)));
327 * Fill in the sidebar.
332 function showSections()
334 $this->showMembers();
338 * Show mini-list of members
343 function showMembers()
345 $member = $this->group->getMembers(0, MEMBERS_PER_SECTION);
351 $this->elementStart('div', array('id' => 'user_subscriptions',
352 'class' => 'section'));
354 $this->element('h2', null, _('Members'));
357 $pml = new ProfileMiniList($member, null, $this);
360 $this->element('p', null, _('(None)'));
364 if ($cnt == MEMBERS_PER_SECTION) {
365 $this->element('a', array('href' => common_local_url('groupmembers',
366 array('nickname' => $this->group->nickname))),