MediaWiki REL1_34
UserNamePrefixSearch.php
Go to the documentation of this file.
1<?php
24
31
41 public static function search( $audience, $search, $limit, $offset = 0 ) {
42 $user = User::newFromName( $search );
43
45 $prefix = $user ? $user->getName() : '';
46 $tables = [ 'user' ];
47 $cond = [ 'user_name ' . $dbr->buildLike( $prefix, $dbr->anyString() ) ];
48 $joinConds = [];
49
50 // Filter out hidden user names
51 if ( $audience === 'public' || !MediaWikiServices::getInstance()
53 ->userHasRight( $audience, 'hideuser' )
54 ) {
55 $tables[] = 'ipblocks';
56 $cond['ipb_deleted'] = [ 0, null ];
57 $joinConds['ipblocks'] = [ 'LEFT JOIN', 'user_id=ipb_user' ];
58 }
59
60 $res = $dbr->selectFieldValues(
61 $tables,
62 'user_name',
63 $cond,
64 __METHOD__,
65 [
66 'LIMIT' => $limit,
67 'ORDER BY' => 'user_name',
68 'OFFSET' => $offset
69 ],
70 $joinConds
71 );
72
73 return $res;
74 }
75}
getPermissionManager()
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Handles searching prefixes of user names.
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition User.php:518
const DB_REPLICA
Definition defines.php:25