}
public function execute( $par ){
- # Check permissions
- if( !$this->userCanExecute( $this->getUser() ) ) {
- $this->displayRestrictionError();
- return;
- }
-
- # Check for database lock
- if( wfReadOnly() ) {
- throw new ReadOnlyError;
- }
+ $this->checkPermissions();
+ $this->checkReadOnly();
list( $this->target, $this->type ) = SpecialBlock::getTargetAndType( $par, $this->getRequest() );
$this->block = Block::newFromTarget( $this->target );
$form = new HTMLForm( $this->getFields(), $this->getContext() );
$form->setWrapperLegend( wfMsg( 'unblockip' ) );
- $form->setSubmitCallback( array( __CLASS__, 'processUnblock' ) );
+ $form->setSubmitCallback( array( __CLASS__, 'processUIUnblock' ) );
$form->setSubmitText( wfMsg( 'ipusubmit' ) );
$form->addPreText( wfMsgExt( 'unblockiptext', 'parse' ) );
return $fields;
}
+ /**
+ * Submit callback for an HTMLForm object
+ */
+ public static function processUIUnblock( array $data, HTMLForm $form ) {
+ return self::processUnblock( $data, $form->getContext() );
+ }
+
/**
* Process the form
+ *
+ * @param $data Array
+ * @param $context IContextSource
* @return Array( Array(message key, parameters) ) on failure, True on success
*/
- public static function processUnblock( array $data ){
- global $wgUser;
-
+ public static function processUnblock( array $data, IContextSource $context ){
+ $performer = $context->getUser();
$target = $data['Target'];
$block = Block::newFromTarget( $data['Target'] );
# bug 15810: blocked admins should have limited access here. This
# won't allow sysops to remove autoblocks on themselves, but they
# should have ipblock-exempt anyway
- $status = SpecialBlock::checkUnblockSelf( $target );
+ $status = SpecialBlock::checkUnblockSelf( $target, $performer );
if ( $status !== true ) {
throw new ErrorPageError( 'badaccess', $status );
}
# If the name was hidden and the blocking user cannot hide
# names, then don't allow any block removals...
- if( !$wgUser->isAllowed( 'hideuser' ) && $block->mHideName ) {
+ if( !$performer->isAllowed( 'hideuser' ) && $block->mHideName ) {
return array( 'unblock-hideuser' );
}