r86151 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86150‎ | r86151 | r86152 >
Date:23:07, 15 April 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Revert r77561, bring back DisableAccount

Followup r86146
Modified paths:
  • /trunk/extensions/DisableAccount (added) (history)

Diff [purge]

Index: trunk/extensions/DisableAccount/DisableAccount.i18n.php
@@ -0,0 +1,17 @@
 2+<?php
 3+
 4+// Internationalisation file for the DisableAccount extension
 5+
 6+$messages['en'] = array(
 7+ 'disableaccount-desc' => 'Allows administrators to disable individual accounts.',
 8+ 'right-disableaccount' => 'Disable accounts',
 9+ 'disableaccount' => 'Disable a user account',
 10+ 'disableaccount-user' => 'User name:',
 11+ 'disableaccount-confirm' => "Disable this user account.
 12+The user will not be able to log in, reset their password, or receive email notifications.
 13+If the user is currently logged in anywhere, they will be immediately logged out.
 14+''Note that disabling an account is not reversible without system administrator intervention.''",
 15+ 'disableaccount-mustconfirm' => 'You must confirm that you wish to disable this account.',
 16+ 'disableaccount-nosuchuser' => 'The user account "$1" does not exist.',
 17+ 'disableaccount-success' => 'The user account "$1" has been permanently disabled.',
 18+);
\ No newline at end of file
Index: trunk/extensions/DisableAccount/DisableAccount.php
@@ -0,0 +1,17 @@
 2+<?php
 3+// DisableAccount extension: quick extension to disable an account.
 4+// Written by Andrew Garrett, 2010-12-02
 5+
 6+$wgExtensionCredits['other'][] = array(
 7+ 'path' => __FILE__,
 8+ 'name' => 'Disable Account',
 9+ 'author' => array( 'Andrew Garrett' ),
 10+ 'descriptionmsg' => 'disableaccount-desc',
 11+);
 12+
 13+$wgExtensionMessagesFiles['DisableAccount'] = dirname(__FILE__)."/DisableAccount.i18n.php";
 14+
 15+$wgAutoloadClasses['SpecialDisableAccount'] = dirname(__FILE__)."/SpecialDisableAccount.php";
 16+$wgSpecialPages['DisableAccount'] = 'SpecialDisableAccount';
 17+
 18+$wgAvailableRights[] = 'disableaccount';
Index: trunk/extensions/DisableAccount/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

Follow-up revisions

RevisionCommit summaryAuthorDate
r86152svn:eol-style native for r86151reedy23:09, 15 April 2011
r86205Followup r86151: Add extension to Translatewikiraymond13:28, 16 April 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r77561Remove DisableAccount extension, now in corewerdna06:58, 2 December 2010
r86146Revert r77555 and followups r77563, r77572, r78116 (merge DisableAccount to c...demon22:49, 15 April 2011

Comments

#Comment by P858snake (talk | contribs)   12:09, 26 April 2011

DisableAccount.php: $wgExtensionCredits should call url and point to http://www.mediawiki.org/wiki/Extension:DisableAccount

also Extension:DisableAccount should be created and documented.

Status & tagging log