Index: trunk/extensions/Renameuser/SpecialRenameuser_body.php |
— | — | @@ -175,6 +175,11 @@ |
176 | 176 | return; |
177 | 177 | } |
178 | 178 | } |
| 179 | + |
| 180 | + // Give other affected extensions a chance to validate or abort |
| 181 | + if( !wfRunHooks( 'RenameUserAbort', array( $uid, $oldusername->getText(), $newusername->getText() ) ) ) { |
| 182 | + return; |
| 183 | + } |
179 | 184 | |
180 | 185 | $rename = new RenameuserSQL( $oldusername->getText(), $newusername->getText(), $uid ); |
181 | 186 | $rename->rename(); |
— | — | @@ -384,6 +389,7 @@ |
385 | 390 | $user = User::newFromId( $this->uid ); |
386 | 391 | $user->invalidateCache(); |
387 | 392 | $wgAuth->updateExternalDB( $user ); |
| 393 | + wfRunHooks( 'RenameUserComplete', array( $this->uid, $this->old, $this->new ) ); |
388 | 394 | |
389 | 395 | wfProfileOut( __METHOD__ ); |
390 | 396 | } |
Index: trunk/extensions/CentralAuth/CentralAuth.php |
— | — | @@ -44,6 +44,10 @@ |
45 | 45 | $wgHooks['AddNewAccount'][] = 'wfCentralAuthAddNewAccount'; |
46 | 46 | $wgHooks['PreferencesUserInformationPanel'][] = 'wfCentralAuthInformationPanel'; |
47 | 47 | |
| 48 | +// For interaction with the Special:Renameuser extension |
| 49 | +$wgHooks['RenameUserAbort'][] = 'wfCentralAuthRenameUserAbort'; |
| 50 | +$wgHooks['RenameUserComplete'][] = 'wfCentralAuthRenameUserComplete'; |
| 51 | + |
48 | 52 | $wgGroupPermissions['steward']['centralauth-admin'] = true; |
49 | 53 | |
50 | 54 | $wgSpecialPages['CentralAuth'] = 'SpecialCentralAuth'; |
— | — | @@ -125,3 +129,32 @@ |
126 | 130 | $central->addLocalName( $wgDBname ); |
127 | 131 | return true; |
128 | 132 | } |
| 133 | + |
| 134 | +/** |
| 135 | + * Don't allow an attached local account to be renamed with the old system. |
| 136 | + */ |
| 137 | +function wfCentralAuthRenameUserAbort( $userId, $oldName, $newName ) { |
| 138 | + $central = new CentralAuthUser( $oldName ); |
| 139 | + if( $central->exists() && $central->isAttached() ) { |
| 140 | + global $wgOut; |
| 141 | + $wgOut->addWikiText( wfMsg( 'centralauth-renameuser-abort', $oldName ) ); |
| 142 | + return false; |
| 143 | + } |
| 144 | + |
| 145 | + // If no central record is present or this local account isn't attached, |
| 146 | + // do as thou wilt. |
| 147 | + return true; |
| 148 | +} |
| 149 | + |
| 150 | +/** |
| 151 | + * When renaming an account, ensure that the presence records are updated. |
| 152 | + */ |
| 153 | +function wfCentralAuthRenameUserComplete( $userId, $oldName, $newName ) { |
| 154 | + global $wgDBname; |
| 155 | + |
| 156 | + $oldCentral = new CentralAuthUser( $oldName ); |
| 157 | + $oldCentral->removeLocalName( $wgDBname ); |
| 158 | + |
| 159 | + $newCentral = new CentralAuthUser( $newName ); |
| 160 | + $newCentral->addLocalName( $wgDBname ); |
| 161 | +} |
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php |
— | — | @@ -186,6 +186,12 @@ |
187 | 187 | 'centralauth-prefs-manage' => |
188 | 188 | 'Manage your global account', |
189 | 189 | |
| 190 | + // Interaction with Special:Renameuser |
| 191 | + 'centralauth-renameuser-abort' => |
| 192 | + "<div class=\"errorbox\">" . |
| 193 | + "Cannot rename user $1 locally as this username has been migrated to the " . |
| 194 | + "unified login system.</div>", |
| 195 | + |
190 | 196 | ); |
191 | 197 | |
192 | 198 | /* Arabic (Meno25) */ |