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->creationSort = $request->getBool(
'creationSort' );
122 $this->mDefaultDirection = $request->getBool(
'desc' )
126 $this->requestedUser =
'';
129 $username = Title::makeTitleSafe(
NS_USER, $un );
131 if ( $username !==
null ) {
132 $this->requestedUser = $username->getText();
138 parent::__construct();
139 $this->userGroupManager = $userGroupManager;
140 $this->hookRunner =
new HookRunner( $hookContainer );
141 $this->linkBatchFactory = $linkBatchFactory;
160 $conds[] =
'ipb_deleted IS NULL OR ipb_deleted = 0';
165 if ( $this->requestedGroup !=
'' || $this->temporaryGroupsOnly ) {
166 $conds[] =
'ug_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() ) .
167 ( !$this->temporaryGroupsOnly ?
' OR ug_expiry IS NULL' :
'' );
170 if ( $this->requestedGroup !=
'' ) {
171 $conds[
'ug_group'] = $this->requestedGroup;
174 if ( $this->requestedUser !=
'' ) {
175 # Sorted either by account creation or name
176 if ( $this->creationSort ) {
177 $conds[] =
'user_id >= ' . intval(
User::idFromName( $this->requestedUser ) );
179 $conds[] =
'user_name >= ' .
$dbr->addQuotes( $this->requestedUser );
183 if ( $this->editsOnly ) {
184 $conds[] =
'user_editcount > 0';
187 $options[
'GROUP BY'] = $this->creationSort ?
'user_id' :
'user_name';
190 'tables' => [
'user',
'user_groups',
'ipblocks' ],
192 'user_name' => $this->creationSort ?
'MAX(user_name)' :
'user_name',
193 'user_id' => $this->creationSort ?
'user_id' :
'MAX(user_id)',
194 'edits' =>
'MAX(user_editcount)',
195 'creation' =>
'MIN(user_registration)',
196 'ipb_deleted' =>
'MAX(ipb_deleted)',
197 'ipb_sitewide' =>
'MAX(ipb_sitewide)'
199 'options' => $options,
201 'user_groups' => [
'LEFT JOIN',
'user_id=ug_user' ],
212 $this->hookRunner->onSpecialListusersQueryInfo( $this, $query );
222 if ( $row->user_id == 0 ) { # T18487
226 $userName = $row->user_name;
243 if ( !$this->including && count( $ugms ) > 0 ) {
245 foreach ( $ugms as $ugm ) {
248 $groups =
$lang->commaList( $list );
251 $item =
$lang->specialList( $ulinks, $groups );
253 if ( $row->ipb_deleted ) {
254 $item =
"<span class=\"deleted\">$item</span>";
258 if ( !$this->including && $this->
getConfig()->
get( MainConfigNames::Edititis ) ) {
259 $count = $this->
msg(
'usereditcount' )->numParams( $row->edits )->escaped();
260 $edits = $this->
msg(
'word-separator' )->escaped() . $this->
msg(
'brackets', $count )->escaped();
264 # Some rows may be null
265 if ( !$this->including && $row->creation ) {
267 $d =
$lang->userDate( $row->creation, $user );
268 $t =
$lang->userTime( $row->creation, $user );
269 $created = $this->
msg(
'usercreated', $d,
$t, $row->user_name )->escaped();
270 $created =
' ' . $this->
msg(
'parentheses' )->rawParams( $created )->escaped();
273 $blocked = $row->ipb_deleted !==
null && $row->ipb_sitewide ===
'1' ?
274 ' ' . $this->
msg(
'listusers-blocked', $userName )->escaped() :
277 $this->hookRunner->onSpecialListusersFormatRow( $item, $row );
279 return Html::rawElement(
'li', [],
"{$item}{$edits}{$created}{$blocked}" );
283 $batch = $this->linkBatchFactory->newLinkBatch();
285 # Give some pointers to make user links
286 foreach ( $this->mResult as $row ) {
287 $batch->add(
NS_USER, $row->user_name );
289 $userIds[] = $row->user_id;
294 $groupsQueryInfo = $this->userGroupManager->getQueryInfo();
295 $groupRes =
$dbr->select(
296 $groupsQueryInfo[
'tables'],
297 $groupsQueryInfo[
'fields'],
298 [
'ug_user' => $userIds ],
300 $groupsQueryInfo[
'joins']
304 foreach ( $groupRes as $row ) {
305 $ugm = $this->userGroupManager->newGroupMembershipFromRow( $row );
306 if ( !$ugm->isExpired() ) {
307 $cache[$row->ug_user][$row->ug_group] = $ugm;
308 $groups[$row->ug_group] =
true;
314 $this->hookRunner->onUsersPagerDoBatchLookups(
$dbr, $userIds,
$cache, $groups );
316 $this->userGroupCache =
$cache;
319 foreach ( $groups as $group => $unused ) {
320 $groupPage = UserGroupMembership::getGroupPage( $group );
322 $batch->addObj( $groupPage );
327 $this->mResult->rewind();
334 $self = explode(
'/', $this->
getTitle()->getPrefixedDBkey(), 2 )[0];
336 $groupOptions = [ $this->
msg(
'group-all' )->text() =>
'' ];
337 foreach ( $this->getAllGroups() as $group => $groupText ) {
338 $groupOptions[ $groupText ] = $group;
343 'class' => HTMLUserTextField::class,
344 'label' => $this->
msg(
'listusersfrom' )->text(),
345 'name' =>
'username',
346 'default' => $this->requestedUser,
349 'label' => $this->
msg(
'group' )->text(),
351 'default' => $this->requestedGroup,
352 'class' => HTMLSelectField::class,
353 'options' => $groupOptions,
357 'label' => $this->
msg(
'listusers-editsonly' )->text(),
358 'name' =>
'editsOnly',
360 'default' => $this->editsOnly
362 'temporaryGroupsOnly' => [
364 'label' => $this->
msg(
'listusers-temporarygroupsonly' )->text(),
365 'name' =>
'temporaryGroupsOnly',
366 'id' =>
'temporaryGroupsOnly',
367 'default' => $this->temporaryGroupsOnly
371 'label' => $this->
msg(
'listusers-creationsort' )->text(),
372 'name' =>
'creationSort',
373 'id' =>
'creationSort',
374 'default' => $this->creationSort
378 'label' => $this->
msg(
'listusers-desc' )->text(),
381 'default' => $this->mDefaultDirection
383 'limithiddenfield' => [
384 'class' => HTMLHiddenField::class,
386 'default' => $this->mLimit
390 $beforeSubmitButtonHookOut =
'';
391 $this->hookRunner->onSpecialListusersHeaderForm( $this, $beforeSubmitButtonHookOut );
393 if ( $beforeSubmitButtonHookOut !==
'' ) {
394 $formDescriptor[
'beforeSubmitButtonHookOut' ] = [
395 'class' => HTMLInfoField::class,
397 'default' => $beforeSubmitButtonHookOut
401 $formDescriptor[
'submit' ] = [
402 'class' => HTMLSubmitField::class,
403 'buttonlabel-message' =>
'listusers-submit',
406 $beforeClosingFieldsetHookOut =
'';
407 $this->hookRunner->onSpecialListusersHeader( $this, $beforeClosingFieldsetHookOut );
409 if ( $beforeClosingFieldsetHookOut !==
'' ) {
410 $formDescriptor[
'beforeClosingFieldsetHookOut' ] = [
411 'class' => HTMLInfoField::class,
413 'default' => $beforeClosingFieldsetHookOut
417 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() );
420 ->setTitle( Title::newFromText(
$self ) )
421 ->setId(
'mw-listusers-form' )
422 ->setFormIdentifier(
'mw-listusers-form' )
423 ->suppressDefaultSubmit()
424 ->setWrapperLegendMsg(
'listusers' );
425 return $htmlForm->prepareForm()->getHTML(
true );
452 $query = parent::getDefaultQuery();
453 if ( $this->requestedGroup !=
'' ) {
454 $query[
'group'] = $this->requestedGroup;
456 if ( $this->requestedUser !=
'' ) {
457 $query[
'username'] = $this->requestedUser;
459 $this->hookRunner->onSpecialListusersDefaultQuery( $this, $query );