From a37cfd454b3f6511da423eae2cf15bccfb065d88 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sun, 1 Aug 2010 12:14:32 +0000 Subject: [PATCH] * Modified Special:Blockip to subclass SpecialPage --- includes/SpecialPage.php | 2 +- includes/specials/SpecialBlockip.php | 78 ++++++++++++++-------------- 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index ca58b7f9e4..4e62dc5a11 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -120,7 +120,7 @@ class SpecialPage { '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', diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index 837d83ce4e..cbbbfb7697 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -18,57 +18,55 @@ */ /** - * 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 ) ); -- 2.20.1