Index: trunk/extensions/Renameuser/SpecialRenameuser_body.php |
— | — | @@ -54,6 +54,10 @@ |
55 | 55 | if ( $wgRequest->wasPosted() && ! $wgRequest->getCheck( 'movepages' ) ) { |
56 | 56 | $is_checked = false; |
57 | 57 | } |
| 58 | + $warnings = array(); |
| 59 | + if( $oun && $nun && !$wgRequest->getCheck( 'confirmaction' ) ) { |
| 60 | + wfRunHooks( 'RenameUserWarning', array( $oun, $nun, &$warnings ) ); |
| 61 | + } |
58 | 62 | |
59 | 63 | $wgOut->addHTML( " |
60 | 64 | <!-- Current contributions limit is " . RENAMEUSER_CONTRIBLIMIT . " -->" . |
— | — | @@ -97,16 +101,41 @@ |
98 | 102 | </tr>" |
99 | 103 | ); |
100 | 104 | } |
| 105 | + if( $warnings ) { |
| 106 | + $warningsHtml = array(); |
| 107 | + foreach( $warnings as $warning ) |
| 108 | + $warningsHtml[] = is_array( $warning ) ? |
| 109 | + call_user_func_array( 'wfMsgWikiHtml', $warning ) : |
| 110 | + wfMsgHtml( $warning ); |
| 111 | + $wgOut->addHTML( " |
| 112 | + <tr> |
| 113 | + <td>".wfMsgWikiHtml( 'renameuserwarnings' ) ." |
| 114 | + </td> |
| 115 | + <td class='mw-input'>" . |
| 116 | + '<ul style="color: red; font-weight: bold"><li>'.implode( '</li><li>', $warningsHtml ).'</li></ul>'. |
| 117 | + "</td> |
| 118 | + </tr>" |
| 119 | + ); |
| 120 | + $wgOut->addHTML( " |
| 121 | + <tr> |
| 122 | + <td> |
| 123 | + </td> |
| 124 | + <td class='mw-input'>" . |
| 125 | + Xml::checkLabel( wfMsg( 'renameuserconfirm' ), 'confirmaction', 'confirmaction', false, array( 'tabindex' => '5' ) ) . |
| 126 | + "</td> |
| 127 | + </tr>" |
| 128 | + ); |
| 129 | + } |
101 | 130 | |
102 | 131 | $wgOut->addHTML( " |
103 | 132 | <tr> |
104 | 133 | <td> |
105 | 134 | </td> |
106 | 135 | <td class='mw-submit'>" . |
107 | | - Xml::submitButton( wfMsg( 'renameusersubmit' ), array( 'name' => 'submit', 'tabindex' => '5', 'id' => 'submit' ) ) . |
| 136 | + Xml::submitButton( wfMsg( 'renameusersubmit' ), array( 'name' => 'submit', 'tabindex' => '6', 'id' => 'submit' ) ) . |
108 | 137 | ' ' . |
109 | 138 | Xml::submitButton( wfMsg( 'blocklogpage' ), array ( 'name' => 'submit-showBlockLog', |
110 | | - 'id' => 'submit-showBlockLog', 'tabindex' => '6' ) ) . |
| 139 | + 'id' => 'submit-showBlockLog', 'tabindex' => '7' ) ) . |
111 | 140 | "</td> |
112 | 141 | </tr>" . |
113 | 142 | Xml::closeElement( 'table' ) . |
— | — | @@ -124,6 +153,9 @@ |
125 | 154 | if( $wgRequest->getText( 'token' ) === '' ) { |
126 | 155 | # They probably haven't even submitted the form, so don't go further. |
127 | 156 | return; |
| 157 | + } elseif( $warnings ) { |
| 158 | + # Let user read warnings |
| 159 | + return; |
128 | 160 | } elseif( !$wgRequest->wasPosted() || !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) { |
129 | 161 | $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameuser-error-request' ) . "</div>" ); |
130 | 162 | return; |
— | — | @@ -372,6 +404,8 @@ |
373 | 405 | |
374 | 406 | wfProfileIn( __METHOD__ ); |
375 | 407 | |
| 408 | + wfRunHooks( 'RenameUserPreRename', array( $this->uid, $this->old, $this->new ) ); |
| 409 | + |
376 | 410 | $dbw = wfGetDB( DB_MASTER ); |
377 | 411 | // Rename and touch the user before re-attributing edits, |
378 | 412 | // this avoids users still being logged in and making new edits while |
Index: trunk/extensions/Renameuser/SpecialRenameuser.i18n.php |
— | — | @@ -8,13 +8,15 @@ |
9 | 9 | $messages = array(); |
10 | 10 | |
11 | 11 | $messages['en'] = array( |
12 | | - 'renameuser' => 'Rename user', |
13 | | - 'renameuser-desc' => 'Rename a user (need \'\'renameuser\'\' right)', |
14 | | - 'renameuserold' => 'Current username:', |
15 | | - 'renameusernew' => 'New username:', |
16 | | - 'renameuserreason' => 'Reason for rename:', |
17 | | - 'renameusermove' => 'Move user and talk pages (and their subpages) to new name', |
18 | | - 'renameusersubmit' => 'Submit', |
| 12 | + 'renameuser' => 'Rename user', |
| 13 | + 'renameuser-desc' => 'Rename a user (need \'\'renameuser\'\' right)', |
| 14 | + 'renameuserold' => 'Current username:', |
| 15 | + 'renameusernew' => 'New username:', |
| 16 | + 'renameuserreason' => 'Reason for rename:', |
| 17 | + 'renameusermove' => 'Move user and talk pages (and their subpages) to new name', |
| 18 | + 'renameuserwarnings' => 'Warnings:', |
| 19 | + 'renameuserconfirm' => 'Yes, rename the user', |
| 20 | + 'renameusersubmit' => 'Submit', |
19 | 21 | |
20 | 22 | 'renameusererrordoesnotexist' => 'The user "<nowiki>$1</nowiki>" does not exist.', |
21 | 23 | 'renameusererrorexists' => 'The user "<nowiki>$1</nowiki>" already exists.', |
Index: trunk/extensions/CentralAuth/CentralAuth.php |
— | — | @@ -166,7 +166,8 @@ |
167 | 167 | $wgHooks['getUserPermissionsErrorsExpensive'][] = 'CentralAuthHooks::onGetUserPermissionsErrorsExpensive'; |
168 | 168 | |
169 | 169 | // For interaction with the Special:Renameuser extension |
170 | | -$wgHooks['RenameUserAbort'][] = 'CentralAuthHooks::onRenameUserAbort'; |
| 170 | +$wgHooks['RenameUserWarning'][] = 'CentralAuthHooks::onRenameUserWarning'; |
| 171 | +$wgHooks['RenameUserPreRename'][] = 'CentralAuthHooks::onRenameUserPreRename'; |
171 | 172 | $wgHooks['RenameUserComplete'][] = 'CentralAuthHooks::onRenameUserComplete'; |
172 | 173 | |
173 | 174 | $wgAvailableRights[] = 'centralauth-admin'; |
Index: trunk/extensions/CentralAuth/CentralAuthHooks.php |
— | — | @@ -278,27 +278,31 @@ |
279 | 279 | /** |
280 | 280 | * Don't allow an attached local account to be renamed with the old system. |
281 | 281 | */ |
282 | | - static function onRenameUserAbort( $userId, $oldName, $newName ) { |
| 282 | + static function onRenameUserWarning( $oldName, $newName, &$warnings ) { |
283 | 283 | $oldCentral = new CentralAuthUser( $oldName ); |
284 | 284 | if ( $oldCentral->exists() && $oldCentral->isAttached() ) { |
285 | 285 | global $wgOut; |
286 | 286 | wfLoadExtensionMessages('SpecialCentralAuth'); |
287 | | - $wgOut->addWikiMsg( 'centralauth-renameuser-abort', $oldName, $newName ); |
| 287 | + $warnings[] = array( 'centralauth-renameuser-abort', $oldName, $newName ); |
288 | 288 | return false; |
289 | 289 | } |
290 | 290 | $newCentral = new CentralAuthUser( $newName ); |
291 | | - if ( $newCentral->exists() ) { |
| 291 | + if ( $newCentral->exists() && !$newCentral->isAttached() ) { |
292 | 292 | global $wgOut; |
293 | 293 | wfLoadExtensionMessages('SpecialCentralAuth'); |
294 | | - $wgOut->addWikiMsg( 'centralauth-renameuser-exists', $oldName, $newName ); |
295 | | - return false; |
| 294 | + $warnings[] = array( 'centralauth-renameuser-exists', $oldName, $newName ); |
296 | 295 | } |
| 296 | + return true; |
| 297 | + } |
297 | 298 | |
298 | | - // If no central record is present or this local account isn't attached, |
299 | | - // do as thou wilt. |
| 299 | + static function onRenameUserPreRename( $uid, $oldName, $newName ) { |
| 300 | + $oldCentral = new CentralAuthUser( $oldName ); |
| 301 | + if( $oldCentral->exists() && $oldCentral->isAttached() ) { |
| 302 | + $oldCentral->adminUnattach( array( wfWikiID() ) ); |
| 303 | + } |
300 | 304 | return true; |
301 | 305 | } |
302 | | - |
| 306 | + |
303 | 307 | /** |
304 | 308 | * When renaming an account, ensure that the presence records are updated. |
305 | 309 | */ |
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php |
— | — | @@ -209,8 +209,8 @@ |
210 | 210 | 'centralauth-prefs-manage' => 'Manage your global account', |
211 | 211 | |
212 | 212 | // Interaction with Special:Renameuser |
213 | | - 'centralauth-renameuser-abort' => "<div class=\"errorbox\">Cannot rename user $1 locally as this username has been migrated to the unified login system.</div>", |
214 | | - 'centralauth-renameuser-exists' => "<div class=\"errorbox\">Cannot rename user $2 as this username is reserved for a global account.</div>", |
| 213 | + 'centralauth-renameuser-abort' => "User $1 has been migrated to the unified login system. Renaming it will cause local user detached from the global one.", |
| 214 | + 'centralauth-renameuser-exists' => "User $2 is reserved for a global account.", |
215 | 215 | |
216 | 216 | // Other messages |
217 | 217 | 'centralauth-invalid-wiki' => 'No such wiki database: $1', |