Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -625,6 +625,7 @@ |
626 | 626 | 'SpecialBookSources' => 'includes/specials/SpecialBooksources.php', |
627 | 627 | 'SpecialCategories' => 'includes/specials/SpecialCategories.php', |
628 | 628 | 'SpecialComparePages' => 'includes/specials/SpecialComparePages.php', |
| 629 | + 'SpecialDisableAccount' => 'includes/specials/SpecialDisableAccount.php', |
629 | 630 | 'SpecialExport' => 'includes/specials/SpecialExport.php', |
630 | 631 | 'SpecialFilepath' => 'includes/specials/SpecialFilepath.php', |
631 | 632 | 'SpecialImport' => 'includes/specials/SpecialImport.php', |
Index: trunk/phase3/includes/specials/SpecialDisableAccount.php |
— | — | @@ -0,0 +1,65 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class SpecialDisableAccount extends SpecialPage { |
| 5 | + function __construct() { |
| 6 | + parent::__construct( 'DisableAccount', 'disableaccount', |
| 7 | + true, array( $this, 'show' ) ); |
| 8 | + } |
| 9 | + |
| 10 | + public function show( $par ) { |
| 11 | + $formFields = array( |
| 12 | + 'account' => array( |
| 13 | + 'type' => 'text', |
| 14 | + 'validation-callback' => array( __CLASS__, 'validateUser' ), |
| 15 | + 'label-message' => 'disableaccount-user', |
| 16 | + ), |
| 17 | + 'confirm' => array( |
| 18 | + 'type' => 'toggle', |
| 19 | + 'validation-callback' => array( __CLASS__, 'checkConfirmation' ), |
| 20 | + 'label-message' => 'disableaccount-confirm', |
| 21 | + ), |
| 22 | + ); |
| 23 | + |
| 24 | + $htmlForm = new HTMLForm( $formFields, 'disableaccount' ); |
| 25 | + |
| 26 | + $htmlForm->setSubmitCallback( array( __CLASS__, 'submit' ) ); |
| 27 | + $htmlForm->setTitle( $this->getTitle() ); |
| 28 | + |
| 29 | + $htmlForm->show(); |
| 30 | + } |
| 31 | + |
| 32 | + static function validateUser( $field, $allFields ) { |
| 33 | + $u = User::newFromName( $field ); |
| 34 | + |
| 35 | + if ( $u && $u->getID() != 0 ) { |
| 36 | + return true; |
| 37 | + } else { |
| 38 | + return wfMsgExt( 'disableaccount-nosuchuser', 'parseinline', array( $field ) ); |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + static function checkConfirmation( $field, $allFields ) { |
| 43 | + if ( $field ) { |
| 44 | + return true; |
| 45 | + } else { |
| 46 | + return wfMsgExt( 'disableaccount-mustconfirm', 'parseinline' ); |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + static function submit( $fields ) { |
| 51 | + $user = User::newFromName( $fields['account'] ); |
| 52 | + |
| 53 | + $user->setPassword( null ); |
| 54 | + $user->setEmail( null ); |
| 55 | + $user->setToken(); |
| 56 | + $user->addGroup( 'inactive' ); |
| 57 | + |
| 58 | + $user->saveSettings(); |
| 59 | + $user->invalidateCache(); |
| 60 | + |
| 61 | + global $wgOut; |
| 62 | + $wgOut->addWikiMsg( 'disableaccount-success', $user->getName() ); |
| 63 | + |
| 64 | + return true; |
| 65 | + } |
| 66 | +} |
\ No newline at end of file |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -133,6 +133,7 @@ |
134 | 134 | 'Listbots' => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ), |
135 | 135 | 'Activeusers' => 'SpecialActiveUsers', |
136 | 136 | 'Userrights' => 'UserrightsPage', |
| 137 | + 'DisableAccount' => 'SpecialDisableAccount', |
137 | 138 | |
138 | 139 | # Recent changes and logs |
139 | 140 | 'Newimages' => array( 'IncludableSpecialPage', 'Newimages' ), |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -4359,4 +4359,16 @@ |
4360 | 4360 | 'sqlite-has-fts' => '$1 with full-text search support', |
4361 | 4361 | 'sqlite-no-fts' => '$1 without full-text search support', |
4362 | 4362 | |
| 4363 | +## Special:DisableAccount |
| 4364 | +'disableaccount-desc' => 'Allows administrators to disable individual accounts.', |
| 4365 | +'right-disableaccount' => 'Disable accounts', |
| 4366 | +'disableaccount' => 'Disable a user account', |
| 4367 | +'disableaccount-user' => 'User name:', |
| 4368 | +'disableaccount-confirm' => "Disable this user account. |
| 4369 | +The user will not be able to log in, reset their password, or receive email notifications. |
| 4370 | +If the user is currently logged in anywhere, they will be immediately logged out. |
| 4371 | +''Note that disabling an account is not reversible without system administrator intervention.''", |
| 4372 | +'disableaccount-mustconfirm' => 'You must confirm that you wish to disable this account.', |
| 4373 | +'disableaccount-nosuchuser' => 'The user account "$1" does not exist.', |
| 4374 | +'disableaccount-success' => 'The user account "$1" has been permanently disabled.', |
4363 | 4375 | ); |