(bug 21455) Fixed "Watch this page" checkbox appearing on some special pages even...
authorMatěj Grabovský <mgrabovsky@users.mediawiki.org>
Sat, 14 Nov 2009 11:07:46 +0000 (11:07 +0000)
committerMatěj Grabovský <mgrabovsky@users.mediawiki.org>
Sat, 14 Nov 2009 11:07:46 +0000 (11:07 +0000)
RELEASE-NOTES
includes/Article.php
includes/FileDeleteForm.php
includes/ProtectionForm.php
includes/specials/SpecialBlockip.php
includes/specials/SpecialMovepage.php
includes/specials/SpecialUpload.php

index ef8f8a7..2c5c059 100644 (file)
@@ -633,6 +633,8 @@ Hopefully we will remove this configuration var soon)
   id "mw-sp-contributions-explain"
 * (bug 19159) Fixed \overleftrightarrow in texvc
 * (bug 19391) Fix caching for Recent ChangesFeed.
+* (bug 21455) Fixed "Watch this page" checkbox appearing on some special pages
+  even to non-logged in users
 
 == API changes in 1.16 ==
 
index 3e34405..3fb548a 100644 (file)
@@ -2587,7 +2587,7 @@ class Article {
 
                if( $confirm ) {
                        $this->doDelete( $reason, $suppress );
-                       if( $wgRequest->getCheck( 'wpWatch' ) ) {
+                       if( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
                                $this->doWatch();
                        } elseif( $this->mTitle->userIsWatching() ) {
                                $this->doUnwatch();
@@ -2751,14 +2751,19 @@ class Article {
                                        'autofocus'
                                ) ) .
                                "</td>
-                       </tr>
+                       </tr>";
+               # Dissalow watching is user is not logged in
+               if( $wgUser->isLoggedIn() ) {
+                       $form .= "
                        <tr>
                                <td></td>
                                <td class='mw-input'>" .
                                        Xml::checkLabel( wfMsg( 'watchthis' ),
                                                'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) .
                                "</td>
-                       </tr>
+                       </tr>";
+               }
+               $form .= "
                        $suppress
                        <tr>
                                <td></td>
index b2620c3..39cb2cf 100644 (file)
@@ -112,7 +112,7 @@ class FileDeleteForm {
                                if( wfRunHooks('ArticleDelete', array(&$article, &$wgUser, &$reason, &$error)) ) {
                                        if( $article->doDeleteArticle( $reason, $suppress, $id ) ) {
                                                global $wgRequest;
-                                               if( $wgRequest->getCheck( 'wpWatch' ) ) {
+                                               if( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
                                                        $article->doWatch();
                                                } elseif( $title->userIsWatching() ) {
                                                        $article->doUnwatch();
@@ -173,14 +173,18 @@ class FileDeleteForm {
                                                array( 'type' => 'text', 'maxlength' => '255', 'tabindex' => '2', 'id' => 'wpReason' ) ) .
                                "</td>
                        </tr>
-                       {$suppress}
+                       {$suppress}";
+               if( $wgUser->isLoggedIn() ) {   
+                       $form .= "
                        <tr>
                                <td></td>
                                <td class='mw-input'>" .
                                        Xml::checkLabel( wfMsg( 'watchthis' ),
                                                'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) .
                                "</td>
-                       </tr>
+                       </tr>";
+               }
+               $form .= "
                        <tr>
                                <td></td>
                                <td class='mw-submit'>" .
index 658bab0..7dde0d8 100644 (file)
@@ -295,7 +295,7 @@ class ProtectionForm {
                        return false;
                }
 
-               if( $wgRequest->getCheck( 'mwProtectWatch' ) ) {
+               if( $wgRequest->getCheck( 'mwProtectWatch' ) && $wgUser->isLoggedIn() ) {
                        $this->mArticle->doWatch();
                } elseif( $this->mTitle->userIsWatching() ) {
                        $this->mArticle->doUnwatch();
@@ -451,7 +451,10 @@ class ProtectionForm {
                                                Xml::input( 'mwProtect-reason', 60, $this->mReason, array( 'type' => 'text',
                                                        'id' => 'mwProtect-reason', 'maxlength' => 255 ) ) .
                                        "</td>
-                               </tr>
+                               </tr>";
+                       # Disallow watching is user is not logged in
+                       if( $wgUser->isLoggedIn() ) {
+                               $out .= "
                                <tr>
                                        <td></td>
                                        <td class='mw-input'>" .
@@ -459,7 +462,9 @@ class ProtectionForm {
                                                        'mwProtectWatch', 'mwProtectWatch',
                                                        $this->mTitle->userIsWatching() || $wgUser->getOption( 'watchdefault' ) ) .
                                        "</td>
-                               </tr>
+                               </tr>";
+                       }
+                       $out .= "
                                <tr>
                                        <td></td>
                                        <td class='mw-submit'>" .
index 7d15b14..276f77a 100644 (file)
@@ -66,7 +66,7 @@ class IPBlockForm {
                if( self::canBlockEmail( $wgUser ) ) {
                        $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false );
                }
-               $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false );
+               $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false ) && $wgUser->isLoggedIn();
                # Re-check user's rights to hide names, very serious, defaults to null
                if( $wgUser->isAllowed( 'hideuser' ) ) {
                        $this->BlockHideName = $wgRequest->getBool( 'wpHideName', null );
@@ -295,8 +295,9 @@ class IPBlockForm {
                        );
                }
 
-               # Watchlist their user page?
-               $wgOut->addHTML("
+               # Watchlist their user page? (Only if user is logged in)
+               if( $wgUser->isLoggedIn() ) {
+                       $wgOut->addHTML("
                        <tr id='wpEnableWatchUser'>
                                <td>&nbsp;</td>
                                <td class='mw-input'>" .
@@ -305,7 +306,8 @@ class IPBlockForm {
                                                array( 'tabindex' => '11' ) ) . "
                                </td>
                        </tr>"
-               );
+                       );
+               }
 
                # Can we explicitly disallow the use of user_talk?
                global $wgBlockAllowsUTEdit;
index 4dbadcf..596b62b 100644 (file)
@@ -80,7 +80,7 @@ class MovePageForm {
                $this->moveSubpages = $wgRequest->getBool( 'wpMovesubpages', false );
                $this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' );
                $this->moveOverShared = $wgRequest->getBool( 'wpMoveOverSharedFile', false );
-               $this->watch = $wgRequest->getCheck( 'wpWatch' );
+               $this->watch = $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn();
        }
 
        /**
@@ -290,15 +290,20 @@ class MovePageForm {
                        );
                }
 
-               $watchChecked = $this->watch || $wgUser->getBoolOption( 'watchmoves' ) 
-                       || $this->oldTitle->userIsWatching();
-               $wgOut->addHTML( "
+               $watchChecked = $wgUser->isLoggedIn() && ($this->watch || $wgUser->getBoolOption( 'watchmoves' ) 
+                       || $this->oldTitle->userIsWatching());
+               # Don't allow watching if user is not logged in
+               if( $wgUser->isLoggedIn() ) {
+                       $wgOut->addHTML( "
                        <tr>
                                <td></td>
                                <td class='mw-input'>" .
                                        Xml::checkLabel( wfMsg( 'move-watch' ), 'wpWatch', 'watch', $watchChecked ) .
                                "</td>
-                       </tr>
+                       </tr>");
+               }
+
+               $wgOut->addHTML( "      
                                {$confirm}
                        <tr>
                                <td>&nbsp;</td>
@@ -531,7 +536,7 @@ class MovePageForm {
                }
 
                # Deal with watches (we don't watch subpages)
-               if( $this->watch ) {
+               if( $this->watch && $wgUser->isLoggedIn() ) {
                        $wgUser->addWatch( $ot );
                        $wgUser->addWatch( $nt );
                } else {
index 965c3bf..0cbd5bc 100644 (file)
@@ -70,7 +70,7 @@ class SpecialUpload extends SpecialPage {
 
                $this->mIgnoreWarning     = $request->getCheck( 'wpIgnoreWarning' )
                        || $request->getCheck( 'wpUploadIgnoreWarning' );
-               $this->mWatchthis         = $request->getBool( 'wpWatchthis' );
+               $this->mWatchthis         = $request->getBool( 'wpWatchthis' ) && $wgUser->isLoggedIn();
                $this->mCopyrightStatus   = $request->getText( 'wpUploadCopyStatus' );
                $this->mCopyrightSource   = $request->getText( 'wpUploadSource' );
 
@@ -857,17 +857,19 @@ class UploadForm extends HTMLForm {
         * @return array Descriptor array
         */
        protected function getOptionsSection() {
-               global $wgOut;
+               global $wgUser, $wgOut;
 
-               $descriptor = array(
-                       'Watchthis' => array(
-                               'type' => 'check',
-                               'id' => 'wpWatchthis',
-                               'label-message' => 'watchthisupload',
-                               'section' => 'options',
-                       )
-               );
-               if ( !$this->mHideIgnoreWarning ) {
+               if( $wgUser->isLoggedIn() ) {
+                       $descriptor = array(
+                               'Watchthis' => array(
+                                       'type' => 'check',
+                                       'id' => 'wpWatchthis',
+                                       'label-message' => 'watchthisupload',
+                                       'section' => 'options',
+                               )
+                       );
+               }
+               if( !$this->mHideIgnoreWarning ) {
                        $descriptor['IgnoreWarning'] = array(
                                'type' => 'check',
                                'id' => 'wpIgnoreWarning',