3 class SpecialDisableAccount
extends SpecialPage
{
4 function __construct() {
5 parent
::__construct( 'DisableAccount', 'disableaccount',
6 true, array( $this, 'show' ) );
9 public function show( $par ) {
13 'validation-callback' => array( __CLASS__
, 'validateUser' ),
14 'label-message' => 'disableaccount-user',
18 'label-message' => 'disableaccount-reason',
22 'validation-callback' => array( __CLASS__
, 'checkConfirmation' ),
23 'label-message' => 'disableaccount-confirm',
27 $htmlForm = new HTMLForm( $formFields, 'disableaccount' );
29 $htmlForm->setSubmitCallback( array( __CLASS__
, 'submit' ) );
30 $htmlForm->setTitle( $this->getTitle() );
35 static function validateUser( $field, $allFields ) {
36 $u = User
::newFromName( $field );
38 if ( $u && $u->getID() != 0 ) {
41 return wfMsgExt( 'disableaccount-nosuchuser', 'parseinline', array( $field ) );
45 static function checkConfirmation( $field, $allFields ) {
49 return wfMsgExt( 'disableaccount-mustconfirm', 'parseinline' );
53 static function submit( $fields ) {
54 $user = User
::newFromName( $fields['account'] );
56 $user->setPassword( null );
57 $user->setEmail( null );
59 $user->addGroup( 'inactive' );
61 $user->saveSettings();
62 $user->invalidateCache();
64 $logPage = new LogPage( 'rights' );
66 $logPage->addEntry( 'disable', $user->getUserPage(), $fields['comment'] );
69 $wgOut->addWikiMsg( 'disableaccount-success', $user->getName() );