Cruft war continues: more uses of isAnon() and isLoggedIn()
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 21 Feb 2005 12:46:37 +0000 (12:46 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 21 Feb 2005 12:46:37 +0000 (12:46 +0000)
15 files changed:
includes/Article.php
includes/ChangesList.php
includes/DifferenceEngine.php
includes/EditPage.php
includes/GlobalFunctions.php
includes/ImagePage.php
includes/SpecialEmailuser.php
includes/SpecialMakesysop.php
includes/SpecialNewpages.php
includes/SpecialPreferences.php
includes/SpecialUserlogin.php
includes/SpecialWatchlist.php
languages/LanguageZh.php
skins/CologneBlue.php
skins/Nostalgia.php

index d869c8b..b8f603f 100644 (file)
@@ -675,7 +675,7 @@ class Article {
                $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
                # If we have been passed an &rcid= parameter, we want to give the user a
                # chance to mark this new article as patrolled.
-               if ( $wgUseRCPatrol && !is_null ( $rcid ) && $rcid != 0 && $wgUser->getID() != 0 &&
+               if ( $wgUseRCPatrol && !is_null ( $rcid ) && $rcid != 0 && $wgUser->isLoggedIn() &&
                     ( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) )
                {
                        $wgOut->addHTML( wfMsg ( 'markaspatrolledlink',
@@ -721,7 +721,7 @@ class Article {
                $won = wfInvertTimestamp( $now );
                wfSeedRandom();
                $rand = wfRandom();
-               $isminor = ( $isminor && $wgUser->getID() ) ? 1 : 0;
+               $isminor = ( $isminor && $wgUser->isLoggedIn() ) ? 1 : 0;
                
                $mungedText = $text;
                $flags = Revision::compressRevisionText( $mungedText );
@@ -915,7 +915,7 @@ class Article {
                $good = true;
 
                if ( $this->mMinorEdit ) { $me1 = 1; } else { $me1 = 0; }
-               if ( $minor && $wgUser->getID() ) { $me2 = 1; } else { $me2 = 0; }
+               if ( $minor && $wgUser->isLoggedIn() ) { $me2 = 1; } else { $me2 = 0; }
                if ( $this->isRedirect( $text ) ) {
                        # Remove all content but redirect
                        # This could be done by reconstructing the redirect from a title given by 
@@ -1097,7 +1097,7 @@ class Article {
                        $wgOut->errorpage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
                        return;
                }
-               if ( $wgUser->getID() == 0 )
+               if ( $wgUser->isAnon() )
                {
                        $wgOut->loginToUse();
                        return;
@@ -1132,7 +1132,7 @@ class Article {
                
                global $wgUser, $wgOut;
 
-               if ( 0 == $wgUser->getID() ) {
+               if ( $wgUser->isAnon() ) {
                        $wgOut->errorpage( 'watchnologin', 'watchnologintext' );
                        return;
                }
@@ -1167,7 +1167,7 @@ class Article {
 
                global $wgUser, $wgOut;
 
-               if ( 0 == $wgUser->getID() ) {
+               if ( $wgUser->isAnon() ) {
                        $wgOut->errorpage( 'watchnologin', 'watchnologintext' );
                        return;
                }
@@ -1902,7 +1902,7 @@ class Article {
                return $wgUseFileCache
                        and (!$wgShowIPinHeader)
                        and ($this->getID() != 0)
-                       and ($wgUser->getId() == 0)
+                       and ($wgUser->isAnon())
                        and (!$wgUser->getNewtalk())
                        and ($this->mTitle->getNamespace() != NS_SPECIAL )
                        and (empty( $action ) || $action == 'view')
index 887e6e1..5749815 100644 (file)
@@ -328,7 +328,7 @@ class ChangesList {
                $curIdEq = 'curid=' . $rc_cur_id;
 
                # Should patrol-related stuff be shown?
-               $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 && 
+               $unpatrolled = $wgUseRCPatrol && $wgUser->isLoggedIn() && 
                  ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
                
                # Make date header if necessary
@@ -489,7 +489,7 @@ class ChangesList {
                }
                
                # Should patrol-related stuff be shown?
-               if ( $wgUseRCPatrol && $wgUser->getID() != 0 && 
+               if ( $wgUseRCPatrol && $wgUser->isLoggedIn() && 
                  ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol') )) {
                        $rc->unpatrolled = !$rc_patrolled;
                } else {
index 603fadf..767c736 100644 (file)
@@ -123,7 +123,7 @@ class DifferenceEngine {
                } else {
                        $rollback = '';
                }
-               if ( $wgUseRCPatrol && $this->mRcidMarkPatrolled != 0 && $wgUser->getID() != 0 &&
+               if ( $wgUseRCPatrol && $this->mRcidMarkPatrolled != 0 && $wgUser->isLoggedIn() &&
                     ( $wgUser->isAllowed('rollback') || !$wgOnlySysopsCanPatrol ) )
                {
                        $patrol = ' [' . $sk->makeKnownLinkObj( $wgTitle, wfMsg( 'markaspatrolleddiff' ),
index 2cd0bdc..be5d659 100644 (file)
@@ -156,7 +156,7 @@ class EditPage {
                        $this->blockedIPpage();
                        return;
                }
-               if ( !$wgUser->getID() && $wgWhitelistEdit ) {
+               if ( $wgUser->isAnon() && $wgWhitelistEdit ) {
                        $this->userNotLoggedInPage();
                        return;
                }
@@ -249,7 +249,7 @@ class EditPage {
         */
        function tokenOk( &$request ) {
                global $wgUser;
-               if( $wgUser->getId() == 0 ) {
+               if( $wgUser->isAnon() ) {
                        # Anonymous users may not have a session
                        # open. Don't tokenize.
                        return true;
@@ -318,7 +318,7 @@ class EditPage {
                                $this->blockedIPpage();
                                return;
                        }
-                       if ( !$wgUser->getID() && $wgWhitelistEdit ) {
+                       if ( $wgUser->isAnon() && $wgWhitelistEdit ) {
                                $this->userNotLoggedInPage();
                                return;
                        }
@@ -541,7 +541,7 @@ class EditPage {
 
                $minoredithtml = '';
 
-               if ( 0 != $wgUser->getID() || $wgAllowAnonymousMinor ) {
+               if ( $wgUser->isLoggedIn() || $wgAllowAnonymousMinor ) {
                        $minoredithtml =
                                "<input tabindex='3' type='checkbox' value='1' name='wpMinoredit'".($this->minoredit?" checked='checked'":"").
                                " accesskey='".wfMsg('accesskey-minoredit')."' id='wpMinoredit' />".
@@ -550,7 +550,7 @@ class EditPage {
 
                $watchhtml = '';
 
-               if ( 0 != $wgUser->getID() ) {
+               if ( $wgUser->isLoggedIn() ) {
                        $watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'".($this->watchthis?" checked='checked'":"").
                                " accesskey='".wfMsg('accesskey-watch')."' id='wpWatchthis'  />".
                                "<label for='wpWatchthis' title='".wfMsg('tooltip-watch')."'>{$watchthis}</label>";
@@ -663,7 +663,7 @@ END
 <input type='hidden' value=\"" . htmlspecialchars( $this->section ) . "\" name=\"wpSection\" />
 <input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n" );
 
-               if ( 0 != $wgUser->getID() ) {
+               if ( $wgUser->isLoggedIn() ) {
                        /**
                         * To make it harder for someone to slip a user a page
                         * which submits an edit form to the wiki without their
@@ -770,7 +770,7 @@ END
         * @todo document
         */
        function userNotLoggedInPage() {
-               global $wgOut, $wgUser;
+               global $wgOut;
 
                $wgOut->setPageTitle( wfMsg( 'whitelistedittitle' ) );
                $wgOut->setRobotpolicy( 'noindex,nofollow' );
index 8e4937f..3d66a27 100644 (file)
@@ -302,7 +302,7 @@ function logProfilingData() {
                        $forward .= ' from ' . $_SERVER['HTTP_FROM'];
                if( $forward )
                        $forward = "\t(proxied via {$_SERVER['REMOTE_ADDR']}{$forward})";
-               if($wgUser->getId() == 0)
+               if( $wgUser->isAnon() )
                        $forward .= ' anon';
                $log = sprintf( "%s\t%04.3f\t%s\n",
                  gmdate( 'YmdHis' ), $elapsed,
index cec8bd0..105eb89 100644 (file)
@@ -368,7 +368,7 @@ class ImagePage extends Article {
                        $wgOut->readOnlyPage();
                        return;
                }
-               if( $wgUser->getId() == 0 ) {
+               if( $wgUser->isAnon() ) {
                        $wgOut->errorpage( 'uploadnologin', 'uploadnologintext' );
                        return;
                }
index 8845e93..7bb4a61 100644 (file)
@@ -18,7 +18,7 @@ function wfSpecialEmailuser( $par ) {
                return;
        }
        
-       if ( 0 == $wgUser->getID() ||
+       if ( $wgUser->isAnon() ||
                ( !$wgUser->isValidEmailAddr( $wgUser->getEmail() ) ) ) {
                $wgOut->errorpage( "mailnologin", "mailnologintext" );
                return;
index aa06283..96b8763 100644 (file)
@@ -20,7 +20,7 @@ require_once( "LinksUpdate.php" );
 function wfSpecialMakesysop() {
        global $wgUser, $wgOut, $wgRequest;
 
-       if ( 0 == $wgUser->getID() or $wgUser->isBlocked() ) {
+       if ( $wgUser->isAnon() or $wgUser->isBlocked() ) {
                $wgOut->errorpage( "movenologin", "movenologintext" );
                return;
        }
index a8935ec..ca85ec4 100644 (file)
@@ -29,7 +29,7 @@ class NewPagesPage extends QueryPage {
 
        function getSQL() {
                global $wgUser, $wgOnlySysopsCanPatrol, $wgUseRCPatrol;
-               $usepatrol = ( $wgUseRCPatrol && $wgUser->getID() != 0 &&
+               $usepatrol = ( $wgUseRCPatrol && $wgUser->isLoggedIn() &&
                               ( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) ) ? 1 : 0;
                $dbr =& wfGetDB( DB_SLAVE );
                extract( $dbr->tableNames( 'recentchanges', 'page', 'text' ) );
@@ -75,7 +75,7 @@ class NewPagesPage extends QueryPage {
                # Since there is no diff link, we need to give users a way to
                # mark the article as patrolled if it isn't already
                if ( $wgUseRCPatrol && !is_null ( $result->usepatrol ) && $result->usepatrol &&
-                    $result->patrolled == 0 && $wgUser->getID() != 0 &&
+                    $result->patrolled == 0 && $wgUser->isLoggedIn() &&
                     ( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) )
                        $link = $skin->makeKnownLink( $result->title, '', "rcid={$result->rcid}" );
                else
index e2c16f6..bfbe8f4 100644 (file)
@@ -103,7 +103,7 @@ class PreferencesForm {
        function execute() {
                global $wgUser, $wgOut, $wgUseDynamicDates;
                
-               if ( 0 == $wgUser->getID() ) {
+               if ( $wgUser->isAnon() ) {
                        $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
                        return;
                }
index 7abf0aa..50407ee 100644 (file)
@@ -486,7 +486,7 @@ class LoginForm {
                global $wgEmailAuthentication;
 
                if ( '' == $this->mName ) {
-                       if ( 0 != $wgUser->getID() ) {
+                       if ( $wgUser->isLoggedIn() ) {
                                $this->mName = $wgUser->getName();
                        } else {
                                $this->mName = @$_COOKIE[$wgDBname.'UserName'];
@@ -511,7 +511,7 @@ class LoginForm {
                $template->set( 'action', $titleObj->getLocalUrl( $q ) );
                $template->set( 'error', $err );
                $template->set( 'create', $wgUser->isAllowedToCreateAccount() );
-               $template->set( 'createemail', $wgEnableEmail && ($wgUser->getID() != 0) );
+               $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
                $template->set( 'userealname', $wgAllowRealName );
                $template->set( 'useemail', $wgEnableEmail );
                $template->set( 'useemailauthent', $wgEmailAuthentication );
index 5f3f2be..3d14b2a 100644 (file)
@@ -27,8 +27,7 @@ function wfSpecialWatchlist() {
 
        $specialTitle = Title::makeTitle( NS_SPECIAL, 'Watchlist' );
 
-       $uid = $wgUser->getID();
-       if( $uid == 0 ) {
+       if( $wgUser->isAnon() ) {
                $wgOut->addWikiText( wfMsg( 'nowatchlist' ) );
                return;
        }
@@ -52,6 +51,7 @@ function wfSpecialWatchlist() {
                        "</div>\n\n" );
        }
 
+       $uid = $wgUser->getID();
        if( $wgRequest->getVal( 'reset' ) == 'all' ) {
                $wgUser->clearAllNotifications( $uid );
        }
index 7c2cab1..bdefc3a 100644 (file)
@@ -224,7 +224,7 @@ class LanguageZh extends LanguageZh_cn {
                }
 
                // get language variant preference from logged in users 
-               if($wgUser->getID()!=0) {
+               if( $wgUser->isLoggedIn() ) {
                        $this->mZhLanguageCode = $wgUser->getOption('variant');
                }
 
index 7cf5b28..06e5d46 100644 (file)
@@ -25,7 +25,7 @@ class SkinCologneBlue extends Skin {
        }
 
        function doBeforeContent() {
-               global $wgUser, $wgOut, $wgTitle, $wgSiteNotice;
+               global $wgOut, $wgTitle, $wgSiteNotice;
 
                $s = "";
                $qb = $this->qbSetting();
@@ -67,7 +67,7 @@ class SkinCologneBlue extends Skin {
 
        function doAfterContent()
        {
-               global $wgUser, $wgOut;
+               global $wgOut;
 
                $s = "\n</div><br clear='all' />\n";
 
@@ -96,9 +96,9 @@ class SkinCologneBlue extends Skin {
                if ( 0 != $qb ) { $s .= $this->quickBar(); }
                return $s;
        }
-       function doGetUserStyles()
-       {
-               global $wgUser, $wgOut, $wgStyleSheetPath;
+       
+       function doGetUserStyles() {
+               global $wgOut, $wgStyleSheetPath;
                $s = parent::doGetUserStyles();
                $qb = $this->qbSetting();
 
@@ -116,8 +116,8 @@ class SkinCologneBlue extends Skin {
                }
                return $s;
        }
-       function sysLinks()
-       {
+       
+       function sysLinks() {
                global $wgUser, $wgContLang, $wgTitle;
                $li = $wgContLang->specialPage("Userlogin");
                $lo = $wgContLang->specialPage("Userlogout");
@@ -140,12 +140,9 @@ class SkinCologneBlue extends Skin {
                  . " | " .
                  $this->specialLink( "specialpages" ) . " | ";
 
-               if ( $wgUser->getID() )
-               {
+               if ( $wgUser->isLoggedIn() ) {
                        $s .=  $this->makeKnownLink( $lo, wfMsg( "logout" ), $q );
-               }
-               else
-               {
+               } else {
                        $s .=  $this->makeKnownLink( $li, wfMsg( "login" ), $q );
                }
 
@@ -200,7 +197,7 @@ class SkinCologneBlue extends Skin {
 
                        $s .= $sep . $this->makeKnownLink( wfMsgForContent( "edithelppage" ), wfMsg( "edithelp" ) );
 
-                       if ( 0 != $wgUser->getID() ) {
+                       if( $wgUser->isLoggedIn() ) {
                                $s .= $sep . $this->moveThisPage();
                        }
                        if ( $wgUser->isAllowed('delete') ) {
@@ -221,7 +218,7 @@ class SkinCologneBlue extends Skin {
                        $s .= $this->talkLink()
                          . $sep . $this->commentLink() 
                          . $sep . $this->printableLink();
-                       if ( 0 != $wgUser->getID() ) {
+                       if ( $wgUser->isLoggedIn() ) {
                                $s .= $sep . $this->watchThisPage();
                        }
 
@@ -245,7 +242,7 @@ class SkinCologneBlue extends Skin {
                }
 
                $s .= $this->menuHead( "qbmyoptions" );
-               if ( 0 != $wgUser->getID() ) {
+               if ( $wgUser->isLoggedIn() ) {
                        $name = $wgUser->getName();
                        $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
                                wfMsg( 'mytalk' ) );
index d29aaf8..02b5d8b 100644 (file)
@@ -66,7 +66,7 @@ class SkinNostalgia extends Skin {
                        $s .=  $sep . $this->editThisPage()
                          . $sep . $this->historyLink();
                }
-               if ( 0 == $wgUser->getID() ) {
+               if ( $wgUser->isAnon() ) {
                        $s .= $sep . $this->specialLink( "userlogin" );
                } else {
                        $s .= $sep . $this->specialLink( "userlogout" );
@@ -77,8 +77,6 @@ class SkinNostalgia extends Skin {
        }
 
        function doAfterContent() {
-               global $wgUser, $wgOut;
-
                $s = "\n</div><br clear='all' />\n";
 
                $s .= "\n<div id='footer'><hr />";