$permErrors = $this->getEditPermissionErrors();
if ( $permErrors ) {
+ // Auto-block user's IP if the account was "hard" blocked
+ $wgUser->spreadAnyEditBlock();
+
wfDebug( __METHOD__ . ": User can't edit\n" );
$content = $this->getContent( null );
$content = $content === '' ? null : $content;
$this->mBlockreason = $this->mBlock->mReason;
$this->mHideName = $this->mBlock->mHideName;
$this->mAllowUsertalk = !$this->mBlock->prevents( 'editownusertalk' );
- if ( $this->isLoggedIn() && $wgUser->getID() == $this->getID() ) {
- $this->spreadBlock();
- }
}
# Proxy blocking
}
/**
- * If this (non-anonymous) user is blocked, block any IP address
- * they've successfully logged in from.
+ * If this user is logged-in and blocked,
+ * block any IP address they've successfully logged in from.
+ * @return bool A block was spread
*/
- public function spreadBlock() {
+ public function spreadAnyEditBlock() {
+ if ( $this->isLoggedIn() && $this->isBlocked() ) {
+ return $this->spreadBlock();
+ }
+ return false;
+ }
+
+ /**
+ * If this (non-anonymous) user is blocked,
+ * block the IP address they've successfully logged in from.
+ * @return bool A block was spread
+ */
+ protected function spreadBlock() {
wfDebug( __METHOD__ . "()\n" );
$this->load();
if ( $this->mId == 0 ) {
- return;
+ return false;
}
$userblock = Block::newFromTarget( $this->getName() );
if ( !$userblock ) {
- return;
+ return false;
}
- $userblock->doAutoblock( $this->getRequest()->getIP() );
+ return (bool)$userblock->doAutoblock( $this->getRequest()->getIP() );
}
/**
# Check rights
$permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $user );
if( !empty( $permErrors ) ) {
+ // Auto-block user's IP if the account was "hard" blocked
+ $user->spreadAnyEditBlock();
$this->getOutput()->showPermissionsErrorPage( $permErrors );
return;
}