4 * StatusNet, the distributed open-source microblogging tool
6 * Widget to show a list of groups
10 * LICENCE: 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 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/widget.php';
38 * Widget to show a list of groups
42 * @author Evan Prodromou <evan@status.net>
43 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
44 * @link http://status.net/
47 class GroupList extends Widget
49 /** Current group, group query. */
51 /** Owner of this list */
53 /** Action object using us. */
56 function __construct($group, $owner=null, $action=null)
58 parent::__construct($action);
60 $this->group = $group;
61 $this->owner = $owner;
62 $this->action = $action;
67 $this->out->elementStart('ul', 'profiles groups xoxo');
71 while ($this->group->fetch()) {
73 if($cnt > GROUPS_PER_PAGE) {
79 $this->out->elementEnd('ul');
86 $this->out->elementStart('li', array('class' => 'profile hentry',
87 'id' => 'group-' . $this->group->id));
89 $user = common_current_user();
91 $this->out->elementStart('div', 'entity_profile vcard entry-content');
93 $logo = ($this->group->stream_logo) ?
94 $this->group->stream_logo : User_group::defaultLogo(AVATAR_STREAM_SIZE);
96 $this->out->elementStart('a', array('href' => $this->group->homeUrl(),
97 'class' => 'url entry-title',
98 'rel' => 'contact group'));
99 $this->out->element('img', array('src' => $logo,
100 'class' => 'photo avatar',
101 'width' => AVATAR_STREAM_SIZE,
102 'height' => AVATAR_STREAM_SIZE,
104 ($this->group->fullname) ? $this->group->fullname :
105 $this->group->nickname));
106 $this->out->text(' ');
107 $hasFN = ($this->group->fullname) ? 'nickname' : 'fn org nickname';
108 $this->out->elementStart('span', $hasFN);
109 $this->out->raw($this->highlight($this->group->nickname));
110 $this->out->elementEnd('span');
111 $this->out->elementEnd('a');
113 if ($this->group->fullname) {
114 $this->out->text(' ');
115 $this->out->elementStart('span', 'fn org');
116 $this->out->raw($this->highlight($this->group->fullname));
117 $this->out->elementEnd('span');
119 if ($this->group->location) {
120 $this->out->text(' ');
121 $this->out->elementStart('span', 'label');
122 $this->out->raw($this->highlight($this->group->location));
123 $this->out->elementEnd('span');
125 if ($this->group->homepage) {
126 $this->out->text(' ');
127 $this->out->elementStart('a', array('href' => $this->group->homepage,
129 $this->out->raw($this->highlight($this->group->homepage));
130 $this->out->elementEnd('a');
132 if ($this->group->description) {
133 $this->out->elementStart('p', 'note');
134 $this->out->raw($this->highlight($this->group->description));
135 $this->out->elementEnd('p');
138 // If we're on a list with an owner (subscriptions or subscribers)...
140 if (!empty($user) && !empty($this->owner) && $user->id == $this->owner->id) {
141 $this->showOwnerControls();
144 $this->out->elementEnd('div');
147 $this->out->elementStart('div', 'entity_actions');
148 $this->out->elementStart('ul');
149 $this->out->elementStart('li', 'entity_subscribe');
150 // XXX: special-case for user looking at own
151 // subscriptions page
152 if ($user->isMember($this->group)) {
153 $lf = new LeaveForm($this->out, $this->group);
155 } else if (!Group_block::isBlocked($this->group, $user->getProfile())) {
156 $jf = new JoinForm($this->out, $this->group);
159 $this->out->elementEnd('li');
160 $this->out->elementEnd('ul');
161 $this->out->elementEnd('div');
164 $this->out->elementEnd('li');
167 /* Override this in subclasses. */
169 function showOwnerControls()
174 function highlight($text)
176 return htmlspecialchars($text);