99 $parms = explode(
'/', $par );
100 $symsForAll = [
'*',
'user' ];
102 if ( $parms[0] !=
'' &&
103 ( in_array( $par, $userGroupManager->
listAllGroups() ) || in_array( $par, $symsForAll ) )
105 $this->requestedGroup = $par;
106 $un = $request->getText(
'username' );
107 } elseif ( count( $parms ) == 2 ) {
108 $this->requestedGroup = $parms[0];
111 $this->requestedGroup = $request->getVal(
'group' );
112 $un = ( $par !=
'' ) ? $par : $request->getText(
'username' );
115 if ( in_array( $this->requestedGroup, $symsForAll ) ) {
116 $this->requestedGroup =
'';
118 $this->editsOnly = $request->getBool(
'editsOnly' );
119 $this->temporaryGroupsOnly = $request->getBool(
'temporaryGroupsOnly' );
120 $this->temporaryAccountsOnly = $request->getBool(
'temporaryAccountsOnly' );
121 $this->creationSort = $request->getBool(
'creationSort' );
123 $this->mDefaultDirection = $request->getBool(
'desc' )
127 $this->requestedUser =
'';
130 $username = Title::makeTitleSafe(
NS_USER, $un );
132 if ( $username !==
null ) {
133 $this->requestedUser = $username->getText();
139 parent::__construct();
140 $this->userGroupManager = $userGroupManager;
141 $this->hookRunner =
new HookRunner( $hookContainer );
142 $this->linkBatchFactory = $linkBatchFactory;
143 $this->userIdentityLookup = $userIdentityLookup;
145 $this->tempUserConfig = $tempUserConfig;
165 $conds[] = $this->hideUserUtils->getExpression( $dbr );
179 $deleted =
'MAX(' . $dbr->buildIntegerCast(
180 $this->hideUserUtils->getExpression( $dbr,
'user_id', HideUserUtils::HIDDEN_USERS )
184 if ( $this->requestedGroup !=
'' || $this->temporaryGroupsOnly ) {
185 $cond = $dbr->expr(
'ug_expiry',
'>=', $dbr->timestamp() );
186 if ( !$this->temporaryGroupsOnly ) {
187 $cond = $cond->or(
'ug_expiry',
'=',
null );
192 if ( $this->temporaryAccountsOnly && $this->tempUserConfig->isKnown() ) {
193 $conds[] = $this->tempUserConfig->getMatchCondition(
194 $dbr,
'user_name', IExpression::LIKE
198 if ( $this->requestedGroup !=
'' ) {
202 if ( $this->requestedUser !=
'' ) {
203 # Sorted either by account creation or name
204 if ( $this->creationSort ) {
205 $userIdentity = $this->userIdentityLookup->getUserIdentityByName( $this->requestedUser );
206 if ( $userIdentity && $userIdentity->isRegistered() ) {
207 $conds[] = $dbr->expr(
'user_id',
'>=', $userIdentity->getId() );
210 $conds[] = $dbr->expr(
'user_name',
'>=', $this->requestedUser );
214 if ( $this->editsOnly ) {
215 $conds[] = $dbr->expr(
'user_editcount',
'>', 0 );
218 $options[
'GROUP BY'] = $this->creationSort ?
'user_id' :
'user_name';
224 'block_with_target' => [
230 'user_name' => $this->creationSort ?
'MAX(user_name)' :
'user_name',
231 'user_id' => $this->creationSort ?
'user_id' :
'MAX(user_id)',
232 'edits' =>
'MAX(user_editcount)',
233 'creation' =>
'MIN(user_registration)',
234 'deleted' => $deleted,
235 'sitewide' =>
'MAX(bl_sitewide)'
237 'options' => $options,
239 'user_groups' => [
'LEFT JOIN',
'user_id=ug_user' ],
240 'block_with_target' => [
246 'block' => [
'JOIN',
'bl_target=bt_id' ]
251 $this->hookRunner->onSpecialListusersQueryInfo( $this, $query );
261 if ( $row->user_id == 0 ) { # T18487
265 $userName = $row->user_name;
267 $ulinks = Linker::userLink( $row->user_id, $userName );
268 $ulinks .= Linker::userToolLinksRedContribs(
282 if ( !$this->including && count( $ugms ) > 0 ) {
284 foreach ( $ugms as $ugm ) {
287 $groups = $lang->commaList( $list );
290 $item = $lang->specialList( $ulinks, $groups );
292 if ( $row->deleted ) {
293 $item =
"<span class=\"deleted\">$item</span>";
298 $count = $this->
msg(
'usereditcount' )->numParams( $row->edits )->escaped();
299 $edits = $this->
msg(
'word-separator' )->escaped() . $this->
msg(
'brackets', $count )->escaped();
303 # Some rows may be null
304 if ( !$this->including && $row->creation ) {
306 $d = $lang->userDate( $row->creation, $user );
307 $t = $lang->userTime( $row->creation, $user );
308 $created = $this->
msg(
'usercreated', $d, $t, $row->user_name )->escaped();
309 $created =
' ' . $this->
msg(
'parentheses' )->rawParams( $created )->escaped();
312 $blocked = $row->deleted !==
null && $row->sitewide ===
'1' ?
313 ' ' . $this->
msg(
'listusers-blocked', $userName )->escaped() :
316 $this->hookRunner->onSpecialListusersFormatRow( $item, $row );
318 return Html::rawElement(
'li', [],
"{$item}{$edits}{$created}{$blocked}" );
322 $batch = $this->linkBatchFactory->newLinkBatch();
324 # Give some pointers to make user links
325 foreach ( $this->mResult as $row ) {
327 $batch->addUser( $user );
328 $userIds[] = $user->getId();
332 $queryBuilder = $this->userGroupManager->newQueryBuilder( $this->
getDatabase() );
333 $groupRes = $queryBuilder->where( [
'ug_user' => $userIds ] )
334 ->caller( __METHOD__ )
338 foreach ( $groupRes as $row ) {
339 $ugm = $this->userGroupManager->newGroupMembershipFromRow( $row );
340 if ( !$ugm->isExpired() ) {
341 $cache[$row->ug_user][$row->ug_group] = $ugm;
342 $groups[$row->ug_group] =
true;
348 $this->hookRunner->onUsersPagerDoBatchLookups( $this->
getDatabase(), $userIds, $cache, $groups );
350 $this->userGroupCache = $cache;
353 foreach ( $groups as $group => $unused ) {
354 $groupPage = UserGroupMembership::getGroupPage( $group );
356 $batch->addObj( $groupPage );
361 $this->mResult->rewind();
368 $self = explode(
'/', $this->
getTitle()->getPrefixedDBkey(), 2 )[0];
370 $groupOptions = [ $this->
msg(
'group-all' )->text() =>
'' ];
371 foreach ( $this->getAllGroups() as $group => $groupText ) {
372 if ( array_key_exists( $groupText, $groupOptions ) ) {
373 LoggerFactory::getInstance(
'translation-problem' )->error(
374 'The group {group_one} has the same translation as {group_two} for {lang}. ' .
375 '{group_one} will not be displayed in group dropdown of the UsersPager.',
377 'group_one' => $group,
378 'group_two' => $groupOptions[$groupText],
384 $groupOptions[ $groupText ] = $group;
389 'class' => HTMLUserTextField::class,
390 'label' => $this->
msg(
'listusersfrom' )->text(),
391 'name' =>
'username',
395 'label' => $this->
msg(
'group' )->text(),
398 'class' => HTMLSelectField::class,
399 'options' => $groupOptions,
403 'label' => $this->
msg(
'listusers-editsonly' )->text(),
404 'name' =>
'editsOnly',
408 'temporaryGroupsOnly' => [
410 'label' => $this->
msg(
'listusers-temporarygroupsonly' )->text(),
411 'name' =>
'temporaryGroupsOnly',
412 'id' =>
'temporaryGroupsOnly',
418 if ( $this->tempUserConfig->isKnown() ) {
419 $formDescriptor = array_merge( $formDescriptor, [
420 'temporaryAccountsOnly' => [
422 'label' => $this->
msg(
'listusers-temporaryaccountsonly' )->text(),
423 'name' =>
'temporaryAccountsOnly',
424 'id' =>
'temporaryAccountsOnly',
425 'default' => $this->temporaryAccountsOnly
431 $formDescriptor = array_merge( $formDescriptor, [
434 'label' => $this->
msg(
'listusers-creationsort' )->text(),
435 'name' =>
'creationSort',
436 'id' =>
'creationSort',
437 'default' => $this->creationSort
441 'label' => $this->
msg(
'listusers-desc' )->text(),
444 'default' => $this->mDefaultDirection
446 'limithiddenfield' => [
447 'class' => HTMLHiddenField::class,
449 'default' => $this->mLimit
453 $beforeSubmitButtonHookOut =
'';
454 $this->hookRunner->onSpecialListusersHeaderForm( $this, $beforeSubmitButtonHookOut );
456 if ( $beforeSubmitButtonHookOut !==
'' ) {
457 $formDescriptor[
'beforeSubmitButtonHookOut' ] = [
458 'class' => HTMLInfoField::class,
460 'default' => $beforeSubmitButtonHookOut
464 $formDescriptor[
'submit' ] = [
465 'class' => HTMLSubmitField::class,
466 'buttonlabel-message' =>
'listusers-submit',
469 $beforeClosingFieldsetHookOut =
'';
470 $this->hookRunner->onSpecialListusersHeader( $this, $beforeClosingFieldsetHookOut );
472 if ( $beforeClosingFieldsetHookOut !==
'' ) {
473 $formDescriptor[
'beforeClosingFieldsetHookOut' ] = [
474 'class' => HTMLInfoField::class,
476 'default' => $beforeClosingFieldsetHookOut
480 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() );
483 ->setTitle( Title::newFromText(
$self ) )
484 ->setId(
'mw-listusers-form' )
485 ->setFormIdentifier(
'mw-listusers-form' )
486 ->suppressDefaultSubmit()
487 ->setWrapperLegendMsg(
'listusers' );
488 return $htmlForm->prepareForm()->getHTML(
true );