126 $parms = explode(
'/', $par );
127 $symsForAll = [
'*',
'user' ];
129 if ( $parms[0] !=
'' &&
130 ( in_array( $par, $userGroupManager->
listAllGroups() ) || in_array( $par, $symsForAll ) )
132 $this->requestedGroup = $par;
133 $un = $request->getText(
'username' );
134 } elseif ( count( $parms ) == 2 ) {
135 $this->requestedGroup = $parms[0];
138 $this->requestedGroup = $request->getVal(
'group' );
139 $un = ( $par !=
'' ) ? $par : $request->getText(
'username' );
142 if ( in_array( $this->requestedGroup, $symsForAll ) ) {
143 $this->requestedGroup =
'';
145 $this->editsOnly = $request->getBool(
'editsOnly' );
146 $this->temporaryGroupsOnly = $request->getBool(
'temporaryGroupsOnly' );
147 $this->temporaryAccountsOnly = $request->getBool(
'temporaryAccountsOnly' );
148 $this->creationSort = $request->getBool(
'creationSort' );
150 $this->mDefaultDirection = $request->getBool(
'desc' )
154 $this->requestedUser =
'';
157 $username = Title::makeTitleSafe(
NS_USER, $un );
159 if ( $username !==
null ) {
160 $this->requestedUser = $username->getText();
166 parent::__construct();
167 $this->userGroupManager = $userGroupManager;
168 $this->hookRunner =
new HookRunner( $hookContainer );
169 $this->linkBatchFactory = $linkBatchFactory;
170 $this->userIdentityLookup = $userIdentityLookup;
192 $conds[] = $this->hideUserUtils->getExpression( $dbr );
206 $deleted =
'MAX(' . $dbr->buildIntegerCast(
207 $this->hideUserUtils->getExpression( $dbr,
'user_id', HideUserUtils::HIDDEN_USERS )
211 if ( $this->requestedGroup !=
'' || $this->temporaryGroupsOnly ) {
212 $cond = $dbr->expr(
'ug_expiry',
'>=', $dbr->timestamp() );
213 if ( !$this->temporaryGroupsOnly ) {
214 $cond = $cond->or(
'ug_expiry',
'=',
null );
219 if ( $this->temporaryAccountsOnly && $this->tempUserConfig->isKnown() ) {
220 $conds[] = $this->tempUserConfig->getMatchCondition(
221 $dbr,
'user_name', IExpression::LIKE
225 if ( $this->requestedGroup !=
'' ) {
229 if ( $this->requestedUser !=
'' ) {
230 # Sorted either by account creation or name
231 if ( $this->creationSort ) {
232 $userIdentity = $this->userIdentityLookup->getUserIdentityByName( $this->requestedUser );
233 if ( $userIdentity && $userIdentity->isRegistered() ) {
234 $conds[] = $dbr->expr(
'user_id',
'>=', $userIdentity->getId() );
237 $conds[] = $dbr->expr(
'user_name',
'>=', $this->requestedUser );
241 if ( $this->editsOnly ) {
242 $conds[] = $dbr->expr(
'user_editcount',
'>', 0 );
245 $options[
'GROUP BY'] = $this->creationSort ?
'user_id' :
'user_name';
251 'block_with_target' => [
257 'user_name' => $this->creationSort ?
'MAX(user_name)' :
'user_name',
258 'user_id' => $this->creationSort ?
'user_id' :
'MAX(user_id)',
259 'edits' =>
'MAX(user_editcount)',
260 'creation' =>
'MIN(user_registration)',
261 'deleted' => $deleted,
262 'sitewide' =>
'MAX(bl_sitewide)'
264 'options' => $options,
266 'user_groups' => [
'LEFT JOIN',
'user_id=ug_user' ],
267 'block_with_target' => [
273 'block' => [
'JOIN',
'bl_target=bt_id' ]
278 $this->hookRunner->onSpecialListusersQueryInfo( $this, $query );
288 if ( $row->user_id == 0 ) { # T18487
292 $userName = $row->user_name;
294 $ulinks = Linker::userLink( $row->user_id, $userName );
295 $ulinks .= Linker::userToolLinksRedContribs(
309 if ( !$this->including && count( $ugms ) > 0 ) {
311 foreach ( $ugms as $ugm ) {
314 $groups = $lang->commaList( $list );
317 $item = $lang->specialList( $ulinks, $groups );
319 if ( $row->deleted ) {
320 $item =
"<span class=\"deleted\">$item</span>";
325 $count = $this->
msg(
'usereditcount' )->numParams( $row->edits )->escaped();
326 $edits = $this->
msg(
'word-separator' )->escaped() . $this->
msg(
'brackets', $count )->escaped();
330 # Some rows may be null
331 if ( !$this->including && $row->creation ) {
333 $d = $lang->userDate( $row->creation, $user );
334 $t = $lang->userTime( $row->creation, $user );
335 $created = $this->
msg(
'usercreated', $d, $t, $row->user_name )->escaped();
336 $created =
' ' . $this->
msg(
'parentheses' )->rawParams( $created )->escaped();
339 $blocked = $row->deleted !==
null && $row->sitewide ===
'1' ?
340 ' ' . $this->
msg(
'listusers-blocked', $userName )->escaped() :
343 $this->hookRunner->onSpecialListusersFormatRow( $item, $row );
345 return Html::rawElement(
'li', [],
"{$item}{$edits}{$created}{$blocked}" );
349 $batch = $this->linkBatchFactory->newLinkBatch();
351 # Give some pointers to make user links
352 foreach ( $this->mResult as $row ) {
353 $batch->add(
NS_USER, $row->user_name );
355 $userIds[] = (int)$row->user_id;
359 $queryBuilder = $this->userGroupManager->newQueryBuilder( $this->
getDatabase() );
360 $groupRes = $queryBuilder->where( [
'ug_user' => $userIds ] )
361 ->caller( __METHOD__ )
365 foreach ( $groupRes as $row ) {
366 $ugm = $this->userGroupManager->newGroupMembershipFromRow( $row );
367 if ( !$ugm->isExpired() ) {
368 $cache[$row->ug_user][$row->ug_group] = $ugm;
369 $groups[$row->ug_group] =
true;
375 $this->hookRunner->onUsersPagerDoBatchLookups( $this->
getDatabase(), $userIds, $cache, $groups );
377 $this->userGroupCache = $cache;
380 foreach ( $groups as $group => $unused ) {
381 $groupPage = UserGroupMembership::getGroupPage( $group );
383 $batch->addObj( $groupPage );
388 $this->mResult->rewind();
395 $self = explode(
'/', $this->
getTitle()->getPrefixedDBkey(), 2 )[0];
397 $groupOptions = [ $this->
msg(
'group-all' )->text() =>
'' ];
398 foreach ( $this->getAllGroups() as $group => $groupText ) {
399 if ( array_key_exists( $groupText, $groupOptions ) ) {
400 LoggerFactory::getInstance(
'translation-problem' )->error(
401 'The group {group_one} has the same translation as {group_two} for {lang}. ' .
402 '{group_one} will not be displayed in group dropdown of the UsersPager.',
404 'group_one' => $group,
405 'group_two' => $groupOptions[$groupText],
411 $groupOptions[ $groupText ] = $group;
416 'class' => HTMLUserTextField::class,
417 'label' => $this->
msg(
'listusersfrom' )->text(),
418 'name' =>
'username',
422 'label' => $this->
msg(
'group' )->text(),
425 'class' => HTMLSelectField::class,
426 'options' => $groupOptions,
430 'label' => $this->
msg(
'listusers-editsonly' )->text(),
431 'name' =>
'editsOnly',
435 'temporaryGroupsOnly' => [
437 'label' => $this->
msg(
'listusers-temporarygroupsonly' )->text(),
438 'name' =>
'temporaryGroupsOnly',
439 'id' =>
'temporaryGroupsOnly',
445 if ( $this->tempUserConfig->isKnown() ) {
446 $formDescriptor = array_merge( $formDescriptor, [
447 'temporaryAccountsOnly' => [
449 'label' => $this->
msg(
'listusers-temporaryaccountsonly' )->text(),
450 'name' =>
'temporaryAccountsOnly',
451 'id' =>
'temporaryAccountsOnly',
452 'default' => $this->temporaryAccountsOnly
458 $formDescriptor = array_merge( $formDescriptor, [
461 'label' => $this->
msg(
'listusers-creationsort' )->text(),
462 'name' =>
'creationSort',
463 'id' =>
'creationSort',
464 'default' => $this->creationSort
468 'label' => $this->
msg(
'listusers-desc' )->text(),
471 'default' => $this->mDefaultDirection
473 'limithiddenfield' => [
474 'class' => HTMLHiddenField::class,
476 'default' => $this->mLimit
480 $beforeSubmitButtonHookOut =
'';
481 $this->hookRunner->onSpecialListusersHeaderForm( $this, $beforeSubmitButtonHookOut );
483 if ( $beforeSubmitButtonHookOut !==
'' ) {
484 $formDescriptor[
'beforeSubmitButtonHookOut' ] = [
485 'class' => HTMLInfoField::class,
487 'default' => $beforeSubmitButtonHookOut
491 $formDescriptor[
'submit' ] = [
492 'class' => HTMLSubmitField::class,
493 'buttonlabel-message' =>
'listusers-submit',
496 $beforeClosingFieldsetHookOut =
'';
497 $this->hookRunner->onSpecialListusersHeader( $this, $beforeClosingFieldsetHookOut );
499 if ( $beforeClosingFieldsetHookOut !==
'' ) {
500 $formDescriptor[
'beforeClosingFieldsetHookOut' ] = [
501 'class' => HTMLInfoField::class,
503 'default' => $beforeClosingFieldsetHookOut
507 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() );
510 ->setTitle( Title::newFromText(
$self ) )
511 ->setId(
'mw-listusers-form' )
512 ->setFormIdentifier(
'mw-listusers-form' )
513 ->suppressDefaultSubmit()
514 ->setWrapperLegendMsg(
'listusers' );
515 return $htmlForm->prepareForm()->getHTML(
true );