119 $parms = explode(
'/', $par );
120 $symsForAll = [
'*',
'user' ];
122 if ( $parms[0] !=
'' &&
123 ( in_array( $par, $userGroupManager->
listAllGroups() ) || in_array( $par, $symsForAll ) )
125 $this->requestedGroup = $par;
126 $un = $request->getText(
'username' );
127 } elseif ( count( $parms ) == 2 ) {
128 $this->requestedGroup = $parms[0];
131 $this->requestedGroup = $request->getVal(
'group' );
132 $un = ( $par !=
'' ) ? $par : $request->getText(
'username' );
135 if ( in_array( $this->requestedGroup, $symsForAll ) ) {
136 $this->requestedGroup =
'';
138 $this->editsOnly = $request->getBool(
'editsOnly' );
139 $this->temporaryGroupsOnly = $request->getBool(
'temporaryGroupsOnly' );
140 $this->creationSort = $request->getBool(
'creationSort' );
142 $this->mDefaultDirection = $request->getBool(
'desc' )
146 $this->requestedUser =
'';
149 $username = Title::makeTitleSafe(
NS_USER, $un );
151 if ( $username !==
null ) {
152 $this->requestedUser = $username->getText();
158 parent::__construct();
159 $this->userGroupManager = $userGroupManager;
160 $this->hookRunner =
new HookRunner( $hookContainer );
161 $this->linkBatchFactory = $linkBatchFactory;
162 $this->userIdentityLookup = $userIdentityLookup;
183 $conds[] = $this->hideUserUtils->getExpression( $dbr );
197 $deleted =
'MAX(' . $dbr->buildIntegerCast(
198 $this->hideUserUtils->getExpression( $dbr,
'user_id', HideUserUtils::HIDDEN_USERS )
202 if ( $this->requestedGroup !=
'' || $this->temporaryGroupsOnly ) {
203 $cond = $dbr->expr(
'ug_expiry',
'>=', $dbr->timestamp() );
204 if ( !$this->temporaryGroupsOnly ) {
205 $cond = $cond->or(
'ug_expiry',
'=',
null );
210 if ( $this->requestedGroup !=
'' ) {
214 if ( $this->requestedUser !=
'' ) {
215 # Sorted either by account creation or name
216 if ( $this->creationSort ) {
217 $userIdentity = $this->userIdentityLookup->getUserIdentityByName( $this->requestedUser );
218 if ( $userIdentity && $userIdentity->isRegistered() ) {
219 $conds[] = $dbr->expr(
'user_id',
'>=', $userIdentity->getId() );
222 $conds[] = $dbr->expr(
'user_name',
'>=', $this->requestedUser );
226 if ( $this->editsOnly ) {
227 $conds[] = $dbr->expr(
'user_editcount',
'>', 0 );
230 $options[
'GROUP BY'] = $this->creationSort ?
'user_id' :
'user_name';
236 'block_with_target' => [
242 'user_name' => $this->creationSort ?
'MAX(user_name)' :
'user_name',
243 'user_id' => $this->creationSort ?
'user_id' :
'MAX(user_id)',
244 'edits' =>
'MAX(user_editcount)',
245 'creation' =>
'MIN(user_registration)',
246 'deleted' => $deleted,
247 'sitewide' =>
'MAX(bl_sitewide)'
249 'options' => $options,
251 'user_groups' => [
'LEFT JOIN',
'user_id=ug_user' ],
252 'block_with_target' => [
258 'block' => [
'JOIN',
'bl_target=bt_id' ]
263 $this->hookRunner->onSpecialListusersQueryInfo( $this, $query );
273 if ( $row->user_id == 0 ) { # T18487
277 $userName = $row->user_name;
279 $ulinks = Linker::userLink( $row->user_id, $userName );
280 $ulinks .= Linker::userToolLinksRedContribs(
294 if ( !$this->including && count( $ugms ) > 0 ) {
296 foreach ( $ugms as $ugm ) {
299 $groups = $lang->commaList( $list );
302 $item = $lang->specialList( $ulinks, $groups );
304 if ( $row->deleted ) {
305 $item =
"<span class=\"deleted\">$item</span>";
310 $count = $this->
msg(
'usereditcount' )->numParams( $row->edits )->escaped();
311 $edits = $this->
msg(
'word-separator' )->escaped() . $this->
msg(
'brackets', $count )->escaped();
315 # Some rows may be null
316 if ( !$this->including && $row->creation ) {
318 $d = $lang->userDate( $row->creation, $user );
319 $t = $lang->userTime( $row->creation, $user );
320 $created = $this->
msg(
'usercreated', $d, $t, $row->user_name )->escaped();
321 $created =
' ' . $this->
msg(
'parentheses' )->rawParams( $created )->escaped();
324 $blocked = $row->deleted !==
null && $row->sitewide ===
'1' ?
325 ' ' . $this->
msg(
'listusers-blocked', $userName )->escaped() :
328 $this->hookRunner->onSpecialListusersFormatRow( $item, $row );
330 return Html::rawElement(
'li', [],
"{$item}{$edits}{$created}{$blocked}" );
334 $batch = $this->linkBatchFactory->newLinkBatch();
336 # Give some pointers to make user links
337 foreach ( $this->mResult as $row ) {
338 $batch->add(
NS_USER, $row->user_name );
340 $userIds[] = (int)$row->user_id;
344 $queryBuilder = $this->userGroupManager->newQueryBuilder( $this->
getDatabase() );
345 $groupRes = $queryBuilder->where( [
'ug_user' => $userIds ] )
346 ->caller( __METHOD__ )
350 foreach ( $groupRes as $row ) {
351 $ugm = $this->userGroupManager->newGroupMembershipFromRow( $row );
352 if ( !$ugm->isExpired() ) {
353 $cache[$row->ug_user][$row->ug_group] = $ugm;
354 $groups[$row->ug_group] =
true;
360 $this->hookRunner->onUsersPagerDoBatchLookups( $this->
getDatabase(), $userIds, $cache, $groups );
362 $this->userGroupCache = $cache;
365 foreach ( $groups as $group => $unused ) {
366 $groupPage = UserGroupMembership::getGroupPage( $group );
368 $batch->addObj( $groupPage );
373 $this->mResult->rewind();
380 $self = explode(
'/', $this->
getTitle()->getPrefixedDBkey(), 2 )[0];
382 $groupOptions = [ $this->
msg(
'group-all' )->text() =>
'' ];
383 foreach ( $this->getAllGroups() as $group => $groupText ) {
384 if ( array_key_exists( $groupText, $groupOptions ) ) {
385 LoggerFactory::getInstance(
'error' )->error(
386 'The group {group_one} has the same translation as {group_two} for {lang}. ' .
387 '{group_one} will not be displayed in group dropdown of the UsersPager.',
389 'group_one' => $group,
390 'group_two' => $groupOptions[$groupText],
396 $groupOptions[ $groupText ] = $group;
401 'class' => HTMLUserTextField::class,
402 'label' => $this->
msg(
'listusersfrom' )->text(),
403 'name' =>
'username',
407 'label' => $this->
msg(
'group' )->text(),
410 'class' => HTMLSelectField::class,
411 'options' => $groupOptions,
415 'label' => $this->
msg(
'listusers-editsonly' )->text(),
416 'name' =>
'editsOnly',
420 'temporaryGroupsOnly' => [
422 'label' => $this->
msg(
'listusers-temporarygroupsonly' )->text(),
423 'name' =>
'temporaryGroupsOnly',
424 'id' =>
'temporaryGroupsOnly',
429 'label' => $this->
msg(
'listusers-creationsort' )->text(),
430 'name' =>
'creationSort',
431 'id' =>
'creationSort',
436 'label' => $this->
msg(
'listusers-desc' )->text(),
441 'limithiddenfield' => [
442 'class' => HTMLHiddenField::class,
448 $beforeSubmitButtonHookOut =
'';
449 $this->hookRunner->onSpecialListusersHeaderForm( $this, $beforeSubmitButtonHookOut );
451 if ( $beforeSubmitButtonHookOut !==
'' ) {
452 $formDescriptor[
'beforeSubmitButtonHookOut' ] = [
453 'class' => HTMLInfoField::class,
455 'default' => $beforeSubmitButtonHookOut
459 $formDescriptor[
'submit' ] = [
460 'class' => HTMLSubmitField::class,
461 'buttonlabel-message' =>
'listusers-submit',
464 $beforeClosingFieldsetHookOut =
'';
465 $this->hookRunner->onSpecialListusersHeader( $this, $beforeClosingFieldsetHookOut );
467 if ( $beforeClosingFieldsetHookOut !==
'' ) {
468 $formDescriptor[
'beforeClosingFieldsetHookOut' ] = [
469 'class' => HTMLInfoField::class,
471 'default' => $beforeClosingFieldsetHookOut
475 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() );
478 ->setTitle( Title::newFromText(
$self ) )
479 ->setId(
'mw-listusers-form' )
480 ->setFormIdentifier(
'mw-listusers-form' )
481 ->suppressDefaultSubmit()
482 ->setWrapperLegendMsg(
'listusers' );
483 return $htmlForm->prepareForm()->getHTML(
true );