56 private $blockStatusByUid;
62 private $excludegroups;
93 $this->RCMaxAge = $this->
getConfig()->get( MainConfigNames::ActiveUserDays );
94 $this->requestedUser =
'';
98 $username = Title::makeTitleSafe(
NS_USER, $un );
99 if ( $username !==
null ) {
100 $this->requestedUser = $username->getText();
108 $this->excludegroups[] =
'bot';
111 $this->excludegroups[] =
'sysop';
122 $activeUserSeconds = $this->
getConfig()->get( MainConfigNames::ActiveUserDays ) * 86400;
123 $timestamp =
$dbr->timestamp( (
int)
wfTimestamp( TS_UNIX ) - $activeUserSeconds );
127 $tables = [
'querycachetwo',
'user',
'actor' ];
128 $fields = [
'qcc_title',
'user_id',
'actor_id' ];
130 'user' => [
'JOIN',
'user_name = qcc_title' ],
131 'actor' => [
'JOIN',
'actor_user = user_id' ],
134 'qcc_type' =>
'activeusers',
138 if ( $data !==
null ) {
139 $options[
'ORDER BY'] =
'qcc_title ' . $data[
'order'];
140 $options[
'LIMIT'] = $data[
'limit'];
141 $conds = array_merge( $conds, $data[
'conds'] );
143 if ( $this->requestedUser !=
'' ) {
144 $conds[] =
'qcc_title >= ' .
$dbr->addQuotes( $this->requestedUser );
146 if ( $this->groups !== [] ) {
147 $tables[
'ug1'] =
'user_groups';
148 $jconds[
'ug1'] = [
'JOIN',
'ug1.ug_user = user_id' ];
150 $conds[] =
'ug1.ug_expiry IS NULL OR ug1.ug_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() );
152 if ( $this->excludegroups !== [] ) {
153 $tables[
'ug2'] =
'user_groups';
154 $jconds[
'ug2'] = [
'LEFT JOIN', [
155 'ug2.ug_user = user_id',
156 'ug2.ug_group' => $this->excludegroups,
157 'ug2.ug_expiry IS NULL OR ug2.ug_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() ),
159 $conds[
'ug2.ug_user'] =
null;
162 $conds[] =
'NOT EXISTS (' .
$dbr->selectSQLText(
163 'ipblocks',
'1', [
'ipb_user=user_id',
'ipb_deleted' => 1 ], __METHOD__
166 $subquery =
$dbr->buildSelectSubquery( $tables, $fields, $conds, $fname, $options, $jconds );
169 $tables = [
'qcc_users' => $subquery,
'recentchanges' ];
170 $jconds = [
'recentchanges' => [
'LEFT JOIN', [
171 'rc_actor = actor_id',
174 'rc_log_type IS NULL OR rc_log_type != ' .
$dbr->addQuotes(
'newusers' ),
175 'rc_timestamp >= ' .
$dbr->addQuotes( $timestamp ),
183 'user_name' =>
'qcc_title',
184 'user_id' =>
'user_id',
185 'recentedits' =>
'COUNT(rc_id)'
187 'options' => [
'GROUP BY' => [
'qcc_title',
'user_id' ] ],
189 'join_conds' => $jconds,
196 $sortColumns = array_merge( [ $this->mIndexField ], $this->mExtraSortFields );
197 if ( $order === self::QUERY_ASCENDING ) {
199 $orderBy = $sortColumns;
200 $operator = $this->mIncludeOffset ?
'>=' :
'>';
204 foreach ( $sortColumns as $col ) {
205 $orderBy[] = $col .
' DESC';
207 $operator = $this->mIncludeOffset ?
'<=' :
'<';
210 'limit' => intval( $limit ),
213 $offset !=
'' ? [ $this->mIndexField . $operator . $this->
getDatabase()->addQuotes( $offset ) ] : [],
216 $tables = $info[
'tables'];
217 $fields = $info[
'fields'];
218 $conds = $info[
'conds'];
219 $options = $info[
'options'];
220 $join_conds = $info[
'join_conds'];
221 $options[
'ORDER BY'] = $orderBy;
222 return [ $tables, $fields, $conds, $fname, $options, $join_conds ];
226 parent::doBatchLookups();
229 foreach ( $this->mResult as $row ) {
230 $uids[] = $row->user_id;
238 [
'ipb_user',
'deleted' =>
'MAX(ipb_deleted)',
'sitewide' =>
'MAX(ipb_sitewide)' ],
239 [
'ipb_user' => $uids ],
241 [
'GROUP BY' => [
'ipb_user' ] ]
243 $this->blockStatusByUid = [];
244 foreach (
$res as $row ) {
245 $this->blockStatusByUid[$row->ipb_user] = [
246 'deleted' => $row->deleted,
247 'sitewide' => $row->sitewide,
250 $this->mResult->seek( 0 );
254 $userName = $row->user_name;
256 $ulinks = Linker::userLink( $row->user_id, $userName );
257 $ulinks .= Linker::userToolLinks(
276 foreach ( $ugms as $ugm ) {
287 $isBlocked = isset( $this->blockStatusByUid[$row->user_id] );
289 if ( $this->blockStatusByUid[$row->user_id][
'deleted'] == 1 ) {
290 $item =
"<span class=\"deleted\">$item</span>";
292 if ( $this->blockStatusByUid[$row->user_id][
'sitewide'] == 1 ) {
293 $blocked =
' ' . $this->
msg(
'listusers-blocked', $userName )->escaped();
296 $count = $this->
msg(
'activeusers-count' )->numParams( $row->recentedits )
297 ->params( $userName )->numParams( $this->RCMaxAge )->escaped();
299 return Html::rawElement(
'li', [],
"{$item} [{$count}]{$blocked}" );
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
A class containing constants representing the names of configuration variables.
Interface for objects which can provide a MediaWiki context on request.
if(!isset( $args[0])) $lang