3 * StatusNet, the distributed open-source microblogging tool
5 * Widget to show a sortable list of profiles
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 Zach Copley <zach@status.net>
25 * @copyright 2011 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('GNUSOCIAL')) { exit(1); }
33 * Widget to show a sortable list of subscriptions
37 * @author Zach Copley <zach@status.net>
38 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
39 * @link http://status.net/
41 class SortableGroupList extends SortableSubscriptionList
45 $this->out->elementStart('table', array('class' => 'profile_list xoxo'));
46 $this->out->elementStart('thead');
47 $this->out->elementStart('tr');
49 $tableHeaders = array(
50 // TRANS: Column header in table for user nickname.
51 'nickname' => _m('Nickname'),
52 // TRANS: Column header in table for timestamp when user was created.
53 'created' => _m('Created')
56 foreach ($tableHeaders as $id => $label) {
57 $attrs = array('id' => $id);
58 $current = (!empty($this->action->sort) && $this->action->sort == $id);
60 if ($current || empty($this->action->sort) && $id == 'nickname') {
61 $attrs['class'] = 'current';
64 if ($current && $this->action->reverse) {
65 $attrs['class'] .= ' reverse';
66 $attrs['class'] = trim($attrs['class']);
69 $this->out->elementStart('th', $attrs);
72 $params = array('sort' => $id);
74 if (!empty($this->action->q)) {
75 $params['q'] = $this->action->q;
78 if ($current && !$this->action->reverse) {
79 $params['reverse'] = 'true';
84 $filter = $this->action->arg('filter');
86 if (!empty($filter)) {
87 $args['filter'] = $filter;
90 $linkAttrs['href'] = common_local_url(
91 $this->action->arg('action'), $args, $params
94 $this->out->element('a', $linkAttrs, $label);
95 $this->out->elementEnd('th');
98 // TRANS: Column header in table for members of a group.
99 $this->out->element('th', array('id' => 'Members'), _m('Members'));
100 $this->out->element('th', array('id' => 'controls'), null);
102 $this->out->elementEnd('tr');
103 $this->out->elementEnd('thead');
105 $this->out->elementStart('tbody');
108 <<<<<<< .merge_file_3awMBt
109 function newListItem(Profile $profile)
111 function newListItem(Profile $profile, $odd)
112 >>>>>>> .merge_file_0Q1cxt
114 return new SortableGroupListItem($profile, $this->owner, $this->action);
118 class SortableGroupListItem extends SortableSubscriptionListItem
120 function showHomepage()
122 if ($this->profile->getHomepage()) {
123 $this->out->text(' ');
124 $aAttrs = $this->homepageAttributes();
125 $this->out->elementStart('a', $aAttrs);
126 $this->out->text($this->profile->getHomepage());
127 $this->out->elementEnd('a');
131 function showDescription()
133 if ($this->profile->getDescription()) {
134 $this->out->elementStart('p', 'note');
135 $this->out->text($this->profile->getDescription());
136 $this->out->elementEnd('p');
141 // TODO: Make sure we can do ->getAvatar() for group profiles too!
142 function showAvatar(Profile $profile, $size=null)
144 $logo = $profile->getGroup()->stream_logo ?: User_group::defaultLogo($size ?: $this->avatarSize());
146 $this->out->element('img', array('src' => $logo,
147 'class' => 'avatar u-photo',
148 'width' => AVATAR_STREAM_SIZE,
149 'height' => AVATAR_STREAM_SIZE,
150 'alt' => $profile->getBestName()));
155 if (Event::handle('StartProfileListItem', array($this))) {
157 if (Event::handle('StartProfileListItemProfile', array($this))) {
158 $this->showProfile();
159 Event::handle('EndProfileListItemProfile', array($this));
163 $this->showCreatedDate();
164 $this->showMemberCount();
166 if (Event::handle('StartProfileListItemActions', array($this))) {
167 $this->showActions();
168 Event::handle('EndProfileListItemActions', array($this));
172 Event::handle('EndProfileListItem', array($this));
176 function showProfile()
178 $this->startProfile();
180 $this->showAvatar($this->profile);
181 $this->out->element('a', array('href' => $this->profile->getUrl(),
182 'class' => 'p-org p-nickname',
183 'rel' => 'contact group'),
184 $this->profile->getNickname());
186 $this->showFullName();
187 $this->showLocation();
188 $this->showHomepage();
189 $this->showDescription(); // groups have this instead of bios
195 function endActions()
198 $cur = common_current_user();
199 list($action, $r2args) = $this->out->returnToArgs();
200 $r2args['action'] = $action;
201 if ($cur instanceof User && $cur->hasRight(Right::DELETEGROUP)) {
202 $this->out->elementStart('li', 'entity_delete');
203 $df = new DeleteGroupForm($this->out, $this->profile->getGroup(), $r2args);
205 $this->out->elementEnd('li');
208 $this->out->elementEnd('ul');
209 $this->out->elementEnd('td');
212 function showActions()
214 $this->startActions();
215 if (Event::handle('StartProfileListItemActionElements', array($this))) {
216 $this->showJoinButton();
217 Event::handle('EndProfileListItemActionElements', array($this));
222 function showJoinButton()
224 $user = $this->owner;
226 if ($user instanceof User) {
227 $this->out->elementStart('li', 'entity_subscribe');
228 // XXX: special-case for user looking at own
229 // subscriptions page
230 if ($user->isMember($this->profile->getGroup())) {
231 $lf = new LeaveForm($this->out, $this->profile->getGroup());
233 } else if (!Group_block::isBlocked($this->profile->getGroup(), $user->getProfile())) {
234 $jf = new JoinForm($this->out, $this->profile->getGroup());
238 $this->out->elementEnd('li');
242 function showMemberCount()
244 $this->out->elementStart('td', 'entry_member_count');
245 $this->out->text($this->profile->getGroup()->getMemberCount());
246 $this->out->elementEnd('td');
249 function showCreatedDate()
251 $this->out->elementStart('td', 'entry_created');
252 // @todo FIXME: Should we provide i18n for timestamps in core?
253 $this->out->text(date('j M Y', strtotime($this->profile->created)));
254 $this->out->elementEnd('td');
257 function showAdmins()
259 $this->out->elementStart('td', 'entry_admins');
261 $this->out->text('gargargar');
262 $this->out->elementEnd('td');
266 * Only show the tags if we're logged in
270 if (common_logged_in()) {