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';
43 * @author Evan Prodromou <evan@controlyourself.ca>
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45 * @link http://laconi.ca/
48 class ShowgroupAction extends Action
50 /** group we're viewing. */
52 /** page we're viewing. */
56 * Is this page read-only?
58 * @return boolean true
69 * @return string page title, with page number
74 if ($this->page == 1) {
75 return sprintf(_("%s group"), $this->group->nickname);
77 return sprintf(_("%s group, page %d"),
78 $this->group->nickname,
86 * Reads and validates arguments and instantiates the attributes.
88 * @param array $args $_REQUEST args
90 * @return boolean success flag
93 function prepare($args)
95 parent::prepare($args);
97 if (!common_config('inboxes','enabled')) {
98 $this->serverError(_('Inboxes must be enabled for groups to work'));
102 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
104 $nickname_arg = $this->arg('nickname');
105 $nickname = common_canonical_nickname($nickname_arg);
107 // Permanent redirect on non-canonical nickname
109 if ($nickname_arg != $nickname) {
110 $args = array('nickname' => $nickname);
111 if ($this->page != 1) {
112 $args['page'] = $this->page;
114 common_redirect(common_local_url('showgroup', $args), 301);
119 $this->clientError(_('No nickname'), 404);
123 $this->group = User_group::staticGet('nickname', $nickname);
126 $this->clientError(_('No such group'), 404);
136 * Shows a profile for the group, some controls, and a list of
142 function handle($args)
148 * Show the page content
150 * Shows a group profile and a list of group notices
153 function showContent()
155 $this->showGroupProfile();
156 $this->showGroupNotices();
160 * Show the group notices
165 function showGroupNotices()
167 $notice = $this->group->getNotices(($this->page-1)*NOTICES_PER_PAGE,
168 NOTICES_PER_PAGE + 1);
170 $nl = new NoticeList($notice, $this);
173 $this->pagination($this->page > 1,
174 $cnt > NOTICES_PER_PAGE,
177 array('nickname' => $this->group->nickname));
181 * Show the group profile
183 * Information about the group
188 function showGroupProfile()
190 $this->elementStart('div', array('id' => 'group_profile',
191 'class' => 'vcard author'));
193 $this->element('h2', null, _('Group profile'));
195 $this->elementStart('dl', 'group_depiction');
196 $this->element('dt', null, _('Photo'));
197 $this->elementStart('dd');
199 $logo = ($this->group->homepage_logo) ?
200 $this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
202 $this->element('img', array('src' => $logo,
203 'class' => 'photo avatar',
204 'width' => AVATAR_PROFILE_SIZE,
205 'height' => AVATAR_PROFILE_SIZE,
206 'alt' => $this->group->nickname));
207 $this->elementEnd('dd');
208 $this->elementEnd('dl');
210 $this->elementStart('dl', 'group_nickname');
211 $this->element('dt', null, _('Nickname'));
212 $this->elementStart('dd');
213 $hasFN = ($this->group->fullname) ? 'nickname url uid' : 'fn nickname url uid';
214 $this->element('a', array('href' => $this->group->homeUrl(),
215 'rel' => 'me', 'class' => $hasFN),
216 $this->group->nickname);
217 $this->elementEnd('dd');
218 $this->elementEnd('dl');
220 if ($this->group->fullname) {
221 $this->elementStart('dl', 'group_fn');
222 $this->element('dt', null, _('Full name'));
223 $this->elementStart('dd');
224 $this->element('span', 'fn', $this->group->fullname);
225 $this->elementEnd('dd');
226 $this->elementEnd('dl');
229 if ($this->group->location) {
230 $this->elementStart('dl', 'group_location');
231 $this->element('dt', null, _('Location'));
232 $this->element('dd', 'location', $this->group->location);
233 $this->elementEnd('dl');
236 if ($this->group->homepage) {
237 $this->elementStart('dl', 'group_url');
238 $this->element('dt', null, _('URL'));
239 $this->elementStart('dd');
240 $this->element('a', array('href' => $this->group->homepage,
241 'rel' => 'me', 'class' => 'url'),
242 $this->group->homepage);
243 $this->elementEnd('dd');
244 $this->elementEnd('dl');
247 if ($this->group->description) {
248 $this->elementStart('dl', 'group_note');
249 $this->element('dt', null, _('Note'));
250 $this->element('dd', 'note', $this->group->description);
251 $this->elementEnd('dl');
254 $this->elementEnd('div');
256 $this->elementStart('div', array('id' => 'group_actions'));
257 $this->element('h2', null, _('Group actions'));
258 $this->elementStart('ul');
259 $this->elementStart('li', array('id' => 'group_subscribe'));
260 $cur = common_current_user();
262 if ($cur->isMember($this->group)) {
263 $lf = new LeaveForm($this, $this->group);
265 if ($cur->isAdmin($this->group)) {
266 $edit = common_local_url('editgroup',
267 array('nickname' => $this->group->nickname));
269 array('href' => $edit,
270 'id' => 'group_admin'),
274 $jf = new JoinForm($this, $this->group);
279 $this->elementEnd('li');
281 $this->elementEnd('ul');
282 $this->elementEnd('div');
286 * Show a list of links to feeds this page produces
291 function showExportData()
293 $fl = new FeedList($this);
294 $fl->show(array(0=>array('href'=>common_local_url('grouprss',
295 array('nickname' => $this->group->nickname)),
297 'version' => 'RSS 1.0',
298 'item' => 'notices')));
302 * Show a list of links to feeds this page produces
310 common_local_url('grouprss',
311 array('nickname' => $this->group->nickname));
313 $this->element('link', array('rel' => 'alternate',
315 'type' => 'application/rss+xml',
316 'title' => sprintf(_('Notice feed for %s group'),
317 $this->group->nickname)));