Go to the documentation of this file.
9 parent::__construct(
'Renameuser',
'renameuser' );
30 $out->addWikiMsg(
'renameuser-summary' );
33 if ( !
$user->isAllowed(
'renameuser' ) ) {
41 if (
$user->isBlocked() ) {
48 $showBlockLog =
$request->getBool(
'submit-showBlockLog' );
49 $usernames = explode(
'/', $par, 2 );
50 $oldnamePar = trim( str_replace(
'_',
' ',
$request->getText(
'oldusername', $usernames[0] ) ) );
52 $newnamePar = isset( $usernames[1] ) ? $usernames[1] :
null;
53 $newnamePar = trim( str_replace(
'_',
' ',
$request->getText(
'newusername', $newnamePar ) ) );
57 $oun = is_object( $oldusername ) ? $oldusername->getText() :
'';
58 $nun = is_object( $newusername ) ? $newusername->getText() :
'';
59 $token =
$user->getEditToken();
60 $reason =
$request->getText(
'reason' );
63 $suppress_checked =
$request->getCheck(
'suppressredirect' );
66 if ( $oun && $nun && !
$request->getCheck(
'confirmaction' ) ) {
67 Hooks::run(
'RenameUserWarning', [ $oun, $nun, &$warnings ] );
80 <td class='mw-label'>" .
83 <td class='mw-input'>" .
84 Xml::input(
'oldusername', 20, $oun, [
'type' =>
'text',
'tabindex' =>
'1' ] ) .
' ' .
88 <td class='mw-label'>" .
91 <td class='mw-input'>" .
92 Xml::input(
'newusername', 20, $nun, [
'type' =>
'text',
'tabindex' =>
'2' ] ) .
96 <td class='mw-label'>" .
99 <td class='mw-input'>" .
104 [
'type' =>
'text',
'tabindex' =>
'3',
'maxlength' => 255 ]
109 if (
$user->isAllowed(
'move' ) ) {
114 <td class='mw-input'>" .
116 $move_checked, [
'tabindex' =>
'4' ] ) .
121 if (
$user->isAllowed(
'suppressredirect' ) ) {
126 <td class='mw-input'>" .
128 $this->
msg(
'renameusersuppress' )->
text(),
132 [
'tabindex' =>
'5' ]
141 foreach ( $warnings
as $warning ) {
142 $warningsHtml[] = is_array( $warning ) ?
143 $this->
msg( $warning[0] )->rawParams( array_slice( $warning, 1 ) )->escaped() :
144 $this->
msg( $warning )->escaped();
149 <td class='mw-label'>" . $this->
msg(
'renameuserwarnings' )->escaped() .
"
151 <td class='mw-input'>" .
152 '<ul class="error"><li>' .
153 implode(
'</li><li>', $warningsHtml ) .
'</li></ul>' .
161 <td class='mw-input'>" .
163 $this->
msg(
'renameuserconfirm' )->
text(),
167 [
'tabindex' =>
'6' ]
177 <td class='mw-submit'>" .
179 $this->
msg(
'renameusersubmit' )->
text(),
188 $this->
msg(
'renameuser-submit-blocklog' )->
text(),
190 'name' =>
'submit-showBlockLog',
191 'id' =>
'submit-showBlockLog',
204 if ( $showBlockLog && is_object( $oldusername ) ) {
210 if (
$request->getText(
'token' ) ===
'' ) {
211 # They probably haven't even submitted the form, so don't go further.
213 } elseif ( $warnings ) {
214 # Let user read warnings
217 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
'renameuser-error-request' );
220 } elseif ( !is_object( $oldusername ) ) {
221 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
222 [
'renameusererrorinvalid',
$request->getText(
'oldusername' ) ] );
225 } elseif ( !is_object( $newusername ) ) {
226 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
227 [
'renameusererrorinvalid',
$request->getText(
'newusername' ) ] );
230 } elseif ( $oldusername->getText() === $newusername->getText() ) {
231 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
'renameuser-error-same-user' );
241 if ( !is_object( $olduser ) ) {
242 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
243 [
'renameusererrorinvalid', $oldusername->getText() ] );
248 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
249 [
'renameusererrorinvalid', $newusername->getText() ] );
256 if ( $oldusername->getText() !==
$wgContLang->ucfirst( $oldusername->getText() ) ) {
259 $uid =
$dbr->selectField(
'user',
'user_id',
260 [
'user_name' => $oldusername->getText() ],
262 if ( $uid ===
false ) {
267 $uid = $olduser->idForName();
273 $uid = $olduser->idForName();
277 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
278 [
'renameusererrordoesnotexist', $oldusername->getText() ] );
283 if ( $newuser->idForName() !== 0 ) {
284 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
285 [
'renameusererrorexists', $newusername->getText() ] );
293 [ $uid, $oldusername->getText(), $newusername->getText() ]
300 $oldusername->getText(),
301 $newusername->getText(),
304 [
'reason' => $reason ]
306 if ( !$rename->rename() ) {
312 if (
$user->getId() === $uid ) {
313 $user->setName( $newusername->getText() );
317 if (
$request->getCheck(
'movepages' ) &&
$user->isAllowed(
'move' ) ) {
320 $pages =
$dbr->select(
322 [
'page_namespace',
'page_title' ],
325 '(page_title ' .
$dbr->buildLike( $oldusername->getDBkey() .
'/',
$dbr->anyString() ) .
326 ' OR page_title = ' .
$dbr->addQuotes( $oldusername->getDBkey() ) .
')'
331 $suppressRedirect =
false;
333 if (
$request->getCheck(
'suppressredirect' ) &&
$user->isAllowed(
'suppressredirect' ) ) {
334 $suppressRedirect =
true;
338 foreach ( $pages
as $row ) {
341 preg_replace(
'!^[^/]+!', $newusername->getDBkey(), $row->page_title ) );
342 # Do not autodelete or anything, title must not exist
343 if ( $newPage->exists() && !$oldPage->isValidMoveTarget( $newPage ) ) {
347 [
'class' =>
'mw-renameuser-pe' ],
348 $this->
msg(
'renameuser-page-exists' )->rawParams(
$link )->escaped()
355 'renameuser-move-log',
356 $oldusername->getText(),
357 $newusername->getText() )->inContentLanguage()->text(),
361 # oldPage is not known in case of redirect suppression
362 $oldLink =
Linker::link( $oldPage,
null, [], [
'redirect' =>
'no' ] );
364 # newPage is always known because the move was successful
369 [
'class' =>
'mw-renameuser-pm' ],
370 $this->
msg(
'renameuser-page-moved' )->rawParams( $oldLink, $newLink )->escaped()
376 'li', [
'class' =>
'mw-renameuser-pu' ],
377 $this->
msg(
'renameuser-page-unmoved' )->rawParams( $oldLink, $newLink )->escaped()
388 $out->wrapWikiMsg(
"<div class=\"successbox\">$1</div><br style=\"clear:both\" />",
389 [
'renameusersuccess', $oldusername->getText(), $newusername->getText() ] );
398 # Show relevant lines from the logs:
400 $out->addHTML(
Xml::element(
'h2',
null, $logPage->getName()->text() ) .
"\n" );
413 if ( !class_exists(
'UserNamePrefixSearch' ) ) {
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
getPageTitle( $subpage=false)
Get a self-referential title object.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
msg( $key)
Wrapper around wfMessage that sets the current context.
processing should stop and the error should be shown to the user * false
Show an error when the user tries to do something whilst blocked.
getOutput()
Get the OutputPage being used for this instance.
doesWrites()
Indicates whether this special page may perform database writes.
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
wfReadOnly()
Check whether the wiki is in read-only mode.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
Show an error when a user tries to do something they do not have the necessary permissions for.
static openElement( $element, $attribs=null)
This opens an XML element.
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Class which performs the actual renaming of users.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Class to simplify the use of log pages.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
when a variable name is used in a it is silently declared as a new masking the global
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Parent class for all special pages.
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
getRequest()
Get the WebRequest being used for this instance.
Special page that allows authorised users to rename user accounts.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
static closeElement( $element)
Shortcut to close an XML element.
$wgCapitalLinks
Set this to false to avoid forcing the first letter of links to capitals.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
showLogExtract( $username, $type, &$out)
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
execute( $par)
Show the special page.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
this hook is for auditing only or null if authentication failed before getting that far $username
static isCreatableName( $name)
Usernames which fail to pass this function will be blocked from new account registrations,...
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out