3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2011, StatusNet, Inc.
6 * Profile block to show for a group
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Evan Prodromou <evan@status.net>
26 * @copyright 2011 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28 * @link http://status.net/
31 if (!defined('STATUSNET')) {
32 // This check helps protect against security problems;
33 // your code file can't be executed directly from the web.
38 * Profile block to show for a group
42 * @author Evan Prodromou <evan@status.net>
43 * @copyright 2011 StatusNet, Inc.
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
45 * @link http://status.net/
48 class GroupProfileBlock extends ProfileBlock
50 protected $group = null;
52 function __construct($out, $group)
54 parent::__construct($out);
55 $this->group = $group;
60 return ($this->group->homepage_logo) ?
61 $this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
66 return $this->group->getBestName();
71 return $this->group->mainpage;
76 $user = common_current_user();
77 return ((!empty($user)) && ($user->isAdmin($this->group)));
82 return common_local_url('editgroup', array('nickname' => $this->group->nickname));
92 return $this->group->location;
97 return $this->group->homepage;
100 function description()
102 return $this->group->description;
105 function showActions()
107 $cur = common_current_user();
108 $this->out->elementStart('div', 'entity_actions');
109 // TRANS: Group actions header (h2). Text hidden by default.
110 $this->out->element('h2', null, _('Group actions'));
111 $this->out->elementStart('ul');
112 if (Event::handle('StartGroupActionsList', array($this, $this->group))) {
113 $this->out->elementStart('li', 'entity_subscribe');
114 if (Event::handle('StartGroupSubscribe', array($this, $this->group))) {
116 if ($cur->isMember($this->group)) {
117 $lf = new LeaveForm($this->out, $this->group);
119 } else if (!Group_block::isBlocked($this->group, $cur->getProfile())) {
120 $jf = new JoinForm($this->out, $this->group);
124 Event::handle('EndGroupSubscribe', array($this, $this->group));
126 $this->out->elementEnd('li');
127 if ($cur && $cur->hasRight(Right::DELETEGROUP)) {
128 $this->out->elementStart('li', 'entity_delete');
129 $df = new DeleteGroupForm($this->out, $this->group);
131 $this->out->elementEnd('li');
133 Event::handle('EndGroupActionsList', array($this, $this->group));
135 $this->out->elementEnd('ul');
136 $this->out->elementEnd('div');