(bug 4990) Show page source to blocked users on edits, or their modified version...
authorRob Church <robchurch@users.mediawiki.org>
Sat, 24 Jun 2006 20:58:10 +0000 (20:58 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sat, 24 Jun 2006 20:58:10 +0000 (20:58 +0000)
RELEASE-NOTES
includes/EditPage.php
includes/OutputPage.php
languages/Messages.php

index 9f41b48..c0abbc0 100644 (file)
@@ -555,6 +555,8 @@ Some default configuration options have changed:
   were causing the newtalk flag to trigger inappropriately)
 * Parser functions are now set using magic words.
 * (bug 6428) Incorrect form action URL on Special:Newimages with hidebots = 0 set
+* (bug 4990) Show page source to blocked users on edits, or their modified version
+  if blocked during an edit
 
 == Compatibility ==
 
index a3c98d6..47e9b53 100644 (file)
@@ -194,7 +194,7 @@ class EditPage {
                        # When previewing, don't check blocked state - will get caught at save time.
                        # Also, check when starting edition is done against slave to improve performance.
                        wfDebug( "$fname: user is blocked\n" );
-                       $wgOut->blockedPage();
+                       $this->blockedPage();
                        wfProfileOut( $fname );
                        return;
                }
@@ -511,7 +511,7 @@ class EditPage {
                }
                if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
                        # Check block state against master, thus 'false'.
-                       $this->blockedIPpage();
+                       $this->blockedPage();
                        wfProfileOut( "$fname-checks" );
                        wfProfileOut( $fname );
                        return false;
@@ -1341,9 +1341,22 @@ END
        /**
         * Call the stock "user is blocked" page
         */
-       function blockedIPpage() {
-               global $wgOut;
-               $wgOut->blockedPage();
+       function blockedPage() {
+               global $wgOut, $wgUser;
+               $wgOut->blockedPage( false ); # Standard block notice on the top, don't 'return'
+               
+               # If the user made changes, preserve them when showing the markup
+               # (This happens when a user is blocked during edit, for instance)               
+               $first = $this->firsttime || ( !$this->save && $this->textbox1 == '' );
+               $source = $first ? $this->mArticle->getContent() : $this->textbox1;
+               
+               # Spit out the source or the user's modified version
+               $rows = $wgUser->getOption( 'rows' );
+               $cols = $wgUser->getOption( 'cols' );
+               $attribs = array( 'id' => 'wpTextbox1', 'name' => 'wpTextbox1', 'cols' => $cols, 'rows' => $rows, 'readonly' => 'readonly' );
+               $wgOut->addHtml( '<hr />' );
+               $wgOut->addWikiText( wfMsg( $first ? 'blockedoriginalsource' : 'blockededitsource', $this->mTitle->getPrefixedText() ) );
+               $wgOut->addHtml( wfElement( 'textarea', $attribs, $source ) );
        }
 
        /**
index 1cfd3f8..31a0781 100644 (file)
@@ -644,7 +644,7 @@ class OutputPage {
        /**
         * Produce a "user is blocked" page
         */
-       function blockedPage() {
+       function blockedPage( $return = true ) {
                global $wgUser, $wgContLang, $wgTitle;
 
                $this->setPageTitle( wfMsg( 'blockedtitle' ) );
@@ -665,8 +665,10 @@ class OutputPage {
                $this->addWikiText( wfMsg( 'blockedtext', $link, $reason, $ip, $name ) );
                
                # Don't auto-return to special pages
-               $return = $wgTitle->getNamespace() > -1 ? $wgTitle->getPrefixedText() : NULL;   
-               $this->returnToMain( false, $return );
+               if( $return ) {
+                       $return = $wgTitle->getNamespace() > -1 ? $wgTitle->getPrefixedText() : NULL;
+                       $this->returnToMain( false, $return );
+               }
        }
 
        /**
index afa99a0..d13d41f 100644 (file)
@@ -475,6 +475,8 @@ The reason given is this:<br />\'\'$2\'\'<br />You may contact $1 or one of the
 Note that you may not use the "e-mail this user" feature unless you have a valid e-mail address registered in your [[Special:Preferences|user preferences]].
 
 Your IP address is $3. Please include this address in any queries you make.',
+'blockedoriginalsource' => "The source of '''$1''' is shown below:",
+'blockededitsource' => "The text of '''your edits''' to '''$1''' is shown below:",
 'whitelistedittitle' => 'Login required to edit',
 'whitelistedittext' => 'You have to $1 to edit pages.',
 'whitelistreadtitle' => 'Login required to read',