3 * Show latest and greatest profile flags
9 * @author Evan Prodromou <evan@status.net>
10 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11 * @link http://status.net/
13 * StatusNet - the distributed open-source microblogging tool
14 * Copyright (C) 2009, StatusNet, Inc.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Affero General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Affero General Public License for more details.
26 * You should have received a copy of the GNU Affero General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 if (!defined('STATUSNET')) {
35 * Show the latest and greatest profile flags
39 * @author Evan Prodromou <evan@status.net>
40 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
41 * @link http://status.net/
44 class AdminprofileflagAction extends Action
47 * Take arguments for running
49 * @param array $args $_REQUEST args
51 * @return boolean success flag
54 function prepare($args)
56 parent::prepare($args);
64 * @param array $args $_REQUEST args; handled in prepare()
69 function handle($args)
71 parent::handle($args);
77 return _('Flagged profiles');
81 * save the profile flag
86 function showContent()
88 $profile = $this->getProfiles();
90 $pl = new FlaggedProfileList($profile, $this);
95 function getProfiles()
97 $ufp = new User_flag_profile();
100 $ufp->selectAdd('profile_id');
101 $ufp->selectAdd('count(*) as flag_count');
103 $ufp->whereAdd('cleared is NULL');
105 $ufp->groupBy('profile_id');
106 $ufp->orderBy('flag_count DESC');
111 while ($ufp->fetch()) {
112 $profile = Profile::staticGet('id', $ufp->profile_id);
113 if (!empty($profile)) {
114 $profiles[] = $profile;
121 return new ArrayWrapper($profiles);
125 class FlaggedProfileList extends ProfileList {
127 function newListItem($profile)
129 return new FlaggedProfileListItem($this->profile, $this->action);
133 class FlaggedProfileListItem extends ProfileListItem
138 function showActions()
140 $this->user = common_current_user();
142 list($action, $this->r2args) = $this->out->returnToArgs();
144 $this->r2args['action'] = $action;
146 $this->startActions();
147 if (Event::handle('StartProfileListItemActionElements', array($this))) {
148 $this->out->elementStart('li', 'entity_moderation');
149 $this->out->element('p', null, _('Moderate'));
150 $this->out->elementStart('ul');
151 $this->showSandboxButton();
152 $this->showSilenceButton();
153 $this->showDeleteButton();
154 $this->showClearButton();
155 $this->out->elementEnd('ul');
156 $this->out->elementEnd('li');
157 Event::handle('EndProfileListItemActionElements', array($this));
162 function showSandboxButton()
164 if ($this->user->hasRight(Right::SANDBOXUSER)) {
165 $this->out->elementStart('li', 'entity_sandbox');
166 if ($this->profile->isSandboxed()) {
167 $usf = new UnSandboxForm($this->out, $this->profile, $this->r2args);
170 $sf = new SandboxForm($this->out, $this->profile, $this->r2args);
173 $this->out->elementEnd('li');
177 function showSilenceButton()
179 if ($this->user->hasRight(Right::SILENCEUSER)) {
180 $this->out->elementStart('li', 'entity_silence');
181 if ($this->profile->isSilenced()) {
182 $usf = new UnSilenceForm($this->out, $this->profile, $this->r2args);
185 $sf = new SilenceForm($this->out, $this->profile, $this->r2args);
188 $this->out->elementEnd('li');
192 function showDeleteButton()
195 if ($this->user->hasRight(Right::DELETEUSER)) {
196 $this->out->elementStart('li', 'entity_delete');
197 $df = new DeleteUserForm($this->out, $this->profile, $this->r2args);
199 $this->out->elementEnd('li');
203 function showClearButton()