98 $parms = explode(
'/', $par );
99 $symsForAll = [
'*',
'user' ];
101 if ( $parms[0] !=
'' &&
104 $this->requestedGroup = $par;
105 $un = $request->getText(
'username' );
106 } elseif ( count( $parms ) == 2 ) {
107 $this->requestedGroup = $parms[0];
110 $this->requestedGroup = $request->getVal(
'group' );
111 $un = ( $par !=
'' ) ? $par : $request->getText(
'username' );
114 if ( in_array( $this->requestedGroup, $symsForAll ) ) {
115 $this->requestedGroup =
'';
117 $this->editsOnly = $request->getBool(
'editsOnly' );
118 $this->temporaryGroupsOnly = $request->getBool(
'temporaryGroupsOnly' );
119 $this->creationSort = $request->getBool(
'creationSort' );
121 $this->mDefaultDirection = $request->getBool(
'desc' )
125 $this->requestedUser =
'';
130 if ( $username !==
null ) {
131 $this->requestedUser = $username->getText();
137 parent::__construct();
139 $this->hookRunner =
new HookRunner( $hookContainer );
147 return $this->creationSort ?
'user_id' :
'user_name';
159 $conds[] =
'ipb_deleted IS NULL OR ipb_deleted = 0';
164 if ( $this->requestedGroup !=
'' || $this->temporaryGroupsOnly ) {
165 $conds[] =
'ug_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() ) .
166 ( !$this->temporaryGroupsOnly ?
' OR ug_expiry IS NULL' :
'' );
169 if ( $this->requestedGroup !=
'' ) {
173 if ( $this->requestedUser !=
'' ) {
174 # Sorted either by account creation or name
175 if ( $this->creationSort ) {
176 $conds[] =
'user_id >= ' . intval(
User::idFromName( $this->requestedUser ) );
178 $conds[] =
'user_name >= ' .
$dbr->addQuotes( $this->requestedUser );
182 if ( $this->editsOnly ) {
183 $conds[] =
'user_editcount > 0';
186 $options[
'GROUP BY'] = $this->creationSort ?
'user_id' :
'user_name';
189 'tables' => [
'user',
'user_groups',
'ipblocks' ],
191 'user_name' => $this->creationSort ?
'MAX(user_name)' :
'user_name',
192 'user_id' => $this->creationSort ?
'user_id' :
'MAX(user_id)',
193 'edits' =>
'MAX(user_editcount)',
194 'creation' =>
'MIN(user_registration)',
195 'ipb_deleted' =>
'MAX(ipb_deleted)',
196 'ipb_sitewide' =>
'MAX(ipb_sitewide)'
198 'options' => $options,
200 'user_groups' => [
'LEFT JOIN',
'user_id=ug_user' ],
211 $this->hookRunner->onSpecialListusersQueryInfo( $this, $query );
221 if ( $row->user_id == 0 ) { # T18487
225 $userName = $row->user_name;
241 if ( !$this->including && count( $ugms ) > 0 ) {
243 foreach ( $ugms as $ugm ) {
246 $groups =
$lang->commaList( $list );
249 $item =
$lang->specialList( $ulinks, $groups );
251 if ( $row->ipb_deleted ) {
252 $item =
"<span class=\"deleted\">$item</span>";
256 if ( !$this->including && $this->
getConfig()->
get(
'Edititis' ) ) {
257 $count = $this->
msg(
'usereditcount' )->numParams( $row->edits )->escaped();
258 $edits = $this->
msg(
'word-separator' )->escaped() . $this->
msg(
'brackets', $count )->escaped();
262 # Some rows may be null
263 if ( !$this->including && $row->creation ) {
265 $d =
$lang->userDate( $row->creation, $user );
266 $t =
$lang->userTime( $row->creation, $user );
267 $created = $this->
msg(
'usercreated', $d,
$t, $row->user_name )->escaped();
268 $created =
' ' . $this->
msg(
'parentheses' )->rawParams( $created )->escaped();
271 $blocked = $row->ipb_deleted !==
null && $row->ipb_sitewide ===
'1' ?
272 ' ' . $this->
msg(
'listusers-blocked', $userName )->escaped() :
275 $this->hookRunner->onSpecialListusersFormatRow( $item, $row );
281 $batch = $this->linkBatchFactory->newLinkBatch();
283 # Give some pointers to make user links
284 foreach ( $this->mResult as $row ) {
285 $batch->add(
NS_USER, $row->user_name );
287 $userIds[] = $row->user_id;
292 $groupsQueryInfo = $this->userGroupManager->getQueryInfo();
293 $groupRes =
$dbr->select(
294 $groupsQueryInfo[
'tables'],
295 $groupsQueryInfo[
'fields'],
296 [
'ug_user' => $userIds ],
298 $groupsQueryInfo[
'joins']
302 foreach ( $groupRes as $row ) {
303 $ugm = $this->userGroupManager->newGroupMembershipFromRow( $row );
304 if ( !$ugm->isExpired() ) {
305 $cache[$row->ug_user][$row->ug_group] = $ugm;
306 $groups[$row->ug_group] =
true;
312 $this->hookRunner->onUsersPagerDoBatchLookups(
$dbr, $userIds,
$cache, $groups );
314 $this->userGroupCache =
$cache;
317 foreach ( $groups as $group => $unused ) {
320 $batch->addObj( $groupPage );
325 $this->mResult->rewind();
332 $self = explode(
'/', $this->
getTitle()->getPrefixedDBkey(), 2 )[0];
334 $groupOptions = [ $this->
msg(
'group-all' )->text() =>
'' ];
335 foreach ( $this->
getAllGroups() as $group => $groupText ) {
336 $groupOptions[ $groupText ] = $group;
341 'class' => HTMLUserTextField::class,
342 'label' => $this->
msg(
'listusersfrom' )->text(),
343 'name' =>
'username',
347 'label' => $this->
msg(
'group' )->text(),
350 'class' => HTMLSelectField::class,
351 'options' => $groupOptions,
355 'label' => $this->
msg(
'listusers-editsonly' )->text(),
356 'name' =>
'editsOnly',
360 'temporaryGroupsOnly' => [
362 'label' => $this->
msg(
'listusers-temporarygroupsonly' )->text(),
363 'name' =>
'temporaryGroupsOnly',
364 'id' =>
'temporaryGroupsOnly',
369 'label' => $this->
msg(
'listusers-creationsort' )->text(),
370 'name' =>
'creationSort',
371 'id' =>
'creationSort',
376 'label' => $this->
msg(
'listusers-desc' )->text(),
381 'limithiddenfield' => [
382 'class' => HTMLHiddenField::class,
388 $beforeSubmitButtonHookOut =
'';
389 $this->hookRunner->onSpecialListusersHeaderForm( $this, $beforeSubmitButtonHookOut );
391 if ( $beforeSubmitButtonHookOut !==
'' ) {
392 $formDescriptor[
'beforeSubmitButtonHookOut' ] = [
393 'class' => HTMLInfoField::class,
395 'default' => $beforeSubmitButtonHookOut
399 $formDescriptor[
'submit' ] = [
400 'class' => HTMLSubmitField::class,
401 'buttonlabel-message' =>
'listusers-submit',
404 $beforeClosingFieldsetHookOut =
'';
405 $this->hookRunner->onSpecialListusersHeader( $this, $beforeClosingFieldsetHookOut );
407 if ( $beforeClosingFieldsetHookOut !==
'' ) {
408 $formDescriptor[
'beforeClosingFieldsetHookOut' ] = [
409 'class' => HTMLInfoField::class,
411 'default' => $beforeClosingFieldsetHookOut
419 ->setId(
'mw-listusers-form' )
420 ->setFormIdentifier(
'mw-listusers-form' )
421 ->suppressDefaultSubmit()
422 ->setWrapperLegendMsg(
'listusers' );
423 return $htmlForm->prepareForm()->getHTML(
true );
436 foreach ( $this->userGroupManager->listAllGroups() as $group ) {
449 $query = parent::getDefaultQuery();
450 if ( $this->requestedGroup !=
'' ) {
453 if ( $this->requestedUser !=
'' ) {
456 $this->hookRunner->onSpecialListusersDefaultQuery( $this, $query );
472 return $user->getGroupMemberships();
474 return $cache[$uid] ?? [];