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
137 function showActions()
139 $this->user = common_current_user();
141 $this->startActions();
142 if (Event::handle('StartProfileListItemActionElements', array($this))) {
143 $this->showSandboxButton();
144 $this->showSilenceButton();
145 $this->showDeleteButton();
146 $this->showClearButton();
147 Event::handle('EndProfileListItemActionElements', array($this));
152 function showSandboxButton()
154 if ($this->user->hasRight(Right::SANDBOXUSER)) {
155 $this->out->elementStart('li', 'entity_sandbox');
156 if ($this->user->isSandboxed()) {
157 $usf = new UnSandboxForm($this->out, $this->profile);
160 $sf = new SandboxForm($this->out, $this->profile);
163 $this->out->elementEnd('li');
167 function showSilenceButton()
169 if ($this->user->hasRight(Right::SILENCEUSER)) {
170 $this->out->elementStart('li', 'entity_silence');
171 if ($this->user->isSilenced()) {
172 $usf = new UnSilenceForm($this->out, $this->profile);
175 $sf = new SilenceForm($this->out, $this->profile);
178 $this->out->elementEnd('li');
182 function showDeleteButton()
185 if ($this->user->hasRight(Right::DELETEUSER)) {
186 $this->out->elementStart('li', 'entity_delete');
187 $df = new DeleteUserForm($this->out, $this->profile);
189 $this->out->elementEnd('li');
193 function showClearButton()