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)
149 function showLocalNav()
151 $nav = new GroupNav($this, $this->group);
156 * Show the page content
158 * Shows a group profile and a list of group notices
161 function showContent()
163 $this->showGroupProfile();
164 $this->showGroupNotices();
168 * Show the group notices
173 function showGroupNotices()
175 $notice = $this->group->getNotices(($this->page-1)*NOTICES_PER_PAGE,
176 NOTICES_PER_PAGE + 1);
178 $nl = new NoticeList($notice, $this);
181 $this->pagination($this->page > 1,
182 $cnt > NOTICES_PER_PAGE,
185 array('nickname' => $this->group->nickname));
189 * Show the group profile
191 * Information about the group
196 function showGroupProfile()
198 $this->elementStart('div', 'entity_profile vcard author');
200 $this->element('h2', null, _('Group profile'));
202 $this->elementStart('dl', 'entity_depiction');
203 $this->element('dt', null, _('Avatar'));
204 $this->elementStart('dd');
206 $logo = ($this->group->homepage_logo) ?
207 $this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
209 $this->element('img', array('src' => $logo,
210 'class' => 'photo avatar',
211 'width' => AVATAR_PROFILE_SIZE,
212 'height' => AVATAR_PROFILE_SIZE,
213 'alt' => $this->group->nickname));
214 $this->elementEnd('dd');
215 $this->elementEnd('dl');
217 $this->elementStart('dl', 'entity_nickname');
218 $this->element('dt', null, _('Nickname'));
219 $this->elementStart('dd');
220 $hasFN = ($this->group->fullname) ? 'nickname url uid' : 'fn org nickname url uid';
221 $this->element('a', array('href' => $this->group->homeUrl(),
222 'rel' => 'me', 'class' => $hasFN),
223 $this->group->nickname);
224 $this->elementEnd('dd');
225 $this->elementEnd('dl');
227 if ($this->group->fullname) {
228 $this->elementStart('dl', 'entity_fn');
229 $this->element('dt', null, _('Full name'));
230 $this->elementStart('dd');
231 $this->element('span', 'fn org', $this->group->fullname);
232 $this->elementEnd('dd');
233 $this->elementEnd('dl');
236 if ($this->group->location) {
237 $this->elementStart('dl', 'entity_location');
238 $this->element('dt', null, _('Location'));
239 $this->element('dd', 'location', $this->group->location);
240 $this->elementEnd('dl');
243 if ($this->group->homepage) {
244 $this->elementStart('dl', 'entity_url');
245 $this->element('dt', null, _('URL'));
246 $this->elementStart('dd');
247 $this->element('a', array('href' => $this->group->homepage,
248 'rel' => 'me', 'class' => 'url'),
249 $this->group->homepage);
250 $this->elementEnd('dd');
251 $this->elementEnd('dl');
254 if ($this->group->description) {
255 $this->elementStart('dl', 'entity_note');
256 $this->element('dt', null, _('Note'));
257 $this->element('dd', 'note', $this->group->description);
258 $this->elementEnd('dl');
261 $this->elementEnd('div');
263 $this->elementStart('div', 'entity_actions');
264 $this->element('h2', null, _('Group actions'));
265 $this->elementStart('ul');
266 $this->elementStart('li', array('id' => 'entity_subscribe'));
267 $cur = common_current_user();
269 if ($cur->isMember($this->group)) {
270 if (!$cur->isAdmin($this->group)) {
271 $lf = new LeaveForm($this, $this->group);
275 $jf = new JoinForm($this, $this->group);
280 $this->elementEnd('li');
282 $this->elementEnd('ul');
283 $this->elementEnd('div');
287 * Show a list of links to feeds this page produces
292 function showExportData()
294 $fl = new FeedList($this);
295 $fl->show(array(0=>array('href'=>common_local_url('grouprss',
296 array('nickname' => $this->group->nickname)),
298 'version' => 'RSS 1.0',
299 'item' => 'notices')));
303 * Show a list of links to feeds this page produces
311 common_local_url('grouprss',
312 array('nickname' => $this->group->nickname));
314 $this->element('link', array('rel' => 'alternate',
316 'type' => 'application/rss+xml',
317 'title' => sprintf(_('Notice feed for %s group'),
318 $this->group->nickname)));
322 * Fill in the sidebar.
327 function showSections()
329 $this->showMembers();
333 * Show mini-list of members
338 function showMembers()
340 $member = $this->group->getMembers(0, MEMBERS_PER_SECTION);
346 $this->elementStart('div', array('id' => 'entity_subscriptions',
347 'class' => 'section'));
349 $this->element('h2', null, _('Members'));
352 $pml = new ProfileMiniList($member, null, $this);
355 $this->element('p', null, _('(None)'));
359 if ($cnt == MEMBERS_PER_SECTION) {
360 $this->element('a', array('href' => common_local_url('groupmembers',
361 array('nickname' => $this->group->nickname))),