61 $this->RCMaxAge = $this->
getConfig()->get(
'ActiveUserDays' );
62 $this->requestedUser =
'';
67 if ( !is_null( $username ) ) {
68 $this->requestedUser = $username->getText();
76 $this->excludegroups[] =
'bot';
79 $this->excludegroups[] =
'sysop';
90 $activeUserSeconds = $this->
getConfig()->get(
'ActiveUserDays' ) * 86400;
91 $timestamp =
$dbr->timestamp(
wfTimestamp( TS_UNIX ) - $activeUserSeconds );
95 $tables = [
'querycachetwo',
'user',
'actor' ];
96 $fields = [
'qcc_title',
'user_id',
'actor_id' ];
98 'user' => [
'JOIN',
'user_name = qcc_title' ],
99 'actor' => [
'JOIN',
'actor_user = user_id' ],
102 'qcc_type' =>
'activeusers',
106 if ( $data !==
null ) {
107 $options[
'ORDER BY'] =
'qcc_title ' . $data[
'order'];
108 $options[
'LIMIT'] = $data[
'limit'];
109 $conds = array_merge( $conds, $data[
'conds'] );
111 if ( $this->requestedUser !=
'' ) {
112 $conds[] =
'qcc_title >= ' .
$dbr->addQuotes( $this->requestedUser );
114 if ( $this->groups !== [] ) {
115 $tables[
'ug1'] =
'user_groups';
116 $jconds[
'ug1'] = [
'JOIN',
'ug1.ug_user = user_id' ];
118 $conds[] =
'ug1.ug_expiry IS NULL OR ug1.ug_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() );
120 if ( $this->excludegroups !== [] ) {
121 $tables[
'ug2'] =
'user_groups';
122 $jconds[
'ug2'] = [
'LEFT JOIN', [
123 'ug2.ug_user = user_id',
125 'ug2.ug_expiry IS NULL OR ug2.ug_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() ),
127 $conds[
'ug2.ug_user'] =
null;
129 if ( !MediaWikiServices::getInstance()
130 ->getPermissionManager()
131 ->userHasRight( $this->
getUser(),
'hideuser' )
133 $conds[] =
'NOT EXISTS (' .
$dbr->selectSQLText(
134 'ipblocks',
'1', [
'ipb_user=user_id',
'ipb_deleted' => 1 ]
137 $subquery =
$dbr->buildSelectSubquery( $tables, $fields, $conds, $fname, $options, $jconds );
140 $tables = [
'qcc_users' => $subquery,
'recentchanges' ];
141 $jconds = [
'recentchanges' => [
'LEFT JOIN', [
142 'rc_actor = actor_id',
145 'rc_log_type IS NULL OR rc_log_type != ' .
$dbr->addQuotes(
'newusers' ),
146 'rc_timestamp >= ' .
$dbr->addQuotes( $timestamp ),
154 'user_name' =>
'qcc_title',
155 'user_id' =>
'user_id',
156 'recentedits' =>
'COUNT(rc_id)'
158 'options' => [
'GROUP BY' => [
'qcc_title',
'user_id' ] ],
160 'join_conds' => $jconds,
167 $sortColumns = array_merge( [ $this->mIndexField ], $this->mExtraSortFields );
168 if ( $order === self::QUERY_ASCENDING ) {
170 $orderBy = $sortColumns;
171 $operator = $this->mIncludeOffset ?
'>=' :
'>';
175 foreach ( $sortColumns as $col ) {
176 $orderBy[] = $col .
' DESC';
178 $operator = $this->mIncludeOffset ?
'<=' :
'<';
181 'limit' => intval( $limit ),
184 $offset !=
'' ? [ $this->mIndexField . $operator . $this->mDb->addQuotes( $offset ) ] : [],
187 $tables = $info[
'tables'];
188 $fields = $info[
'fields'];
189 $conds = $info[
'conds'];
190 $options = $info[
'options'];
191 $join_conds = $info[
'join_conds'];
192 $options[
'ORDER BY'] = $orderBy;
193 return [ $tables, $fields, $conds, $fname, $options, $join_conds ];
197 parent::doBatchLookups();
200 foreach ( $this->mResult as $row ) {
201 $uids[] = $row->user_id;
209 [
'ipb_user',
'MAX(ipb_deleted) AS deleted, MAX(ipb_sitewide) AS sitewide' ],
210 [
'ipb_user' => $uids ],
212 [
'GROUP BY' => [
'ipb_user' ] ]
214 $this->blockStatusByUid = [];
215 foreach (
$res as $row ) {
216 $this->blockStatusByUid[$row->ipb_user] = [
217 'deleted' => $row->deleted,
218 'sitewide' => $row->sitewide,
221 $this->mResult->seek( 0 );
225 $userName = $row->user_name;
246 foreach ( $ugms as $ugm ) {
257 $isBlocked = isset( $this->blockStatusByUid[$row->user_id] );
259 if ( $this->blockStatusByUid[$row->user_id][
'deleted'] == 1 ) {
260 $item =
"<span class=\"deleted\">$item</span>";
262 if ( $this->blockStatusByUid[$row->user_id][
'sitewide'] == 1 ) {
263 $blocked =
' ' . $this->
msg(
'listusers-blocked', $userName )->escaped();
266 $count = $this->
msg(
'activeusers-count' )->numParams( $row->recentedits )
267 ->params( $userName )->numParams( $this->RCMaxAge )->escaped();
269 return Html::rawElement(
'li', [],
"{$item} [{$count}]{$blocked}" );