Revert r93237 ("use User::getBlock() accessor rather than accessing $mBlock directly...
authorRoan Kattouw <catrope@users.mediawiki.org>
Wed, 27 Jul 2011 22:28:59 +0000 (22:28 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Wed, 27 Jul 2011 22:28:59 +0000 (22:28 +0000)
includes/Action.php
includes/OutputPage.php
includes/SpecialPage.php
includes/Title.php
includes/User.php
includes/specials/SpecialEmailuser.php
includes/specials/SpecialUserlogin.php

index 6a62fb6..ff0ce69 100644 (file)
@@ -198,7 +198,8 @@ abstract class Action {
                }
 
                if ( $this->requiresUnblock() && $user->isBlocked() ) {
-                       throw new UserBlockedError( $user->getBlock() );
+                       $block = $user->mBlock;
+                       throw new UserBlockedError( $block );
                }
        }
 
index dcd0675..067158b 100644 (file)
@@ -1934,7 +1934,7 @@ class OutputPage {
         * @deprecated since 1.18
         */
        function blockedPage() {
-               throw new UserBlockedError( $this->getUser()->getBlock() );
+               throw new UserBlockedError( $this->getUser()->mBlock );
        }
 
        /**
index 9984ac0..fbcd25e 100644 (file)
@@ -825,7 +825,8 @@ abstract class FormSpecialPage extends SpecialPage {
                }
 
                if ( $this->requiresUnblock() && $user->isBlocked() ) {
-                       throw new UserBlockedError( $user->getBlock() );
+                       $block = $user->mBlock;
+                       throw new UserBlockedError( $block );
                }
 
                return true;
index 76519d0..a774404 100644 (file)
@@ -1565,11 +1565,39 @@ class Title {
                } elseif( ( $action == 'edit' || $action == 'create' ) && !$user->isBlockedFrom( $this ) ){
                        // Don't block the user from editing their own talk page unless they've been
                        // explicitly blocked from that too.
-               } elseif( $user->isBlocked() && $user->getBlock()->prevents( $action ) !== false ) {
-                       $e = new UserBlockedError( $user->getBlock() );
-                       $params = $e->params;
-                       array_unshift( $params, $e->msg );
-                       $errors[] = $params;
+               } elseif( $user->isBlocked() && $user->mBlock->prevents( $action ) !== false ) {
+                       $block = $user->mBlock;
+
+                       // This is from OutputPage::blockedPage
+                       // Copied at r23888 by werdna
+
+                       $id = $user->blockedBy();
+                       $reason = $user->blockedFor();
+                       if ( $reason == '' ) {
+                               $reason = wfMsg( 'blockednoreason' );
+                       }
+                       $ip = wfGetIP();
+
+                       if ( is_numeric( $id ) ) {
+                               $name = User::whoIs( $id );
+                       } else {
+                               $name = $id;
+                       }
+
+                       $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
+                       $blockid = $block->getId();
+                       $blockExpiry = $user->mBlock->mExpiry;
+                       $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $user->mBlock->mTimestamp ), true );
+                       if ( $blockExpiry == 'infinity' ) {
+                               $blockExpiry = wfMessage( 'infiniteblock' )->text();
+                       } else {
+                               $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
+                       }
+
+                       $intended = strval( $user->mBlock->getTarget() );
+
+                       $errors[] = array( ( $block->mAuto ? 'autoblockedtext' : 'blockedtext' ), $link, $reason, $ip, $name,
+                               $blockid, $blockExpiry, $intended, $blockTimestamp );
                }
 
                return $errors;
index 4d9b4c7..a160e93 100644 (file)
@@ -1265,14 +1265,13 @@ class User {
                }
 
                # User/IP blocking
-               $block = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave );
-               if ( $block instanceof Block ) {
+               $this->mBlock = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave );
+               if ( $this->mBlock instanceof Block ) {
                        wfDebug( __METHOD__ . ": Found block.\n" );
-                       $this->mBlock = $block;
-                       $this->mBlockedby = $block->getByName();
-                       $this->mBlockreason = $block->mReason;
-                       $this->mHideName = $block->mHideName;
-                       $this->mAllowUsertalk = !$block->prevents( 'editownusertalk' );
+                       $this->mBlockedby = $this->mBlock->getByName();
+                       $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();
                        }
index 509f7fc..52501e4 100644 (file)
@@ -99,7 +99,7 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                        case 'badaccess':
                                throw new PermissionsError( 'sendemail' );
                        case 'blockedemailuser':
-                               throw new UserBlockedError( $this->getUser()->getBlock() );
+                               throw new UserBlockedError( $this->getUser()->mBlock );
                        case 'actionthrottledtext':
                                throw new ThrottledError;
                        case 'mailnologin':
index bed5a14..a933041 100644 (file)
@@ -746,7 +746,7 @@ class LoginForm extends SpecialPage {
                                $this->resetLoginForm( wfMsg( 'resetpass_announce' ) );
                                break;
                        case self::CREATE_BLOCKED:
-                               $this->userBlockedMessage( $wgUser->getBlock() );
+                               $this->userBlockedMessage( $wgUser->mBlock );
                                break;
                        case self::THROTTLED:
                                $this->mainLoginForm( wfMsg( 'login-throttled' ) );