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