99 $parms = explode(
'/', $par );
100 $symsForAll = [
'*',
'user' ];
102 if ( $parms[0] !=
'' &&
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 =
'';
131 if ( $username !==
null ) {
132 $this->requestedUser = $username->getText();
138 parent::__construct();
140 $this->hookRunner =
new HookRunner( $hookContainer );
148 return $this->creationSort ?
'user_id' :
'user_name';
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 !=
'' ) {
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 );
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 ) {
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',
349 'label' => $this->
msg(
'group' )->text(),
352 'class' => HTMLSelectField::class,
353 'options' => $groupOptions,
357 'label' => $this->
msg(
'listusers-editsonly' )->text(),
358 'name' =>
'editsOnly',
362 'temporaryGroupsOnly' => [
364 'label' => $this->
msg(
'listusers-temporarygroupsonly' )->text(),
365 'name' =>
'temporaryGroupsOnly',
366 'id' =>
'temporaryGroupsOnly',
371 'label' => $this->
msg(
'listusers-creationsort' )->text(),
372 'name' =>
'creationSort',
373 'id' =>
'creationSort',
378 'label' => $this->
msg(
'listusers-desc' )->text(),
383 'limithiddenfield' => [
384 'class' => HTMLHiddenField::class,
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
421 ->setId(
'mw-listusers-form' )
422 ->setFormIdentifier(
'mw-listusers-form' )
423 ->suppressDefaultSubmit()
424 ->setWrapperLegendMsg(
'listusers' );
425 return $htmlForm->prepareForm()->getHTML(
true );
439 foreach ( $this->userGroupManager->listAllGroups() as $group ) {
440 $result[$group] =
$lang->getGroupName( $group );
452 $query = parent::getDefaultQuery();
453 if ( $this->requestedGroup !=
'' ) {
456 if ( $this->requestedUser !=
'' ) {
459 $this->hookRunner->onSpecialListusersDefaultQuery( $this, $query );
472 if ( $this->userGroupCache ===
null ) {
473 return $this->userGroupManager->getUserGroupMemberships( $user );
475 return $this->userGroupCache[$user->getId()] ?? [];
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
static userToolLinksRedContribs( $userId, $userText, $edits=null, $useParentheses=true)
Alias for userToolLinks( $userId, $userText, true );.
A class containing constants representing the names of configuration variables.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static getGroupPage( $group)
Gets the title of a page describing a particular user group.
static getLink( $ugm, IContextSource $context, $format, $userName=null)
Gets a link for a user group, possibly including the expiry date if relevant.
static idFromName( $name, $flags=self::READ_NORMAL)
Get database id given a user name.
Interface for objects which can provide a MediaWiki context on request.
if(!isset( $args[0])) $lang