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(_("%s group, page %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 $this->group = User_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 $this->clientError(_('No such group'), 404);
142 common_set_returnto($this->selfUrl());
150 * Shows a profile for the group, some controls, and a list of
156 function handle($args)
167 function showLocalNav()
169 $nav = new GroupNav($this, $this->group);
174 * Show the page content
176 * Shows a group profile and a list of group notices
179 function showContent()
181 $this->showGroupProfile();
182 $this->showGroupNotices();
186 * Show the group notices
191 function showGroupNotices()
193 $notice = $this->group->getNotices(($this->page-1)*NOTICES_PER_PAGE,
194 NOTICES_PER_PAGE + 1);
196 $nl = new NoticeList($notice, $this);
199 $this->pagination($this->page > 1,
200 $cnt > NOTICES_PER_PAGE,
203 array('nickname' => $this->group->nickname));
207 * Show the group profile
209 * Information about the group
214 function showGroupProfile()
216 $this->elementStart('div', 'entity_profile vcard author');
218 $this->element('h2', null, _('Group profile'));
220 $this->elementStart('dl', 'entity_depiction');
221 $this->element('dt', null, _('Avatar'));
222 $this->elementStart('dd');
224 $logo = ($this->group->homepage_logo) ?
225 $this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
227 $this->element('img', array('src' => $logo,
228 'class' => 'photo avatar',
229 'width' => AVATAR_PROFILE_SIZE,
230 'height' => AVATAR_PROFILE_SIZE,
231 'alt' => $this->group->nickname));
232 $this->elementEnd('dd');
233 $this->elementEnd('dl');
235 $this->elementStart('dl', 'entity_nickname');
236 $this->element('dt', null, _('Nickname'));
237 $this->elementStart('dd');
238 $hasFN = ($this->group->fullname) ? 'nickname url uid' : 'fn org nickname url uid';
239 $this->element('a', array('href' => $this->group->homeUrl(),
240 'rel' => 'me', 'class' => $hasFN),
241 $this->group->nickname);
242 $this->elementEnd('dd');
243 $this->elementEnd('dl');
245 if ($this->group->fullname) {
246 $this->elementStart('dl', 'entity_fn');
247 $this->element('dt', null, _('Full name'));
248 $this->elementStart('dd');
249 $this->element('span', 'fn org', $this->group->fullname);
250 $this->elementEnd('dd');
251 $this->elementEnd('dl');
254 if ($this->group->location) {
255 $this->elementStart('dl', 'entity_location');
256 $this->element('dt', null, _('Location'));
257 $this->element('dd', 'label', $this->group->location);
258 $this->elementEnd('dl');
261 if ($this->group->homepage) {
262 $this->elementStart('dl', 'entity_url');
263 $this->element('dt', null, _('URL'));
264 $this->elementStart('dd');
265 $this->element('a', array('href' => $this->group->homepage,
266 'rel' => 'me', 'class' => 'url'),
267 $this->group->homepage);
268 $this->elementEnd('dd');
269 $this->elementEnd('dl');
272 if ($this->group->description) {
273 $this->elementStart('dl', 'entity_note');
274 $this->element('dt', null, _('Note'));
275 $this->element('dd', 'note', $this->group->description);
276 $this->elementEnd('dl');
279 if (common_config('group', 'maxaliases') > 0) {
280 $aliases = $this->group->getAliases();
282 if (!empty($aliases)) {
283 $this->elementStart('dl', 'entity_aliases');
284 $this->element('dt', null, _('Aliases'));
285 $this->element('dd', 'aliases', implode(' ', $aliases));
286 $this->elementEnd('dl');
290 $this->elementEnd('div');
292 $this->elementStart('div', 'entity_actions');
293 $this->element('h2', null, _('Group actions'));
294 $this->elementStart('ul');
295 $this->elementStart('li', 'entity_subscribe');
296 $cur = common_current_user();
298 if ($cur->isMember($this->group)) {
299 $lf = new LeaveForm($this, $this->group);
301 } else if (!Group_block::isBlocked($this->group, $cur->getProfile())) {
302 $jf = new JoinForm($this, $this->group);
307 $this->elementEnd('li');
309 $this->elementEnd('ul');
310 $this->elementEnd('div');
314 * Get a list of the feeds for this page
322 common_local_url('grouprss',
323 array('nickname' => $this->group->nickname));
325 return array(new Feed(Feed::RSS1,
326 common_local_url('grouprss',
327 array('nickname' => $this->group->nickname)),
328 sprintf(_('Notice feed for %s group (RSS 1.0)'),
329 $this->group->nickname)),
331 common_local_url('ApiTimelineGroup',
332 array('format' => 'rss',
333 'id' => $this->group->nickname)),
334 sprintf(_('Notice feed for %s group (RSS 2.0)'),
335 $this->group->nickname)),
337 common_local_url('ApiTimelineGroup',
338 array('format' => 'atom',
339 'id' => $this->group->nickname)),
340 sprintf(_('Notice feed for %s group (Atom)'),
341 $this->group->nickname)),
343 common_local_url('foafgroup',
344 array('nickname' => $this->group->nickname)),
345 sprintf(_('FOAF for %s group'),
346 $this->group->nickname)));
350 * Fill in the sidebar.
355 function showSections()
357 $this->showMembers();
358 $this->showStatistics();
360 $cloud = new GroupTagCloudSection($this, $this->group);
365 * Show mini-list of members
370 function showMembers()
372 $member = $this->group->getMembers(0, MEMBERS_PER_SECTION);
378 $this->elementStart('div', array('id' => 'entity_members',
379 'class' => 'section'));
381 $this->element('h2', null, _('Members'));
383 $pml = new ProfileMiniList($member, $this);
386 $this->element('p', null, _('(None)'));
389 if ($cnt > MEMBERS_PER_SECTION) {
390 $this->element('a', array('href' => common_local_url('groupmembers',
391 array('nickname' => $this->group->nickname))),
395 $this->elementEnd('div');
399 * Show list of admins
404 function showAdmins()
406 $adminSection = new GroupAdminSection($this, $this->group);
407 $adminSection->show();
411 * Show some statistics
416 function showStatistics()
418 // XXX: WORM cache this
419 $members = $this->group->getMembers();
421 /** $member->count() doesn't work. */
422 while ($members->fetch()) {
426 $this->elementStart('div', array('id' => 'entity_statistics',
427 'class' => 'section'));
429 $this->element('h2', null, _('Statistics'));
431 $this->elementStart('dl', 'entity_created');
432 $this->element('dt', null, _('Created'));
433 $this->element('dd', null, date('j M Y',
434 strtotime($this->group->created)));
435 $this->elementEnd('dl');
437 $this->elementStart('dl', 'entity_members');
438 $this->element('dt', null, _('Members'));
439 $this->element('dd', null, (is_int($members_count)) ? $members_count : '0');
440 $this->elementEnd('dl');
442 $this->elementEnd('div');
445 function showAnonymousMessage()
447 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
448 $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
449 'based on the Free Software [StatusNet](http://status.net/) tool. Its members share ' .
450 'short messages about their life and interests. '.
451 '[Join now](%%%%action.register%%%%) to become part of this group and many more! ([Read more](%%%%doc.help%%%%))'),
452 $this->group->nickname);
454 $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
455 'based on the Free Software [StatusNet](http://status.net/) tool. Its members share ' .
456 'short messages about their life and interests. '),
457 $this->group->nickname);
459 $this->elementStart('div', array('id' => 'anon_notice'));
460 $this->raw(common_markup_to_html($m));
461 $this->elementEnd('div');
465 class GroupAdminSection extends ProfileSection
469 function __construct($out, $group)
471 parent::__construct($out);
472 $this->group = $group;
475 function getProfiles()
477 return $this->group->getAdmins();
487 return 'group_admins';