Revised design of Special:Userlogin
[lhc/web/wiklou.git] / includes / Title.php
index 6ac17d6..aa8fb93 100644 (file)
@@ -2049,8 +2049,38 @@ class Title {
                        // Don't block the user from editing their own talk page unless they've been
                        // explicitly blocked from that too.
                } elseif( $user->isBlocked() && $user->mBlock->prevents( $action ) !== false ) {
-                       // @todo FIXME: Pass the relevant context into this function.
-                       $errors[] = $user->getBlock()->getPermissionsError( RequestContext::getMain() );
+                       $block = $user->getBlock();
+
+                       // This is from OutputPage::blockedPage
+                       // Copied at r23888 by werdna
+
+                       $id = $user->blockedBy();
+                       $reason = $user->blockedFor();
+                       if ( $reason == '' ) {
+                               $reason = wfMessage( 'blockednoreason' )->text();
+                       }
+                       $ip = $user->getRequest()->getIP();
+
+                       if ( is_numeric( $id ) ) {
+                               $name = User::whoIs( $id );
+                       } else {
+                               $name = $id;
+                       }
+
+                       $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
+                       $blockid = $block->getId();
+                       $blockExpiry = $block->getExpiry();
+                       $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $block->mTimestamp ), true );
+                       if ( $blockExpiry == 'infinity' ) {
+                               $blockExpiry = wfMessage( 'infiniteblock' )->text();
+                       } else {
+                               $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
+                       }
+
+                       $intended = strval( $block->getTarget() );
+
+                       $errors[] = array( ( $block->mAuto ? 'autoblockedtext' : 'blockedtext' ), $link, $reason, $ip, $name,
+                               $blockid, $blockExpiry, $intended, $blockTimestamp );
                }
 
                return $errors;