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->showSandboxButton();
149 $this->showSilenceButton();
150 $this->showDeleteButton();
151 $this->showClearButton();
152 Event::handle('EndProfileListItemActionElements', array($this));
157 function showSandboxButton()
159 if ($this->user->hasRight(Right::SANDBOXUSER)) {
160 $this->out->elementStart('li', 'entity_sandbox');
161 if ($this->profile->isSandboxed()) {
162 $usf = new UnSandboxForm($this->out, $this->profile, $this->r2args);
165 $sf = new SandboxForm($this->out, $this->profile, $this->r2args);
168 $this->out->elementEnd('li');
172 function showSilenceButton()
174 if ($this->user->hasRight(Right::SILENCEUSER)) {
175 $this->out->elementStart('li', 'entity_silence');
176 if ($this->profile->isSilenced()) {
177 $usf = new UnSilenceForm($this->out, $this->profile, $this->r2args);
180 $sf = new SilenceForm($this->out, $this->profile, $this->r2args);
183 $this->out->elementEnd('li');
187 function showDeleteButton()
190 if ($this->user->hasRight(Right::DELETEUSER)) {
191 $this->out->elementStart('li', 'entity_delete');
192 $df = new DeleteUserForm($this->out, $this->profile, $this->r2args);
194 $this->out->elementEnd('li');
198 function showClearButton()