Merge "Fix Postgres support"
[lhc/web/wiklou.git] / includes / specials / SpecialContributions.php
1 <?php
2 /**
3 * Implements Special:Contributions
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * Special:Contributions, show user contributions in a paged list
26 *
27 * @ingroup SpecialPage
28 */
29 class SpecialContributions extends IncludableSpecialPage {
30 protected $opts;
31
32 public function __construct() {
33 parent::__construct( 'Contributions' );
34 }
35
36 public function execute( $par ) {
37 $this->setHeaders();
38 $this->outputHeader();
39 $out = $this->getOutput();
40 $out->addModuleStyles( [
41 'mediawiki.special',
42 'mediawiki.special.changeslist',
43 'mediawiki.widgets.DateInputWidget.styles',
44 ] );
45 $out->addModules( 'mediawiki.special.contributions' );
46 $this->addHelpLink( 'Help:User contributions' );
47 $out->enableOOUI();
48
49 $this->opts = [];
50 $request = $this->getRequest();
51
52 if ( $par !== null ) {
53 $target = $par;
54 } else {
55 $target = $request->getVal( 'target' );
56 }
57
58 if ( $request->getVal( 'contribs' ) == 'newbie' || $par === 'newbies' ) {
59 $target = 'newbies';
60 $this->opts['contribs'] = 'newbie';
61 } else {
62 $this->opts['contribs'] = 'user';
63 }
64
65 $this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' );
66
67 if ( !strlen( $target ) ) {
68 if ( !$this->including() ) {
69 $out->addHTML( $this->getForm() );
70 }
71
72 return;
73 }
74
75 $user = $this->getUser();
76
77 $this->opts['limit'] = $request->getInt( 'limit', $user->getOption( 'rclimit' ) );
78 $this->opts['target'] = $target;
79 $this->opts['topOnly'] = $request->getBool( 'topOnly' );
80 $this->opts['newOnly'] = $request->getBool( 'newOnly' );
81 $this->opts['hideMinor'] = $request->getBool( 'hideMinor' );
82
83 $nt = Title::makeTitleSafe( NS_USER, $target );
84 if ( !$nt ) {
85 $out->addHTML( $this->getForm() );
86
87 return;
88 }
89 $userObj = User::newFromName( $nt->getText(), false );
90 if ( !$userObj ) {
91 $out->addHTML( $this->getForm() );
92
93 return;
94 }
95 $id = $userObj->getId();
96
97 if ( $this->opts['contribs'] != 'newbie' ) {
98 $target = $nt->getText();
99 $out->addSubtitle( $this->contributionsSub( $userObj ) );
100 $out->setHTMLTitle( $this->msg(
101 'pagetitle',
102 $this->msg( 'contributions-title', $target )->plain()
103 )->inContentLanguage() );
104 $this->getSkin()->setRelevantUser( $userObj );
105 } else {
106 $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
107 $out->setHTMLTitle( $this->msg(
108 'pagetitle',
109 $this->msg( 'sp-contributions-newbies-title' )->plain()
110 )->inContentLanguage() );
111 }
112
113 $ns = $request->getVal( 'namespace', null );
114 if ( $ns !== null && $ns !== '' ) {
115 $this->opts['namespace'] = intval( $ns );
116 } else {
117 $this->opts['namespace'] = '';
118 }
119
120 $this->opts['associated'] = $request->getBool( 'associated' );
121 $this->opts['nsInvert'] = (bool)$request->getVal( 'nsInvert' );
122 $this->opts['tagfilter'] = (string)$request->getVal( 'tagfilter' );
123
124 // Allows reverts to have the bot flag in recent changes. It is just here to
125 // be passed in the form at the top of the page
126 if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
127 $this->opts['bot'] = '1';
128 }
129
130 $skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev';
131 # Offset overrides year/month selection
132 if ( $skip ) {
133 $this->opts['year'] = '';
134 $this->opts['month'] = '';
135 } else {
136 $this->opts['year'] = $request->getVal( 'year' );
137 $this->opts['month'] = $request->getVal( 'month' );
138
139 $this->opts['start'] = $request->getVal( 'start' );
140 $this->opts['end'] = $request->getVal( 'end' );
141 $this->opts = ContribsPager::processDateFilter( $this->opts );
142 }
143
144 $feedType = $request->getVal( 'feed' );
145
146 $feedParams = [
147 'action' => 'feedcontributions',
148 'user' => $target,
149 ];
150 if ( $this->opts['topOnly'] ) {
151 $feedParams['toponly'] = true;
152 }
153 if ( $this->opts['newOnly'] ) {
154 $feedParams['newonly'] = true;
155 }
156 if ( $this->opts['hideMinor'] ) {
157 $feedParams['hideminor'] = true;
158 }
159 if ( $this->opts['deletedOnly'] ) {
160 $feedParams['deletedonly'] = true;
161 }
162 if ( $this->opts['tagfilter'] !== '' ) {
163 $feedParams['tagfilter'] = $this->opts['tagfilter'];
164 }
165 if ( $this->opts['namespace'] !== '' ) {
166 $feedParams['namespace'] = $this->opts['namespace'];
167 }
168 // Don't use year and month for the feed URL, but pass them on if
169 // we redirect to API (if $feedType is specified)
170 if ( $feedType && $this->opts['year'] !== null ) {
171 $feedParams['year'] = $this->opts['year'];
172 }
173 if ( $feedType && $this->opts['month'] !== null ) {
174 $feedParams['month'] = $this->opts['month'];
175 }
176
177 if ( $feedType ) {
178 // Maintain some level of backwards compatibility
179 // If people request feeds using the old parameters, redirect to API
180 $feedParams['feedformat'] = $feedType;
181 $url = wfAppendQuery( wfScript( 'api' ), $feedParams );
182
183 $out->redirect( $url, '301' );
184
185 return;
186 }
187
188 // Add RSS/atom links
189 $this->addFeedLinks( $feedParams );
190
191 if ( Hooks::run( 'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) {
192 if ( !$this->including() ) {
193 $out->addHTML( $this->getForm() );
194 }
195 $pager = new ContribsPager( $this->getContext(), [
196 'target' => $target,
197 'contribs' => $this->opts['contribs'],
198 'namespace' => $this->opts['namespace'],
199 'tagfilter' => $this->opts['tagfilter'],
200 'start' => $this->opts['start'],
201 'end' => $this->opts['end'],
202 'deletedOnly' => $this->opts['deletedOnly'],
203 'topOnly' => $this->opts['topOnly'],
204 'newOnly' => $this->opts['newOnly'],
205 'hideMinor' => $this->opts['hideMinor'],
206 'nsInvert' => $this->opts['nsInvert'],
207 'associated' => $this->opts['associated'],
208 ] );
209
210 if ( !$pager->getNumRows() ) {
211 $out->addWikiMsg( 'nocontribs', $target );
212 } else {
213 # Show a message about replica DB lag, if applicable
214 $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
215 if ( $lag > 0 ) {
216 $out->showLagWarning( $lag );
217 }
218
219 $output = $pager->getBody();
220 if ( !$this->including() ) {
221 $output = '<p>' . $pager->getNavigationBar() . '</p>' .
222 $output .
223 '<p>' . $pager->getNavigationBar() . '</p>';
224 }
225 $out->addHTML( $output );
226 }
227 $out->preventClickjacking( $pager->getPreventClickjacking() );
228
229 # Show the appropriate "footer" message - WHOIS tools, etc.
230 if ( $this->opts['contribs'] == 'newbie' ) {
231 $message = 'sp-contributions-footer-newbies';
232 } elseif ( IP::isIPAddress( $target ) ) {
233 $message = 'sp-contributions-footer-anon';
234 } elseif ( $userObj->isAnon() ) {
235 // No message for non-existing users
236 $message = '';
237 } else {
238 $message = 'sp-contributions-footer';
239 }
240
241 if ( $message ) {
242 if ( !$this->including() ) {
243 if ( !$this->msg( $message, $target )->isDisabled() ) {
244 $out->wrapWikiMsg(
245 "<div class='mw-contributions-footer'>\n$1\n</div>",
246 [ $message, $target ] );
247 }
248 }
249 }
250 }
251 }
252
253 /**
254 * Generates the subheading with links
255 * @param User $userObj User object for the target
256 * @return string Appropriately-escaped HTML to be output literally
257 * @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php.
258 * Could be combined.
259 */
260 protected function contributionsSub( $userObj ) {
261 if ( $userObj->isAnon() ) {
262 // Show a warning message that the user being searched for doesn't exists
263 if ( !User::isIP( $userObj->getName() ) ) {
264 $this->getOutput()->wrapWikiMsg(
265 "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
266 [
267 'contributions-userdoesnotexist',
268 wfEscapeWikiText( $userObj->getName() ),
269 ]
270 );
271 if ( !$this->including() ) {
272 $this->getOutput()->setStatusCode( 404 );
273 }
274 }
275 $user = htmlspecialchars( $userObj->getName() );
276 } else {
277 $user = $this->getLinkRenderer()->makeLink( $userObj->getUserPage(), $userObj->getName() );
278 }
279 $nt = $userObj->getUserPage();
280 $talk = $userObj->getTalkPage();
281 $links = '';
282 if ( $talk ) {
283 $tools = self::getUserLinks( $this, $userObj );
284 $links = $this->getLanguage()->pipeList( $tools );
285
286 // Show a note if the user is blocked and display the last block log entry.
287 // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
288 // and also this will display a totally irrelevant log entry as a current block.
289 if ( !$this->including() ) {
290 $block = Block::newFromTarget( $userObj, $userObj );
291 if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
292 if ( $block->getType() == Block::TYPE_RANGE ) {
293 $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
294 }
295
296 $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
297 LogEventsList::showLogExtract(
298 $out,
299 'block',
300 $nt,
301 '',
302 [
303 'lim' => 1,
304 'showIfEmpty' => false,
305 'msgKey' => [
306 $userObj->isAnon() ?
307 'sp-contributions-blocked-notice-anon' :
308 'sp-contributions-blocked-notice',
309 $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
310 ],
311 'offset' => '' # don't use WebRequest parameter offset
312 ]
313 );
314 }
315 }
316 }
317
318 return $this->msg( 'contribsub2' )->rawParams( $user, $links )->params( $userObj->getName() );
319 }
320
321 /**
322 * Links to different places.
323 *
324 * @note This function is also called in DeletedContributionsPage
325 * @param SpecialPage $sp SpecialPage instance, for context
326 * @param User $target Target user object
327 * @return array
328 */
329 public static function getUserLinks( SpecialPage $sp, User $target ) {
330
331 $id = $target->getId();
332 $username = $target->getName();
333 $userpage = $target->getUserPage();
334 $talkpage = $target->getTalkPage();
335
336 $linkRenderer = $sp->getLinkRenderer();
337 $tools['user-talk'] = $linkRenderer->makeLink(
338 $talkpage,
339 $sp->msg( 'sp-contributions-talk' )->text()
340 );
341
342 if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
343 if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
344 if ( $target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
345 $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
346 SpecialPage::getTitleFor( 'Block', $username ),
347 $sp->msg( 'change-blocklink' )->text()
348 );
349 $tools['unblock'] = $linkRenderer->makeKnownLink( # Unblock link
350 SpecialPage::getTitleFor( 'Unblock', $username ),
351 $sp->msg( 'unblocklink' )->text()
352 );
353 } else { # User is not blocked
354 $tools['block'] = $linkRenderer->makeKnownLink( # Block link
355 SpecialPage::getTitleFor( 'Block', $username ),
356 $sp->msg( 'blocklink' )->text()
357 );
358 }
359 }
360
361 # Block log link
362 $tools['log-block'] = $linkRenderer->makeKnownLink(
363 SpecialPage::getTitleFor( 'Log', 'block' ),
364 $sp->msg( 'sp-contributions-blocklog' )->text(),
365 [],
366 [ 'page' => $userpage->getPrefixedText() ]
367 );
368
369 # Suppression log link (T61120)
370 if ( $sp->getUser()->isAllowed( 'suppressionlog' ) ) {
371 $tools['log-suppression'] = $linkRenderer->makeKnownLink(
372 SpecialPage::getTitleFor( 'Log', 'suppress' ),
373 $sp->msg( 'sp-contributions-suppresslog', $username )->text(),
374 [],
375 [ 'offender' => $username ]
376 );
377 }
378 }
379 # Uploads
380 $tools['uploads'] = $linkRenderer->makeKnownLink(
381 SpecialPage::getTitleFor( 'Listfiles', $username ),
382 $sp->msg( 'sp-contributions-uploads' )->text()
383 );
384
385 # Other logs link
386 $tools['logs'] = $linkRenderer->makeKnownLink(
387 SpecialPage::getTitleFor( 'Log', $username ),
388 $sp->msg( 'sp-contributions-logs' )->text()
389 );
390
391 # Add link to deleted user contributions for priviledged users
392 if ( $sp->getUser()->isAllowed( 'deletedhistory' ) ) {
393 $tools['deletedcontribs'] = $linkRenderer->makeKnownLink(
394 SpecialPage::getTitleFor( 'DeletedContributions', $username ),
395 $sp->msg( 'sp-contributions-deleted', $username )->text()
396 );
397 }
398
399 # Add a link to change user rights for privileged users
400 $userrightsPage = new UserrightsPage();
401 $userrightsPage->setContext( $sp->getContext() );
402 if ( $userrightsPage->userCanChangeRights( $target ) ) {
403 $tools['userrights'] = $linkRenderer->makeKnownLink(
404 SpecialPage::getTitleFor( 'Userrights', $username ),
405 $sp->msg( 'sp-contributions-userrights', $username )->text()
406 );
407 }
408
409 Hooks::run( 'ContributionsToolLinks', [ $id, $userpage, &$tools, $sp ] );
410
411 return $tools;
412 }
413
414 /**
415 * Generates the namespace selector form with hidden attributes.
416 * @return string HTML fragment
417 */
418 protected function getForm() {
419 $this->opts['title'] = $this->getPageTitle()->getPrefixedText();
420 if ( !isset( $this->opts['target'] ) ) {
421 $this->opts['target'] = '';
422 } else {
423 $this->opts['target'] = str_replace( '_', ' ', $this->opts['target'] );
424 }
425
426 if ( !isset( $this->opts['namespace'] ) ) {
427 $this->opts['namespace'] = '';
428 }
429
430 if ( !isset( $this->opts['nsInvert'] ) ) {
431 $this->opts['nsInvert'] = '';
432 }
433
434 if ( !isset( $this->opts['associated'] ) ) {
435 $this->opts['associated'] = false;
436 }
437
438 if ( !isset( $this->opts['contribs'] ) ) {
439 $this->opts['contribs'] = 'user';
440 }
441
442 if ( !isset( $this->opts['start'] ) ) {
443 $this->opts['start'] = '';
444 }
445
446 if ( !isset( $this->opts['end'] ) ) {
447 $this->opts['end'] = '';
448 }
449
450 if ( $this->opts['contribs'] == 'newbie' ) {
451 $this->opts['target'] = '';
452 }
453
454 if ( !isset( $this->opts['tagfilter'] ) ) {
455 $this->opts['tagfilter'] = '';
456 }
457
458 if ( !isset( $this->opts['topOnly'] ) ) {
459 $this->opts['topOnly'] = false;
460 }
461
462 if ( !isset( $this->opts['newOnly'] ) ) {
463 $this->opts['newOnly'] = false;
464 }
465
466 if ( !isset( $this->opts['hideMinor'] ) ) {
467 $this->opts['hideMinor'] = false;
468 }
469
470 $form = Html::openElement(
471 'form',
472 [
473 'method' => 'get',
474 'action' => wfScript(),
475 'class' => 'mw-contributions-form'
476 ]
477 );
478
479 # Add hidden params for tracking except for parameters in $skipParameters
480 $skipParameters = [
481 'namespace',
482 'nsInvert',
483 'deletedOnly',
484 'target',
485 'contribs',
486 'year',
487 'month',
488 'start',
489 'end',
490 'topOnly',
491 'newOnly',
492 'hideMinor',
493 'associated',
494 'tagfilter'
495 ];
496
497 foreach ( $this->opts as $name => $value ) {
498 if ( in_array( $name, $skipParameters ) ) {
499 continue;
500 }
501 $form .= "\t" . Html::hidden( $name, $value ) . "\n";
502 }
503
504 $tagFilter = ChangeTags::buildTagFilterSelector(
505 $this->opts['tagfilter'], false, $this->getContext() );
506
507 if ( $tagFilter ) {
508 $filterSelection = Html::rawElement(
509 'div',
510 [],
511 implode( '&#160;', $tagFilter )
512 );
513 } else {
514 $filterSelection = Html::rawElement( 'div', [], '' );
515 }
516
517 $this->getOutput()->addModules( 'mediawiki.userSuggest' );
518
519 $labelNewbies = Xml::radioLabel(
520 $this->msg( 'sp-contributions-newbies' )->text(),
521 'contribs',
522 'newbie',
523 'newbie',
524 $this->opts['contribs'] == 'newbie',
525 [ 'class' => 'mw-input' ]
526 );
527 $labelUsername = Xml::radioLabel(
528 $this->msg( 'sp-contributions-username' )->text(),
529 'contribs',
530 'user',
531 'user',
532 $this->opts['contribs'] == 'user',
533 [ 'class' => 'mw-input' ]
534 );
535 $input = Html::input(
536 'target',
537 $this->opts['target'],
538 'text',
539 [
540 'size' => '40',
541 'class' => [
542 'mw-input',
543 'mw-ui-input-inline',
544 'mw-autocomplete-user', // used by mediawiki.userSuggest
545 ],
546 ] + (
547 // Only autofocus if target hasn't been specified or in non-newbies mode
548 ( $this->opts['contribs'] === 'newbie' || $this->opts['target'] )
549 ? [] : [ 'autofocus' => true ]
550 )
551 );
552
553 $targetSelection = Html::rawElement(
554 'div',
555 [],
556 $labelNewbies . '<br>' . $labelUsername . ' ' . $input . ' '
557 );
558
559 $namespaceSelection = Xml::tags(
560 'div',
561 [],
562 Xml::label(
563 $this->msg( 'namespace' )->text(),
564 'namespace',
565 ''
566 ) . '&#160;' .
567 Html::namespaceSelector(
568 [ 'selected' => $this->opts['namespace'], 'all' => '' ],
569 [
570 'name' => 'namespace',
571 'id' => 'namespace',
572 'class' => 'namespaceselector',
573 ]
574 ) . '&#160;' .
575 Html::rawElement(
576 'span',
577 [ 'class' => 'mw-input-with-label' ],
578 Xml::checkLabel(
579 $this->msg( 'invert' )->text(),
580 'nsInvert',
581 'nsInvert',
582 $this->opts['nsInvert'],
583 [
584 'title' => $this->msg( 'tooltip-invert' )->text(),
585 'class' => 'mw-input'
586 ]
587 ) . '&#160;'
588 ) .
589 Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' ],
590 Xml::checkLabel(
591 $this->msg( 'namespace_association' )->text(),
592 'associated',
593 'associated',
594 $this->opts['associated'],
595 [
596 'title' => $this->msg( 'tooltip-namespace_association' )->text(),
597 'class' => 'mw-input'
598 ]
599 ) . '&#160;'
600 )
601 );
602
603 $filters = [];
604
605 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
606 $filters[] = Html::rawElement(
607 'span',
608 [ 'class' => 'mw-input-with-label' ],
609 Xml::checkLabel(
610 $this->msg( 'history-show-deleted' )->text(),
611 'deletedOnly',
612 'mw-show-deleted-only',
613 $this->opts['deletedOnly'],
614 [ 'class' => 'mw-input' ]
615 )
616 );
617 }
618
619 $filters[] = Html::rawElement(
620 'span',
621 [ 'class' => 'mw-input-with-label' ],
622 Xml::checkLabel(
623 $this->msg( 'sp-contributions-toponly' )->text(),
624 'topOnly',
625 'mw-show-top-only',
626 $this->opts['topOnly'],
627 [ 'class' => 'mw-input' ]
628 )
629 );
630 $filters[] = Html::rawElement(
631 'span',
632 [ 'class' => 'mw-input-with-label' ],
633 Xml::checkLabel(
634 $this->msg( 'sp-contributions-newonly' )->text(),
635 'newOnly',
636 'mw-show-new-only',
637 $this->opts['newOnly'],
638 [ 'class' => 'mw-input' ]
639 )
640 );
641 $filters[] = Html::rawElement(
642 'span',
643 [ 'class' => 'mw-input-with-label' ],
644 Xml::checkLabel(
645 $this->msg( 'sp-contributions-hideminor' )->text(),
646 'hideMinor',
647 'mw-hide-minor-edits',
648 $this->opts['hideMinor'],
649 [ 'class' => 'mw-input' ]
650 )
651 );
652
653 Hooks::run(
654 'SpecialContributions::getForm::filters',
655 [ $this, &$filters ]
656 );
657
658 $extraOptions = Html::rawElement(
659 'div',
660 [],
661 implode( '', $filters )
662 );
663
664 $dateRangeSelection = Html::rawElement(
665 'div',
666 [],
667 Xml::label( wfMessage( 'date-range-from' )->text(), 'mw-date-start' ) . ' ' .
668 new \Mediawiki\Widget\DateInputWidget( [
669 'infusable' => true,
670 'id' => 'mw-date-start',
671 'name' => 'start',
672 'value' => $this->opts['start'],
673 'longDisplayFormat' => true,
674 ] ) . '<br>' .
675 Xml::label( wfMessage( 'date-range-to' )->text(), 'mw-date-end' ) . ' ' .
676 new \Mediawiki\Widget\DateInputWidget( [
677 'infusable' => true,
678 'id' => 'mw-date-end',
679 'name' => 'end',
680 'value' => $this->opts['end'],
681 'longDisplayFormat' => true,
682 ] )
683 );
684
685 $submit = Xml::tags( 'div', [],
686 Html::submitButton(
687 $this->msg( 'sp-contributions-submit' )->text(),
688 [ 'class' => 'mw-submit' ], [ 'mw-ui-progressive' ]
689 )
690 );
691
692 $form .= Xml::fieldset(
693 $this->msg( 'sp-contributions-search' )->text(),
694 $targetSelection .
695 $namespaceSelection .
696 $filterSelection .
697 $extraOptions .
698 $dateRangeSelection .
699 $submit,
700 [ 'class' => 'mw-contributions-table' ]
701 );
702
703 $explain = $this->msg( 'sp-contributions-explain' );
704 if ( !$explain->isBlank() ) {
705 $form .= "<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>";
706 }
707
708 $form .= Xml::closeElement( 'form' );
709
710 return $form;
711 }
712
713 /**
714 * Return an array of subpages beginning with $search that this special page will accept.
715 *
716 * @param string $search Prefix to search for
717 * @param int $limit Maximum number of results to return (usually 10)
718 * @param int $offset Number of results to skip (usually 0)
719 * @return string[] Matching subpages
720 */
721 public function prefixSearchSubpages( $search, $limit, $offset ) {
722 $user = User::newFromName( $search );
723 if ( !$user ) {
724 // No prefix suggestion for invalid user
725 return [];
726 }
727 // Autocomplete subpage as user list - public to allow caching
728 return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
729 }
730
731 protected function getGroupName() {
732 return 'users';
733 }
734 }