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. */
58 * @return string page title, with page number
63 if ($this->page == 1) {
64 return sprintf(_("%s group"), $this->group->nickname);
66 return sprintf(_("%s group, page %d"),
67 $this->group->nickname,
75 * Reads and validates arguments and instantiates the attributes.
77 * @param array $args $_REQUEST args
79 * @return boolean success flag
82 function prepare($args)
84 parent::prepare($args);
86 if (!common_config('inboxes','enabled')) {
87 $this->serverError(_('Inboxes must be enabled for groups to work'));
91 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
93 $nickname_arg = $this->arg('nickname');
94 $nickname = common_canonical_nickname($nickname_arg);
96 // Permanent redirect on non-canonical nickname
98 if ($nickname_arg != $nickname) {
99 $args = array('nickname' => $nickname);
100 if ($this->page != 1) {
101 $args['page'] = $this->page;
103 common_redirect(common_local_url('showgroup', $args), 301);
108 $this->clientError(_('No nickname'), 404);
112 $this->group = User_group::staticGet('nickname', $nickname);
115 $this->clientError(_('No such group'), 404);
125 * Shows a profile for the group, some controls, and a list of
131 function handle($args)
137 * Show the page content
139 * Shows a group profile and a list of group notices
142 function showContent()
144 $this->showGroupProfile();
145 $this->showGroupNotices();
149 * Show the group notices
154 function showGroupNotices()
156 $notice = $this->group->getNotices(($this->page-1)*NOTICES_PER_PAGE,
157 NOTICES_PER_PAGE + 1);
159 $nl = new NoticeList($notice, $this);
162 $this->pagination($this->page > 1,
163 $cnt > NOTICES_PER_PAGE,
166 array('nickname' => $this->group->nickname));
170 * Show the group profile
172 * Information about the group
177 function showGroupProfile()
179 $this->elementStart('div', array('id' => 'group_profile',
180 'class' => 'vcard author'));
182 $this->element('h2', null, _('Group profile'));
184 $this->elementStart('dl', 'group_depiction');
185 $this->element('dt', null, _('Photo'));
186 $this->elementStart('dd');
188 $logo = ($this->group->homepage_logo) ?
189 $this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
191 $this->element('img', array('src' => $logo,
192 'class' => 'photo avatar',
193 'width' => AVATAR_PROFILE_SIZE,
194 'height' => AVATAR_PROFILE_SIZE,
195 'alt' => $this->group->nickname));
196 $this->elementEnd('dd');
197 $this->elementEnd('dl');
199 $this->elementStart('dl', 'group_nickname');
200 $this->element('dt', null, _('Nickname'));
201 $this->elementStart('dd');
202 $hasFN = ($this->group->fullname) ? 'nickname url uid' : 'fn nickname url uid';
203 $this->element('a', array('href' => $this->group->homeUrl(),
204 'rel' => 'me', 'class' => $hasFN),
205 $this->group->nickname);
206 $this->elementEnd('dd');
207 $this->elementEnd('dl');
209 if ($this->group->fullname) {
210 $this->elementStart('dl', 'group_fn');
211 $this->element('dt', null, _('Full name'));
212 $this->elementStart('dd');
213 $this->element('span', 'fn', $this->group->fullname);
214 $this->elementEnd('dd');
215 $this->elementEnd('dl');
218 if ($this->group->location) {
219 $this->elementStart('dl', 'group_location');
220 $this->element('dt', null, _('Location'));
221 $this->element('dd', 'location', $this->group->location);
222 $this->elementEnd('dl');
225 if ($this->group->homepage) {
226 $this->elementStart('dl', 'group_url');
227 $this->element('dt', null, _('URL'));
228 $this->elementStart('dd');
229 $this->element('a', array('href' => $this->group->homepage,
230 'rel' => 'me', 'class' => 'url'),
231 $this->group->homepage);
232 $this->elementEnd('dd');
233 $this->elementEnd('dl');
236 if ($this->group->description) {
237 $this->elementStart('dl', 'group_note');
238 $this->element('dt', null, _('Note'));
239 $this->element('dd', 'note', $this->group->description);
240 $this->elementEnd('dl');
243 $this->elementEnd('div');
245 $this->elementStart('div', array('id' => 'group_actions'));
246 $this->element('h2', null, _('Group actions'));
247 $this->elementStart('ul');
248 $this->elementStart('li', array('id' => 'group_subscribe'));
249 $cur = common_current_user();
251 if ($cur->isMember($this->group)) {
252 $lf = new LeaveForm($this, $this->group);
254 if ($cur->isAdmin($this->group)) {
255 $edit = common_local_url('editgroup',
256 array('nickname' => $this->group->nickname));
258 array('href' => $edit,
259 'id' => 'group_admin'),
263 $jf = new JoinForm($this, $this->group);
268 $this->elementEnd('li');
270 $this->elementEnd('ul');
271 $this->elementEnd('div');
275 * Show a list of links to feeds this page produces
280 function showExportData()
282 $fl = new FeedList($this);
283 $fl->show(array(0=>array('href'=>common_local_url('grouprss',
284 array('nickname' => $this->group->nickname)),
286 'version' => 'RSS 1.0',
287 'item' => 'notices')));
291 * Show a list of links to feeds this page produces
299 common_local_url('grouprss',
300 array('nickname' => $this->group->nickname));
302 $this->element('link', array('rel' => 'alternate',
304 'type' => 'application/rss+xml',
305 'title' => sprintf(_('Notice feed for %s group'),
306 $this->group->nickname)));