Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -1933,53 +1933,10 @@ |
1934 | 1934 | |
1935 | 1935 | /** |
1936 | 1936 | * Produce a "user is blocked" page. |
1937 | | - * |
1938 | | - * @param $return Boolean: whether to have a "return to $wgTitle" message or not. |
1939 | | - * @return nothing |
| 1937 | + * @deprecated since 1.18 |
1940 | 1938 | */ |
1941 | | - function blockedPage( $return = true ) { |
1942 | | - global $wgContLang; |
1943 | | - |
1944 | | - $this->setPageTitle( wfMsg( 'blockedtitle' ) ); |
1945 | | - $this->setRobotPolicy( 'noindex,nofollow' ); |
1946 | | - $this->setArticleRelated( false ); |
1947 | | - |
1948 | | - $name = $this->getUser()->blockedBy(); |
1949 | | - $reason = $this->getUser()->blockedFor(); |
1950 | | - if( $reason == '' ) { |
1951 | | - $reason = wfMsg( 'blockednoreason' ); |
1952 | | - } |
1953 | | - $blockTimestamp = $this->getContext()->getLang()->timeanddate( |
1954 | | - wfTimestamp( TS_MW, $this->getUser()->mBlock->mTimestamp ), true |
1955 | | - ); |
1956 | | - $ip = wfGetIP(); |
1957 | | - |
1958 | | - $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]"; |
1959 | | - |
1960 | | - $blockid = $this->getUser()->mBlock->getId(); |
1961 | | - |
1962 | | - $blockExpiry = $this->getContext()->getLang()->formatExpiry( $this->getUser()->mBlock->mExpiry ); |
1963 | | - |
1964 | | - if ( $this->getUser()->mBlock->mAuto ) { |
1965 | | - $msg = 'autoblockedtext'; |
1966 | | - } else { |
1967 | | - $msg = 'blockedtext'; |
1968 | | - } |
1969 | | - |
1970 | | - /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked. |
1971 | | - * This could be a username, an IP range, or a single IP. */ |
1972 | | - $intended = $this->getUser()->mBlock->getTarget(); |
1973 | | - |
1974 | | - $this->addWikiMsg( |
1975 | | - $msg, $link, $reason, $ip, $name, $blockid, $blockExpiry, |
1976 | | - $intended, $blockTimestamp |
1977 | | - ); |
1978 | | - |
1979 | | - # Don't auto-return to special pages |
1980 | | - if( $return ) { |
1981 | | - $return = $this->getTitle()->getNamespace() > -1 ? $this->getTitle() : null; |
1982 | | - $this->returnToMain( null, $return ); |
1983 | | - } |
| 1939 | + function blockedPage() { |
| 1940 | + throw new UserBlockedError( $this->getUser()->mBlock ); |
1984 | 1941 | } |
1985 | 1942 | |
1986 | 1943 | /** |
— | — | @@ -2163,9 +2120,7 @@ |
2164 | 2121 | $this->addWikiText( $this->formatPermissionsErrorMessage( $reasons, $action ) ); |
2165 | 2122 | } else { |
2166 | 2123 | // Wiki is read only |
2167 | | - $this->setPageTitle( wfMsg( 'readonly' ) ); |
2168 | | - $reason = wfReadOnlyReason(); |
2169 | | - $this->wrapWikiMsg( "<div class='mw-readonly-error'>\n$1\n</div>", array( 'readonlytext', $reason ) ); |
| 2124 | + throw new ReadOnlyError; |
2170 | 2125 | } |
2171 | 2126 | |
2172 | 2127 | // Show source, if supplied |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -196,6 +196,7 @@ |
197 | 197 | 'RawPage' => 'includes/RawPage.php', |
198 | 198 | 'RCCacheEntry' => 'includes/ChangesList.php', |
199 | 199 | 'RdfMetaData' => 'includes/Metadata.php', |
| 200 | + 'ReadOnlyError' => 'includes/Exception.php', |
200 | 201 | 'RecentChange' => 'includes/RecentChange.php', |
201 | 202 | 'RegexlikeReplacer' => 'includes/StringUtils.php', |
202 | 203 | 'ReplacementArray' => 'includes/StringUtils.php', |
— | — | @@ -249,6 +250,7 @@ |
250 | 251 | 'User' => 'includes/User.php', |
251 | 252 | 'UserArray' => 'includes/UserArray.php', |
252 | 253 | 'UserArrayFromResult' => 'includes/UserArray.php', |
| 254 | + 'UserBlockedError' => 'includes/Exception.php', |
253 | 255 | 'UserMailer' => 'includes/UserMailer.php', |
254 | 256 | 'UserRightsProxy' => 'includes/UserRightsProxy.php', |
255 | 257 | 'ViewCountUpdate' => 'includes/ViewCountUpdate.php', |
Index: trunk/phase3/includes/Exception.php |
— | — | @@ -371,6 +371,56 @@ |
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
| 375 | + * Show an error when the wiki is locked/read-only and the user tries to do |
| 376 | + * something that requires write access |
| 377 | + */ |
| 378 | +class ReadOnlyError extends ErrorPageError { |
| 379 | + public function __construct(){ |
| 380 | + parent::__construct( |
| 381 | + 'readonly', |
| 382 | + 'readonlytext', |
| 383 | + wfReadOnlyReason() |
| 384 | + ); |
| 385 | + } |
| 386 | +} |
| 387 | + |
| 388 | +/** |
| 389 | + * Show an error when the user tries to do something whilst blocked |
| 390 | + */ |
| 391 | +class UserBlockedError extends ErrorPageError { |
| 392 | + public function __construct( Block $block ){ |
| 393 | + global $wgLang; |
| 394 | + |
| 395 | + $blockerUserpage = $block->getBlocker()->getUserPage(); |
| 396 | + $link = "[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]"; |
| 397 | + |
| 398 | + $reason = $block->mReason; |
| 399 | + if( $reason == '' ) { |
| 400 | + $reason = wfMsg( 'blockednoreason' ); |
| 401 | + } |
| 402 | + |
| 403 | + /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked. |
| 404 | + * This could be a username, an IP range, or a single IP. */ |
| 405 | + $intended = $block->getTarget(); |
| 406 | + |
| 407 | + parent::__construct( |
| 408 | + 'blockedtitle', |
| 409 | + $block->mAuto ? 'autoblocketext' : 'blockedtext', |
| 410 | + array( |
| 411 | + $link, |
| 412 | + $reason, |
| 413 | + wfGetIP(), |
| 414 | + $block->getBlocker()->getName(), |
| 415 | + $block->getId(), |
| 416 | + $wgLang->formatExpiry( $block->mExpiry ), |
| 417 | + $intended, |
| 418 | + $wgLang->timeanddate( wfTimestamp( TS_MW, $block->mTimestamp ), true ) |
| 419 | + ) |
| 420 | + ); |
| 421 | + } |
| 422 | +} |
| 423 | + |
| 424 | +/** |
375 | 425 | * Install an exception handler for MediaWiki exception types. |
376 | 426 | */ |
377 | 427 | function wfInstallExceptionHandler() { |