From 4a099928f73222b2c92c6bc66384649f3022def1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C4=9Bj=20Grabovsk=C3=BD?= Date: Sat, 14 Nov 2009 11:07:46 +0000 Subject: [PATCH] (bug 21455) Fixed "Watch this page" checkbox appearing on some special pages even to non-logged in users --- RELEASE-NOTES | 2 ++ includes/Article.php | 11 ++++++++--- includes/FileDeleteForm.php | 10 +++++++--- includes/ProtectionForm.php | 11 ++++++++--- includes/specials/SpecialBlockip.php | 10 ++++++---- includes/specials/SpecialMovepage.php | 17 +++++++++++------ includes/specials/SpecialUpload.php | 24 +++++++++++++----------- 7 files changed, 55 insertions(+), 30 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ef8f8a791b..2c5c059a63 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/Article.php b/includes/Article.php index 3e344059e9..3fb548a4bc 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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' ) ) . " - + "; + # Dissalow watching is user is not logged in + if( $wgUser->isLoggedIn() ) { + $form .= " " . Xml::checkLabel( wfMsg( 'watchthis' ), 'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) . " - + "; + } + $form .= " $suppress diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index b2620c3ba1..39cb2cf9f3 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -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' ) ) . " - {$suppress} + {$suppress}"; + if( $wgUser->isLoggedIn() ) { + $form .= " " . Xml::checkLabel( wfMsg( 'watchthis' ), 'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) . " - + "; + } + $form .= " " . diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 658bab0c73..7dde0d8381 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -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 ) ) . " - + "; + # Disallow watching is user is not logged in + if( $wgUser->isLoggedIn() ) { + $out .= " " . @@ -459,7 +462,9 @@ class ProtectionForm { 'mwProtectWatch', 'mwProtectWatch', $this->mTitle->userIsWatching() || $wgUser->getOption( 'watchdefault' ) ) . " - + "; + } + $out .= " " . diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index 7d15b14c66..276f77a4ff 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -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("   " . @@ -305,7 +306,8 @@ class IPBlockForm { array( 'tabindex' => '11' ) ) . " " - ); + ); + } # Can we explicitly disallow the use of user_talk? global $wgBlockAllowsUTEdit; diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 4dbadcfb8f..596b62b2d0 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -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( " " . Xml::checkLabel( wfMsg( 'move-watch' ), 'wpWatch', 'watch', $watchChecked ) . " - + "); + } + + $wgOut->addHTML( " {$confirm}   @@ -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 { diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 965c3bf1c5..0cbd5bceae 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -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', -- 2.20.1