Merge DisableAccount extension into core, disabled by default because the rights...
authorAndrew Garrett <werdna@users.mediawiki.org>
Thu, 2 Dec 2010 04:17:11 +0000 (04:17 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Thu, 2 Dec 2010 04:17:11 +0000 (04:17 +0000)
includes/AutoLoader.php
includes/SpecialPage.php
includes/specials/SpecialDisableAccount.php [new file with mode: 0644]
languages/messages/MessagesEn.php

index 5661375..0474aa2 100644 (file)
@@ -625,6 +625,7 @@ $wgAutoloadLocalClasses = array(
        'SpecialBookSources' => 'includes/specials/SpecialBooksources.php',
        'SpecialCategories' => 'includes/specials/SpecialCategories.php',
        'SpecialComparePages' => 'includes/specials/SpecialComparePages.php',
+       'SpecialDisableAccount' => 'includes/specials/SpecialDisableAccount.php',
        'SpecialExport' => 'includes/specials/SpecialExport.php',
        'SpecialFilepath' => 'includes/specials/SpecialFilepath.php',
        'SpecialImport' => 'includes/specials/SpecialImport.php',
index 35890dc..f678de3 100644 (file)
@@ -133,6 +133,7 @@ class SpecialPage {
                'Listbots'                  => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
                'Activeusers'               => 'SpecialActiveUsers',
                'Userrights'                => 'UserrightsPage',
+               'DisableAccount'            => 'SpecialDisableAccount',
 
                # Recent changes and logs
                'Newimages'                 => array( 'IncludableSpecialPage', 'Newimages' ),
diff --git a/includes/specials/SpecialDisableAccount.php b/includes/specials/SpecialDisableAccount.php
new file mode 100644 (file)
index 0000000..0df2159
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+
+class SpecialDisableAccount extends SpecialPage {
+       function __construct() {
+               parent::__construct( 'DisableAccount', 'disableaccount',
+                                       true, array( $this, 'show' ) );
+       }
+
+       public function show( $par ) {
+               $formFields = array(
+                       'account' => array(
+                               'type' => 'text',
+                               'validation-callback' => array( __CLASS__, 'validateUser' ),
+                               'label-message' => 'disableaccount-user',
+                       ),
+                       'confirm' => array(
+                               'type' => 'toggle',
+                               'validation-callback' => array( __CLASS__, 'checkConfirmation' ),
+                               'label-message' => 'disableaccount-confirm',
+                       ),
+               );
+
+               $htmlForm = new HTMLForm( $formFields, 'disableaccount' );
+
+               $htmlForm->setSubmitCallback( array( __CLASS__, 'submit' ) );
+               $htmlForm->setTitle( $this->getTitle() );
+
+               $htmlForm->show();
+       }
+
+       static function validateUser( $field, $allFields ) {
+               $u = User::newFromName( $field );
+
+               if ( $u && $u->getID() != 0 ) {
+                       return true;
+               } else {
+                       return wfMsgExt( 'disableaccount-nosuchuser', 'parseinline', array( $field ) );
+               }
+       }
+
+       static function checkConfirmation( $field, $allFields ) {
+               if ( $field ) {
+                       return true;
+               } else {
+                       return wfMsgExt( 'disableaccount-mustconfirm', 'parseinline' );
+               }
+       }
+
+       static function submit( $fields ) {
+               $user = User::newFromName( $fields['account'] );
+
+               $user->setPassword( null );
+               $user->setEmail( null );
+               $user->setToken();
+               $user->addGroup( 'inactive' );
+
+               $user->saveSettings();
+               $user->invalidateCache();
+
+               global $wgOut;
+               $wgOut->addWikiMsg( 'disableaccount-success', $user->getName() );
+
+               return true;
+       }
+}
\ No newline at end of file
index 6eef849..9dbdec5 100644 (file)
@@ -4359,4 +4359,16 @@ This site is experiencing technical difficulties.',
 'sqlite-has-fts' => '$1 with full-text search support',
 'sqlite-no-fts'  => '$1 without full-text search support',
 
+## Special:DisableAccount
+'disableaccount-desc' => 'Allows administrators to disable individual accounts.',
+'right-disableaccount' => 'Disable accounts',
+'disableaccount' => 'Disable a user account',
+'disableaccount-user' => 'User name:',
+'disableaccount-confirm' => "Disable this user account.
+The user will not be able to log in, reset their password, or receive email notifications.
+If the user is currently logged in anywhere, they will be immediately logged out.
+''Note that disabling an account is not reversible without system administrator intervention.''",
+'disableaccount-mustconfirm' => 'You must confirm that you wish to disable this account.',
+'disableaccount-nosuchuser' => 'The user account "$1" does not exist.',
+'disableaccount-success' => 'The user account "$1" has been permanently disabled.',
 );