87 $this->RCMaxAge = $this->
getConfig()->get(
'ActiveUserDays' );
88 $this->requestedUser =
'';
93 if ( $username !==
null ) {
94 $this->requestedUser = $username->getText();
102 $this->excludegroups[] =
'bot';
105 $this->excludegroups[] =
'sysop';
116 $activeUserSeconds = $this->
getConfig()->get(
'ActiveUserDays' ) * 86400;
117 $timestamp =
$dbr->timestamp(
wfTimestamp( TS_UNIX ) - $activeUserSeconds );
121 $tables = [
'querycachetwo',
'user',
'actor' ];
122 $fields = [
'qcc_title',
'user_id',
'actor_id' ];
124 'user' => [
'JOIN',
'user_name = qcc_title' ],
125 'actor' => [
'JOIN',
'actor_user = user_id' ],
128 'qcc_type' =>
'activeusers',
132 if ( $data !==
null ) {
133 $options[
'ORDER BY'] =
'qcc_title ' . $data[
'order'];
134 $options[
'LIMIT'] = $data[
'limit'];
135 $conds = array_merge( $conds, $data[
'conds'] );
137 if ( $this->requestedUser !=
'' ) {
138 $conds[] =
'qcc_title >= ' .
$dbr->addQuotes( $this->requestedUser );
140 if ( $this->groups !== [] ) {
141 $tables[
'ug1'] =
'user_groups';
142 $jconds[
'ug1'] = [
'JOIN',
'ug1.ug_user = user_id' ];
144 $conds[] =
'ug1.ug_expiry IS NULL OR ug1.ug_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() );
146 if ( $this->excludegroups !== [] ) {
147 $tables[
'ug2'] =
'user_groups';
148 $jconds[
'ug2'] = [
'LEFT JOIN', [
149 'ug2.ug_user = user_id',
151 'ug2.ug_expiry IS NULL OR ug2.ug_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() ),
153 $conds[
'ug2.ug_user'] =
null;
156 $conds[] =
'NOT EXISTS (' .
$dbr->selectSQLText(
157 'ipblocks',
'1', [
'ipb_user=user_id',
'ipb_deleted' => 1 ], __METHOD__
160 $subquery =
$dbr->buildSelectSubquery( $tables, $fields, $conds, $fname, $options, $jconds );
163 $tables = [
'qcc_users' => $subquery,
'recentchanges' ];
164 $jconds = [
'recentchanges' => [
'LEFT JOIN', [
165 'rc_actor = actor_id',
168 'rc_log_type IS NULL OR rc_log_type != ' .
$dbr->addQuotes(
'newusers' ),
169 'rc_timestamp >= ' .
$dbr->addQuotes( $timestamp ),
177 'user_name' =>
'qcc_title',
178 'user_id' =>
'user_id',
179 'recentedits' =>
'COUNT(rc_id)'
181 'options' => [
'GROUP BY' => [
'qcc_title',
'user_id' ] ],
183 'join_conds' => $jconds,
190 $sortColumns = array_merge( [ $this->mIndexField ], $this->mExtraSortFields );
191 if ( $order === self::QUERY_ASCENDING ) {
193 $orderBy = $sortColumns;
194 $operator = $this->mIncludeOffset ?
'>=' :
'>';
198 foreach ( $sortColumns as $col ) {
199 $orderBy[] = $col .
' DESC';
201 $operator = $this->mIncludeOffset ?
'<=' :
'<';
204 'limit' => intval( $limit ),
207 $offset !=
'' ? [ $this->mIndexField . $operator . $this->
getDatabase()->addQuotes( $offset ) ] : [],
210 $tables = $info[
'tables'];
211 $fields = $info[
'fields'];
212 $conds = $info[
'conds'];
213 $options = $info[
'options'];
214 $join_conds = $info[
'join_conds'];
215 $options[
'ORDER BY'] = $orderBy;
216 return [ $tables, $fields, $conds, $fname, $options, $join_conds ];
220 parent::doBatchLookups();
223 foreach ( $this->mResult as $row ) {
224 $uids[] = $row->user_id;
232 [
'ipb_user',
'deleted' =>
'MAX(ipb_deleted)',
'sitewide' =>
'MAX(ipb_sitewide)' ],
233 [
'ipb_user' => $uids ],
235 [
'GROUP BY' => [
'ipb_user' ] ]
237 $this->blockStatusByUid = [];
238 foreach (
$res as $row ) {
239 $this->blockStatusByUid[$row->ipb_user] = [
240 'deleted' => $row->deleted,
241 'sitewide' => $row->sitewide,
244 $this->mResult->seek( 0 );
248 $userName = $row->user_name;
269 foreach ( $ugms as $ugm ) {
280 $isBlocked = isset( $this->blockStatusByUid[$row->user_id] );
282 if ( $this->blockStatusByUid[$row->user_id][
'deleted'] == 1 ) {
283 $item =
"<span class=\"deleted\">$item</span>";
285 if ( $this->blockStatusByUid[$row->user_id][
'sitewide'] == 1 ) {
286 $blocked =
' ' . $this->
msg(
'listusers-blocked', $userName )->escaped();
289 $count = $this->
msg(
'activeusers-count' )->numParams( $row->recentedits )
290 ->params( $userName )->numParams( $this->RCMaxAge )->escaped();