Index: trunk/extensions/CentralAuth/SpecialMergeAccount.php |
— | — | @@ -56,6 +56,8 @@ |
57 | 57 | return $this->doInitialMerge(); |
58 | 58 | case "cleanup": |
59 | 59 | return $this->doCleanupMerge(); |
| 60 | + case "attach": |
| 61 | + return $this->doAttachMerge(); |
60 | 62 | case "remove": |
61 | 63 | return $this->doUnattach(); |
62 | 64 | default: |
— | — | @@ -65,7 +67,11 @@ |
66 | 68 | |
67 | 69 | $globalUser = new CentralAuthUser( $this->mUserName ); |
68 | 70 | if( $globalUser->exists() ) { |
69 | | - $this->showCleanupForm(); |
| 71 | + if( $globalUser->isAttached() ) { |
| 72 | + $this->showCleanupForm(); |
| 73 | + } else { |
| 74 | + $this->showAttachForm(); |
| 75 | + } |
70 | 76 | } else { |
71 | 77 | $this->showWelcomeForm(); |
72 | 78 | } |
— | — | @@ -274,6 +280,31 @@ |
275 | 281 | $this->showCleanupForm(); |
276 | 282 | } |
277 | 283 | |
| 284 | + function doAttachMerge() { |
| 285 | + global $wgUser, $wgRequest, $wgOut, $wgDBname, $wgCentralAuthDryRun; |
| 286 | + $globalUser = new CentralAuthUser( $wgUser->getName() ); |
| 287 | + |
| 288 | + if( !$globalUser->exists() ) { |
| 289 | + throw new MWException( "User doesn't exist -- race condition?" ); |
| 290 | + } |
| 291 | + |
| 292 | + if( $wgCentralAuthDryRun ) { |
| 293 | + return $this->dryRunError(); |
| 294 | + } |
| 295 | + $password = $wgRequest->getText( 'wpPassword' ); |
| 296 | + if( $globalUser->authenticate( $password ) == 'ok' ) { |
| 297 | + $globalUser->attach( $wgDBname, 'password' ); |
| 298 | + $wgOut->addWikiText( wfMsg( 'centralauth-attach-success' ) ); |
| 299 | + $this->showCleanupForm(); |
| 300 | + } else { |
| 301 | + $wgOut->addHtml( |
| 302 | + '<div class="errorbox">' . |
| 303 | + wfMsg( 'wrongpassword' ) . |
| 304 | + '</div>' . |
| 305 | + $this->attachActionForm() ); |
| 306 | + } |
| 307 | + } |
| 308 | + |
278 | 309 | private function showWelcomeForm() { |
279 | 310 | global $wgOut, $wgUser, $wgCentralAuthDryRun; |
280 | 311 | |
— | — | @@ -305,6 +336,15 @@ |
306 | 337 | $this->showStatus( $merged, $remainder ); |
307 | 338 | } |
308 | 339 | |
| 340 | + function showAttachForm() { |
| 341 | + global $wgOut, $wgUser; |
| 342 | + $globalUser = new CentralAuthUser( $wgUser->getName() ); |
| 343 | + $merged = $globalUser->listAttached(); |
| 344 | + $wgOut->addWikiText( wfMsg( 'centralauth-attach-list-attached', $this->mUserName ) ); |
| 345 | + $wgOut->addHtml( $this->listAttached( $merged ) ); |
| 346 | + $wgOut->addHtml( $this->attachActionForm() ); |
| 347 | + } |
| 348 | + |
309 | 349 | function showStatus( $merged, $remainder ) { |
310 | 350 | global $wgOut; |
311 | 351 | |
— | — | @@ -483,6 +523,14 @@ |
484 | 524 | ); |
485 | 525 | } |
486 | 526 | |
| 527 | + private function attachActionForm() { |
| 528 | + return $this->passwordForm( |
| 529 | + 'attach', |
| 530 | + wfMsg( 'centralauth-attach-title' ), |
| 531 | + wfMsg( 'centralauth-attach-text' ), |
| 532 | + wfMsg( 'centralauth-attach-submit' ) ); |
| 533 | + } |
| 534 | + |
487 | 535 | private function dryRunError() { |
488 | 536 | global $wgOut; |
489 | 537 | $wgOut->addWikiText( wfMsg( 'centralauth-disabled-dryrun' ) ); |
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php |
— | — | @@ -130,6 +130,13 @@ |
131 | 131 | 'centralauth-merge-attempt' => |
132 | 132 | "'''Checking provided password against remaining unmerged accounts...'''", |
133 | 133 | |
| 134 | + # When unattached, offer to attach... |
| 135 | + 'centralauth-attach-list-attached' => 'The unified account named "$1" includes the following accounts:', |
| 136 | + 'centralauth-attach-title' => 'Confirm account', |
| 137 | + 'centralauth-attach-text' => 'This account has not yet been migrated to the unified account. If the global account is yours too, you can merge this account if you type the global account password:', |
| 138 | + 'centralauth-attach-submit' => 'Migrate account', |
| 139 | + 'centralauth-attach-success' => 'The account was migrated to the unified account.', |
| 140 | + |
134 | 141 | // Administrator's console |
135 | 142 | 'centralauth' => 'Unified login administration', |
136 | 143 | 'centralauth-admin-manage' => |
— | — | @@ -653,6 +660,13 @@ |
654 | 661 | |
655 | 662 | 'centralauth-merge-attempt' => "'''בודק האם הסיסמאות שניתנו תואמים לחשבונות הנותרים שלא מוזגו...'''", |
656 | 663 | |
| 664 | + # When unattached, offer to attach... |
| 665 | + 'centralauth-attach-list-attached' => 'החשבון הממוזג בשם המשתמש "$1" כולל את החשבונות הבאים:', |
| 666 | + 'centralauth-attach-title' => 'אימות החשבון', |
| 667 | + 'centralauth-attach-text' => 'חשבון זה לא נוסף עדיין לחשבון הממוזג. אם גם החשבון הממוזג שייך לכם, באפשרותכם למזג חשבון זה פשוט על־ידי הקלדת סיסמת החשבון הכללי:', |
| 668 | + 'centralauth-attach-submit' => 'מיזוג החשבון', |
| 669 | + 'centralauth-attach-success' => 'החשבון נוסף לחשבון הממוזג.', |
| 670 | + |
657 | 671 | # Administrator's console |
658 | 672 | 'centralauth' => 'ניהול מיזוג החשבונות', |
659 | 673 | 'centralauth-admin-manage' => 'ניהול המידע על המשתמש', |