'CreateAccount' => array( 'SpecialRedirectToSpecial', 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) ),
# Users and rights
- 'Blockip' => array( 'SpecialPage', 'Blockip', 'block' ),
+ 'Blockip' => 'IPBlockForm',
'Ipblocklist' => 'IPUnblockForm',
'Unblock' => array( 'SpecialRedirectToSpecial', 'Unblock', 'Ipblocklist', false, array( 'uselang', 'ip', 'id' ), array( 'action' => 'unblock' ) ),
'Resetpass' => 'SpecialResetpass',
*/
/**
- * Constructor for Special:Blockip page
+ * Implements Special:Blockip
*
- * @file
* @ingroup SpecialPage
*/
-function wfSpecialBlockip( $par ) {
- global $wgUser, $wgOut, $wgRequest;
+class IPBlockForm extends SpecialPage {
+ var $BlockAddress, $BlockExpiry, $BlockReason;
+ // The maximum number of edits a user can have and still be hidden
+ const HIDEUSER_CONTRIBLIMIT = 1000;
- # Can't block when the database is locked
- if( wfReadOnly() ) {
- $wgOut->readOnlyPage();
- return;
- }
- # Permission check
- if( !$wgUser->isAllowed( 'block' ) ) {
- $wgOut->permissionRequired( 'block' );
- return;
+ public function __construct() {
+ parent::__construct( 'Blockip', 'block' );
}
- $ipb = new IPBlockForm( $par );
+ public function execute( $par ) {
+ global $wgUser, $wgOut, $wgRequest;
+
+ # Can't block when the database is locked
+ if( wfReadOnly() ) {
+ $wgOut->readOnlyPage();
+ return;
+ }
+ # Permission check
+ if( !$this->userCanExecute( $wgUser ) ) {
+ $wgOut->permissionRequired( 'block' );
+ return;
+ }
+
+ $this->setup( $par );
- # bug 15810: blocked admins should have limited access here
- if ( $wgUser->isBlocked() ) {
- $status = IPBlockForm::checkUnblockSelf( $ipb->BlockAddress );
- if ( $status !== true ) {
- throw new ErrorPageError( 'badaccess', $status );
+ # bug 15810: blocked admins should have limited access here
+ if ( $wgUser->isBlocked() ) {
+ $status = IPBlockForm::checkUnblockSelf( $ipb->BlockAddress );
+ if ( $status !== true ) {
+ throw new ErrorPageError( 'badaccess', $status );
+ }
}
- }
- $action = $wgRequest->getVal( 'action' );
- if( 'success' == $action ) {
- $ipb->showSuccess();
- } elseif( $wgRequest->wasPosted() && 'submit' == $action &&
- $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
- $ipb->doSubmit();
- } else {
- $ipb->showForm( '' );
+ $action = $wgRequest->getVal( 'action' );
+ if( 'success' == $action ) {
+ $this->showSuccess();
+ } elseif( $wgRequest->wasPosted() && 'submit' == $action &&
+ $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
+ $this->doSubmit();
+ } else {
+ $this->showForm( '' );
+ }
}
-}
-
-/**
- * Form object for the Special:Blockip page.
- *
- * @ingroup SpecialPage
- */
-class IPBlockForm {
- var $BlockAddress, $BlockExpiry, $BlockReason;
- // The maximum number of edits a user can have and still be hidden
- const HIDEUSER_CONTRIBLIMIT = 1000;
- public function __construct( $par ) {
+ private function setup( $par ) {
global $wgRequest, $wgUser, $wgBlockAllowsUTEdit;
$this->BlockAddress = $wgRequest->getVal( 'wpBlockAddress', $wgRequest->getVal( 'ip', $par ) );