122 $parms = explode(
'/', $par );
123 $symsForAll = [
'*',
'user' ];
125 if ( $parms[0] !=
'' &&
126 ( in_array( $par, $userGroupManager->
listAllGroups() ) || in_array( $par, $symsForAll ) )
128 $this->requestedGroup = $par;
129 $un = $request->getText(
'username' );
130 } elseif ( count( $parms ) == 2 ) {
131 $this->requestedGroup = $parms[0];
134 $this->requestedGroup = $request->getVal(
'group' );
135 $un = ( $par !=
'' ) ? $par : $request->getText(
'username' );
138 if ( in_array( $this->requestedGroup, $symsForAll ) ) {
139 $this->requestedGroup =
'';
141 $this->editsOnly = $request->getBool(
'editsOnly' );
142 $this->temporaryGroupsOnly = $request->getBool(
'temporaryGroupsOnly' );
143 $this->creationSort = $request->getBool(
'creationSort' );
145 $this->mDefaultDirection = $request->getBool(
'desc' )
149 $this->requestedUser =
'';
152 $username = Title::makeTitleSafe(
NS_USER, $un );
154 if ( $username !==
null ) {
155 $this->requestedUser = $username->getText();
161 parent::__construct();
162 $this->userGroupManager = $userGroupManager;
163 $this->hookRunner =
new HookRunner( $hookContainer );
164 $this->linkBatchFactory = $linkBatchFactory;
165 $this->userIdentityLookup = $userIdentityLookup;
166 $this->blockTargetReadStage = $this->
getConfig()
188 $conds[] = $this->hideUserUtils->getExpression( $dbr );
202 $deleted =
'MAX(' . $dbr->buildIntegerCast(
203 $this->hideUserUtils->getExpression( $dbr,
'user_id', HideUserUtils::HIDDEN_USERS )
207 if ( $this->requestedGroup !=
'' || $this->temporaryGroupsOnly ) {
208 $cond = $dbr->expr(
'ug_expiry',
'>=', $dbr->timestamp() );
209 if ( !$this->temporaryGroupsOnly ) {
210 $cond = $cond->or(
'ug_expiry',
'=',
null );
215 if ( $this->requestedGroup !=
'' ) {
219 if ( $this->requestedUser !=
'' ) {
220 # Sorted either by account creation or name
221 if ( $this->creationSort ) {
222 $userIdentity = $this->userIdentityLookup->getUserIdentityByName( $this->requestedUser );
223 if ( $userIdentity && $userIdentity->isRegistered() ) {
224 $conds[] =
'user_id >= ' . $userIdentity->getId();
227 $conds[] = $dbr->expr(
'user_name',
'>=', $this->requestedUser );
231 if ( $this->editsOnly ) {
232 $conds[] =
'user_editcount > 0';
235 $options[
'GROUP BY'] = $this->creationSort ?
'user_id' :
'user_name';
239 'tables' => [
'user',
'user_groups',
'ipblocks' ],
241 'user_name' => $this->creationSort ?
'MAX(user_name)' :
'user_name',
242 'user_id' => $this->creationSort ?
'user_id' :
'MAX(user_id)',
243 'edits' =>
'MAX(user_editcount)',
244 'creation' =>
'MIN(user_registration)',
245 'deleted' => $deleted,
246 'sitewide' =>
'MAX(ipb_sitewide)'
248 'options' => $options,
250 'user_groups' => [
'LEFT JOIN',
'user_id=ug_user' ],
265 'block_with_target' => [
271 'user_name' => $this->creationSort ?
'MAX(user_name)' :
'user_name',
272 'user_id' => $this->creationSort ?
'user_id' :
'MAX(user_id)',
273 'edits' =>
'MAX(user_editcount)',
274 'creation' =>
'MIN(user_registration)',
275 'deleted' => $deleted,
276 'sitewide' =>
'MAX(bl_sitewide)'
278 'options' => $options,
280 'user_groups' => [
'LEFT JOIN',
'user_id=ug_user' ],
281 'block_with_target' => [
287 'block' => [
'JOIN',
'bl_target=bt_id' ]
293 $this->hookRunner->onSpecialListusersQueryInfo( $this, $query );
303 if ( $row->user_id == 0 ) { # T18487
307 $userName = $row->user_name;
309 $ulinks = Linker::userLink( $row->user_id, $userName );
310 $ulinks .= Linker::userToolLinksRedContribs(
324 if ( !$this->including && count( $ugms ) > 0 ) {
326 foreach ( $ugms as $ugm ) {
329 $groups = $lang->commaList( $list );
332 $item = $lang->specialList( $ulinks, $groups );
334 if ( $row->deleted ) {
335 $item =
"<span class=\"deleted\">$item</span>";
340 $count = $this->
msg(
'usereditcount' )->numParams( $row->edits )->escaped();
341 $edits = $this->
msg(
'word-separator' )->escaped() . $this->
msg(
'brackets', $count )->escaped();
345 # Some rows may be null
346 if ( !$this->including && $row->creation ) {
348 $d = $lang->userDate( $row->creation, $user );
349 $t = $lang->userTime( $row->creation, $user );
350 $created = $this->
msg(
'usercreated', $d, $t, $row->user_name )->escaped();
351 $created =
' ' . $this->
msg(
'parentheses' )->rawParams( $created )->escaped();
354 $blocked = $row->deleted !==
null && $row->sitewide ===
'1' ?
355 ' ' . $this->
msg(
'listusers-blocked', $userName )->escaped() :
358 $this->hookRunner->onSpecialListusersFormatRow( $item, $row );
360 return Html::rawElement(
'li', [],
"{$item}{$edits}{$created}{$blocked}" );
364 $batch = $this->linkBatchFactory->newLinkBatch();
366 # Give some pointers to make user links
367 foreach ( $this->mResult as $row ) {
368 $batch->add(
NS_USER, $row->user_name );
370 $userIds[] = (int)$row->user_id;
374 $queryBuilder = $this->userGroupManager->newQueryBuilder( $this->
getDatabase() );
375 $groupRes = $queryBuilder->where( [
'ug_user' => $userIds ] )
376 ->caller( __METHOD__ )
380 foreach ( $groupRes as $row ) {
381 $ugm = $this->userGroupManager->newGroupMembershipFromRow( $row );
382 if ( !$ugm->isExpired() ) {
383 $cache[$row->ug_user][$row->ug_group] = $ugm;
384 $groups[$row->ug_group] =
true;
390 $this->hookRunner->onUsersPagerDoBatchLookups( $this->
getDatabase(), $userIds, $cache, $groups );
392 $this->userGroupCache = $cache;
395 foreach ( $groups as $group => $unused ) {
396 $groupPage = UserGroupMembership::getGroupPage( $group );
398 $batch->addObj( $groupPage );
403 $this->mResult->rewind();
410 $self = explode(
'/', $this->
getTitle()->getPrefixedDBkey(), 2 )[0];
412 $groupOptions = [ $this->
msg(
'group-all' )->text() =>
'' ];
413 foreach ( $this->getAllGroups() as $group => $groupText ) {
414 if ( array_key_exists( $groupText, $groupOptions ) ) {
415 LoggerFactory::getInstance(
'error' )->error(
416 'The group {group_one} has the same translation as {group_two} for {lang}. ' .
417 '{group_one} will not be displayed in group dropdown of the UsersPager.',
419 'group_one' => $group,
420 'group_two' => $groupOptions[$groupText],
426 $groupOptions[ $groupText ] = $group;
431 'class' => HTMLUserTextField::class,
432 'label' => $this->
msg(
'listusersfrom' )->text(),
433 'name' =>
'username',
437 'label' => $this->
msg(
'group' )->text(),
440 'class' => HTMLSelectField::class,
441 'options' => $groupOptions,
445 'label' => $this->
msg(
'listusers-editsonly' )->text(),
446 'name' =>
'editsOnly',
450 'temporaryGroupsOnly' => [
452 'label' => $this->
msg(
'listusers-temporarygroupsonly' )->text(),
453 'name' =>
'temporaryGroupsOnly',
454 'id' =>
'temporaryGroupsOnly',
459 'label' => $this->
msg(
'listusers-creationsort' )->text(),
460 'name' =>
'creationSort',
461 'id' =>
'creationSort',
466 'label' => $this->
msg(
'listusers-desc' )->text(),
471 'limithiddenfield' => [
472 'class' => HTMLHiddenField::class,
478 $beforeSubmitButtonHookOut =
'';
479 $this->hookRunner->onSpecialListusersHeaderForm( $this, $beforeSubmitButtonHookOut );
481 if ( $beforeSubmitButtonHookOut !==
'' ) {
482 $formDescriptor[
'beforeSubmitButtonHookOut' ] = [
483 'class' => HTMLInfoField::class,
485 'default' => $beforeSubmitButtonHookOut
489 $formDescriptor[
'submit' ] = [
490 'class' => HTMLSubmitField::class,
491 'buttonlabel-message' =>
'listusers-submit',
494 $beforeClosingFieldsetHookOut =
'';
495 $this->hookRunner->onSpecialListusersHeader( $this, $beforeClosingFieldsetHookOut );
497 if ( $beforeClosingFieldsetHookOut !==
'' ) {
498 $formDescriptor[
'beforeClosingFieldsetHookOut' ] = [
499 'class' => HTMLInfoField::class,
501 'default' => $beforeClosingFieldsetHookOut
505 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() );
508 ->setTitle( Title::newFromText(
$self ) )
509 ->setId(
'mw-listusers-form' )
510 ->setFormIdentifier(
'mw-listusers-form' )
511 ->suppressDefaultSubmit()
512 ->setWrapperLegendMsg(
'listusers' );
513 return $htmlForm->prepareForm()->getHTML(
true );