3 * StatusNet, 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@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/noticelist.php';
36 require_once INSTALLDIR.'/lib/feedlist.php';
38 define('MEMBERS_PER_SECTION', 27);
45 * @author Evan Prodromou <evan@status.net>
46 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
47 * @link http://status.net/
50 class ShowgroupAction extends GroupDesignAction
53 /** page we're viewing. */
57 * Is this page read-only?
59 * @return boolean true
62 function isReadOnly($args)
70 * @return string page title, with page number
75 if (!empty($this->group->fullname)) {
76 $base = $this->group->fullname . ' (' . $this->group->nickname . ')';
78 $base = $this->group->nickname;
81 if ($this->page == 1) {
82 return sprintf(_('%s group'), $base);
84 return sprintf(_('%1$s group, page %2$d'),
93 * Reads and validates arguments and instantiates the attributes.
95 * @param array $args $_REQUEST args
97 * @return boolean success flag
100 function prepare($args)
102 parent::prepare($args);
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 $local = Local_group::staticGet('nickname', $nickname);
128 $alias = Group_alias::staticGet('alias', $nickname);
130 $args = array('id' => $alias->group_id);
131 if ($this->page != 1) {
132 $args['page'] = $this->page;
134 common_redirect(common_local_url('groupbyid', $args), 301);
137 common_log(LOG_NOTICE, "Couldn't find local group for nickname '$nickname'");
138 $this->clientError(_('No such group.'), 404);
143 $this->group = User_group::staticGet('id', $local->group_id);
146 $this->clientError(_('No such group.'), 404);
150 common_set_returnto($this->selfUrl());
158 * Shows a profile for the group, some controls, and a list of
164 function handle($args)
175 function showLocalNav()
177 $nav = new GroupNav($this, $this->group);
182 * Show the page content
184 * Shows a group profile and a list of group notices
187 function showContent()
189 $this->showGroupProfile();
190 $this->showGroupNotices();
194 * Show the group notices
199 function showGroupNotices()
201 $notice = $this->group->getNotices(($this->page-1)*NOTICES_PER_PAGE,
202 NOTICES_PER_PAGE + 1);
204 $nl = new NoticeList($notice, $this);
207 $this->pagination($this->page > 1,
208 $cnt > NOTICES_PER_PAGE,
211 array('nickname' => $this->group->nickname));
215 * Show the group profile
217 * Information about the group
222 function showGroupProfile()
224 $this->elementStart('div', array('id' => 'i',
225 'class' => 'entity_profile vcard author'));
227 $this->element('h2', null, _('Group profile'));
229 $this->elementStart('dl', 'entity_depiction');
230 $this->element('dt', null, _('Avatar'));
231 $this->elementStart('dd');
233 $logo = ($this->group->homepage_logo) ?
234 $this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
236 $this->element('img', array('src' => $logo,
237 'class' => 'photo avatar',
238 'width' => AVATAR_PROFILE_SIZE,
239 'height' => AVATAR_PROFILE_SIZE,
240 'alt' => $this->group->nickname));
241 $this->elementEnd('dd');
242 $this->elementEnd('dl');
244 $this->elementStart('dl', 'entity_nickname');
245 $this->element('dt', null, _('Nickname'));
246 $this->elementStart('dd');
247 $hasFN = ($this->group->fullname) ? 'nickname url uid' : 'fn org nickname url uid';
248 $this->element('a', array('href' => $this->group->homeUrl(),
249 'rel' => 'me', 'class' => $hasFN),
250 $this->group->nickname);
251 $this->elementEnd('dd');
252 $this->elementEnd('dl');
254 if ($this->group->fullname) {
255 $this->elementStart('dl', 'entity_fn');
256 $this->element('dt', null, _('Full name'));
257 $this->elementStart('dd');
258 $this->element('span', 'fn org', $this->group->fullname);
259 $this->elementEnd('dd');
260 $this->elementEnd('dl');
263 if ($this->group->location) {
264 $this->elementStart('dl', 'entity_location');
265 $this->element('dt', null, _('Location'));
266 $this->element('dd', 'label', $this->group->location);
267 $this->elementEnd('dl');
270 if ($this->group->homepage) {
271 $this->elementStart('dl', 'entity_url');
272 $this->element('dt', null, _('URL'));
273 $this->elementStart('dd');
274 $this->element('a', array('href' => $this->group->homepage,
275 'rel' => 'me', 'class' => 'url'),
276 $this->group->homepage);
277 $this->elementEnd('dd');
278 $this->elementEnd('dl');
281 if ($this->group->description) {
282 $this->elementStart('dl', 'entity_note');
283 $this->element('dt', null, _('Note'));
284 $this->element('dd', 'note', $this->group->description);
285 $this->elementEnd('dl');
288 if (common_config('group', 'maxaliases') > 0) {
289 $aliases = $this->group->getAliases();
291 if (!empty($aliases)) {
292 $this->elementStart('dl', 'entity_aliases');
293 $this->element('dt', null, _('Aliases'));
294 $this->element('dd', 'aliases', implode(' ', $aliases));
295 $this->elementEnd('dl');
299 $this->elementEnd('div');
301 $cur = common_current_user();
302 $this->elementStart('div', 'entity_actions');
303 $this->element('h2', null, _('Group actions'));
304 $this->elementStart('ul');
305 $this->elementStart('li', 'entity_subscribe');
306 if (Event::handle('StartGroupSubscribe', array($this, $this->group))) {
308 if ($cur->isMember($this->group)) {
309 $lf = new LeaveForm($this, $this->group);
311 } else if (!Group_block::isBlocked($this->group, $cur->getProfile())) {
312 $jf = new JoinForm($this, $this->group);
316 Event::handle('EndGroupSubscribe', array($this, $this->group));
318 $this->elementEnd('li');
319 if ($cur && $cur->hasRight(Right::DELETEGROUP)) {
320 $this->elementStart('li', 'entity_delete');
321 $df = new DeleteGroupForm($this, $this->group);
323 $this->elementEnd('li');
325 $this->elementEnd('ul');
326 $this->elementEnd('div');
330 * Get a list of the feeds for this page
338 common_local_url('grouprss',
339 array('nickname' => $this->group->nickname));
341 return array(new Feed(Feed::RSS1,
342 common_local_url('grouprss',
343 array('nickname' => $this->group->nickname)),
344 sprintf(_('Notice feed for %s group (RSS 1.0)'),
345 $this->group->nickname)),
347 common_local_url('ApiTimelineGroup',
348 array('format' => 'rss',
349 'id' => $this->group->id)),
350 sprintf(_('Notice feed for %s group (RSS 2.0)'),
351 $this->group->nickname)),
353 common_local_url('ApiTimelineGroup',
354 array('format' => 'atom',
355 'id' => $this->group->id)),
356 sprintf(_('Notice feed for %s group (Atom)'),
357 $this->group->nickname)),
359 common_local_url('foafgroup',
360 array('nickname' => $this->group->nickname)),
361 sprintf(_('FOAF for %s group'),
362 $this->group->nickname)));
366 * Fill in the sidebar.
371 function showSections()
373 $this->showMembers();
374 $this->showStatistics();
376 $cloud = new GroupTagCloudSection($this, $this->group);
381 * Show mini-list of members
386 function showMembers()
388 $member = $this->group->getMembers(0, MEMBERS_PER_SECTION);
394 $this->elementStart('div', array('id' => 'entity_members',
395 'class' => 'section'));
397 if (Event::handle('StartShowGroupMembersMiniList', array($this))) {
399 $this->element('h2', null, _('Members'));
401 $gmml = new GroupMembersMiniList($member, $this);
402 $cnt = $gmml->show();
404 $this->element('p', null, _('(None)'));
407 if ($cnt > MEMBERS_PER_SECTION) {
408 $this->element('a', array('href' => common_local_url('groupmembers',
409 array('nickname' => $this->group->nickname))),
413 Event::handle('EndShowGroupMembersMiniList', array($this));
416 $this->elementEnd('div');
420 * Show list of admins
425 function showAdmins()
427 $adminSection = new GroupAdminSection($this, $this->group);
428 $adminSection->show();
432 * Show some statistics
437 function showStatistics()
439 $this->elementStart('div', array('id' => 'entity_statistics',
440 'class' => 'section'));
442 $this->element('h2', null, _('Statistics'));
444 $this->elementStart('dl', 'entity_created');
445 $this->element('dt', null, _('Created'));
446 $this->element('dd', null, date('j M Y',
447 strtotime($this->group->created)));
448 $this->elementEnd('dl');
450 $this->elementStart('dl', 'entity_members');
451 $this->element('dt', null, _('Members'));
452 $this->element('dd', null, $this->group->getMemberCount());
453 $this->elementEnd('dl');
455 $this->elementEnd('div');
458 function showAnonymousMessage()
460 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
461 $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
462 'based on the Free Software [StatusNet](http://status.net/) tool. Its members share ' .
463 'short messages about their life and interests. '.
464 '[Join now](%%%%action.register%%%%) to become part of this group and many more! ([Read more](%%%%doc.help%%%%))'),
465 $this->group->nickname);
467 $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
468 'based on the Free Software [StatusNet](http://status.net/) tool. Its members share ' .
469 'short messages about their life and interests. '),
470 $this->group->nickname);
472 $this->elementStart('div', array('id' => 'anon_notice'));
473 $this->raw(common_markup_to_html($m));
474 $this->elementEnd('div');
478 class GroupAdminSection extends ProfileSection
482 function __construct($out, $group)
484 parent::__construct($out);
485 $this->group = $group;
488 function getProfiles()
490 return $this->group->getAdmins();
500 return 'group_admins';
509 class GroupMembersMiniList extends ProfileMiniList
511 function newListItem($profile)
513 return new GroupMembersMiniListItem($profile, $this->action);
517 class GroupMembersMiniListItem extends ProfileMiniListItem
519 function linkAttributes()
521 $aAttrs = parent::linkAttributes();
523 if (common_config('nofollow', 'members')) {
524 $aAttrs['rel'] .= ' nofollow';