'RawPage' => 'includes/RawPage.php',
'RCCacheEntry' => 'includes/ChangesList.php',
'RdfMetaData' => 'includes/Metadata.php',
+ 'ReadOnlyError' => 'includes/Exception.php',
'RecentChange' => 'includes/RecentChange.php',
'RegexlikeReplacer' => 'includes/StringUtils.php',
'ReplacementArray' => 'includes/StringUtils.php',
'User' => 'includes/User.php',
'UserArray' => 'includes/UserArray.php',
'UserArrayFromResult' => 'includes/UserArray.php',
+ 'UserBlockedError' => 'includes/Exception.php',
'UserMailer' => 'includes/UserMailer.php',
'UserRightsProxy' => 'includes/UserRightsProxy.php',
'ViewCountUpdate' => 'includes/ViewCountUpdate.php',
}
}
+/**
+ * Show an error when the wiki is locked/read-only and the user tries to do
+ * something that requires write access
+ */
+class ReadOnlyError extends ErrorPageError {
+ public function __construct(){
+ parent::__construct(
+ 'readonly',
+ 'readonlytext',
+ wfReadOnlyReason()
+ );
+ }
+}
+
+/**
+ * Show an error when the user tries to do something whilst blocked
+ */
+class UserBlockedError extends ErrorPageError {
+ public function __construct( Block $block ){
+ global $wgLang;
+
+ $blockerUserpage = $block->getBlocker()->getUserPage();
+ $link = "[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]";
+
+ $reason = $block->mReason;
+ if( $reason == '' ) {
+ $reason = wfMsg( 'blockednoreason' );
+ }
+
+ /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
+ * This could be a username, an IP range, or a single IP. */
+ $intended = $block->getTarget();
+
+ parent::__construct(
+ 'blockedtitle',
+ $block->mAuto ? 'autoblocketext' : 'blockedtext',
+ array(
+ $link,
+ $reason,
+ wfGetIP(),
+ $block->getBlocker()->getName(),
+ $block->getId(),
+ $wgLang->formatExpiry( $block->mExpiry ),
+ $intended,
+ $wgLang->timeanddate( wfTimestamp( TS_MW, $block->mTimestamp ), true )
+ )
+ );
+ }
+}
+
/**
* Install an exception handler for MediaWiki exception types.
*/
/**
* Produce a "user is blocked" page.
- *
- * @param $return Boolean: whether to have a "return to $wgTitle" message or not.
- * @return nothing
+ * @deprecated since 1.18
*/
- function blockedPage( $return = true ) {
- global $wgContLang;
-
- $this->setPageTitle( wfMsg( 'blockedtitle' ) );
- $this->setRobotPolicy( 'noindex,nofollow' );
- $this->setArticleRelated( false );
-
- $name = $this->getUser()->blockedBy();
- $reason = $this->getUser()->blockedFor();
- if( $reason == '' ) {
- $reason = wfMsg( 'blockednoreason' );
- }
- $blockTimestamp = $this->getContext()->getLang()->timeanddate(
- wfTimestamp( TS_MW, $this->getUser()->mBlock->mTimestamp ), true
- );
- $ip = wfGetIP();
-
- $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
-
- $blockid = $this->getUser()->mBlock->getId();
-
- $blockExpiry = $this->getContext()->getLang()->formatExpiry( $this->getUser()->mBlock->mExpiry );
-
- if ( $this->getUser()->mBlock->mAuto ) {
- $msg = 'autoblockedtext';
- } else {
- $msg = 'blockedtext';
- }
-
- /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
- * This could be a username, an IP range, or a single IP. */
- $intended = $this->getUser()->mBlock->getTarget();
-
- $this->addWikiMsg(
- $msg, $link, $reason, $ip, $name, $blockid, $blockExpiry,
- $intended, $blockTimestamp
- );
-
- # Don't auto-return to special pages
- if( $return ) {
- $return = $this->getTitle()->getNamespace() > -1 ? $this->getTitle() : null;
- $this->returnToMain( null, $return );
- }
+ function blockedPage() {
+ throw new UserBlockedError( $this->getUser()->mBlock );
}
/**
$this->addWikiText( $this->formatPermissionsErrorMessage( $reasons, $action ) );
} else {
// Wiki is read only
- $this->setPageTitle( wfMsg( 'readonly' ) );
- $reason = wfReadOnlyReason();
- $this->wrapWikiMsg( "<div class='mw-readonly-error'>\n$1\n</div>", array( 'readonlytext', $reason ) );
+ throw new ReadOnlyError;
}
// Show source, if supplied