Update per r50782:
authorRobin Pepermans <robin@users.mediawiki.org>
Sun, 24 May 2009 12:09:15 +0000 (12:09 +0000)
committerRobin Pepermans <robin@users.mediawiki.org>
Sun, 24 May 2009 12:09:15 +0000 (12:09 +0000)
* Remove all $wgAllowRealName, check $wgHiddenPrefs instead
* Make $wgAllowUserSkin obsolete too, check $wgHiddenPrefs instead
* And also only call globals if really needed, and remove unused globals

RELEASE-NOTES
includes/Credits.php
includes/DefaultSettings.php
includes/Preferences.php
includes/Setup.php
includes/User.php
includes/specials/SpecialUserlogin.php

index 7e9a45a..cc10190 100644 (file)
@@ -26,8 +26,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   be used when uploading/moving files
 * (bug 18761) $wgHiddenPrefs is a new array for specifying preferences not
   to be shown to users
-* $wgAllowRealName was deprecated in favor of $wgHiddenPrefs[] = 'realname',
-  but the former is still retained for backwards-compatibility
+* $wgAllowRealName and $wgAllowUserSkin were deprecated in favor of
+  $wgHiddenPrefs[] = 'realname', but the former are still retained
+  for backwards-compatibility
 * (bug 9257) $wgRCMaxAge now defaults to three months
 * $wgDevelopmentWarnings can be set to true to show warnings about deprecated
   functions and other potential errors when developing.
index 9137c3f..817f179 100644 (file)
@@ -75,7 +75,7 @@ class Credits {
         * @param $article Article object
         */
        protected static function getAuthor( Article $article ){
-               global $wgLang, $wgAllowRealName;
+               global $wgLang;
 
                $user = User::newFromId( $article->getUser() );
 
@@ -98,7 +98,7 @@ class Credits {
         * @return String: html
         */
        protected static function getContributors( Article $article, $cnt, $showIfMax ) {
-               global $wgLang, $wgAllowRealName;
+               global $wgLang, $wgHiddenPrefs;
        
                $contributors = $article->getContributors();
        
@@ -120,7 +120,7 @@ class Credits {
                        $cnt--;
                        if( $user->isLoggedIn() ){
                                $link = self::link( $user );
-                               if( $wgAllowRealName && $user->getRealName() )
+                               if( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() )
                                        $real_names[] = $link;
                                else
                                        $user_names[] = $link;
@@ -162,15 +162,15 @@ class Credits {
         * @return String: html
         */
        protected static function link( User $user ) {
-               global $wgUser, $wgAllowRealName;
-               if( $wgAllowRealName )
+               global $wgHiddenPrefs;
+               if( !in_array( 'realname', $wgHiddenPrefs ) )
                        $real = $user->getRealName();
                else
                        $real = false;
 
-               $skin = $wgUser->getSkin();
+               $skin = $user->getSkin();
                $page = $user->getUserPage();
-                       
+
                return $skin->link( $page, htmlspecialchars( $real ? $real : $user->getName() ) );
        }
 
@@ -181,12 +181,12 @@ class Credits {
         * @return String: html
         */
        protected static function userLink( User $user ) {
-               global $wgUser, $wgAllowRealName;
                if( $user->isAnon() ){
                        return wfMsgExt( 'anonymous', array( 'parseinline' ), 1 );
                } else {
+                       global $wgHiddenPrefs;
                        $link = self::link( $user );
-                       if( $wgAllowRealName && $user->getRealName() )
+                       if( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() )
                                return $link;
                        else 
                                return wfMsgExt( 'siteuser', array( 'parseinline', 'replaceafter' ), $link );
index 393ac1d..79a42db 100644 (file)
@@ -2398,7 +2398,10 @@ $wgValidateAllHtml = false;
 /** See list of skins and their symbolic names in languages/Language.php */
 $wgDefaultSkin = 'monobook';
 
-/** Should we allow the user's to select their own skin that will override the default? */
+/**
+* Should we allow the user's to select their own skin that will override the default?
+* @deprecated in 1.16, use $wgHiddenPrefs[] = 'skin' to disable it
+*/
 $wgAllowUserSkin = true;
 
 /**
index 419aa8c..3e8f708 100644 (file)
@@ -379,20 +379,17 @@ class Preferences {
        
        static function skinPreferences( $user, &$defaultPreferences ) {
                ## Skin #####################################
-               global $wgAllowUserSkin, $wgLang;
-               
-               if ($wgAllowUserSkin) {
-                       $defaultPreferences['skin'] =
-                                       array(
-                                               'type' => 'radio',
-                                               'options' => self::generateSkinOptions( $user ),
-                                               'label' => '&nbsp;',
-                                               'section' => 'rendering/skin',
-                                       );
-               }
+               $defaultPreferences['skin'] =
+                               array(
+                                       'type' => 'radio',
+                                       'options' => self::generateSkinOptions( $user ),
+                                       'label' => '&nbsp;',
+                                       'section' => 'rendering/skin',
+                               );
                
                $selectedSkin = $user->getOption( 'skin' );
                if ( in_array( $selectedSkin, array( 'cologneblue', 'standard' ) ) ) {
+                       global $wgLang;
                        $settings = array_flip($wgLang->getQuickbarSettings());
                        
                        $defaultPreferences['quickbar'] =
@@ -1151,8 +1148,8 @@ class Preferences {
                }
                
                // Fortunately, the realname field is MUCH simpler
-               global $wgAllowRealName;
-               if ($wgAllowRealName) {
+               global $wgHiddenPrefs;
+               if ( !in_array( 'realname', $wgHiddenPrefs ) ) {
                        $realName = $formData['realname'];
                        $wgUser->setRealName( $realName );
                }
index 8df3f98..6df6ac3 100644 (file)
@@ -201,12 +201,16 @@ $wgContLanguageCode = $wgLanguageCode;
 # If file cache or squid cache is on, just disable this (DWIMD).
 if( $wgUseFileCache || $wgUseSquid ) $wgShowIPinHeader = false;
 
-# $wgAllowRealName was removed in 1.16 in favor of $wgHiddenPrefs,
-# handle b/c here
+# $wgAllowRealName and $wgAllowUserSkin were removed in 1.16
+# in favor of $wgHiddenPrefs, handle b/c here
 if( !$wgAllowRealName ) {
        $wgHiddenPrefs[] = 'realname';
 }
 
+if( !$wgAllowUserSkin ) {
+       $wgHiddenPrefs[] = 'skin';
+}
+
 wfProfileOut( $fname.'-misc1' );
 wfProfileIn( $fname.'-memcached' );
 
index d10bc34..3085628 100644 (file)
@@ -2149,16 +2149,18 @@ class User {
         * @todo FIXME : need to check the old failback system [AV]
         */
        function &getSkin( $t = null ) {
-               global $wgRequest, $wgAllowUserSkin, $wgDefaultSkin;
                if ( ! isset( $this->mSkin ) ) {
                        wfProfileIn( __METHOD__ );
 
-                       if( $wgAllowUserSkin ) {
+                       global $wgHiddenPrefs;
+                       if( !in_array( 'skin', $wgHiddenPrefs ) ) {
                                # get the user skin
+                               global $wgRequest;
                                $userSkin = $this->getOption( 'skin' );
                                $userSkin = $wgRequest->getVal('useskin', $userSkin);
                        } else {
                                # if we're not allowing users to override, then use the default
+                               global $wgDefaultSkin;
                                $userSkin = $wgDefaultSkin;
                        }
                        
index 55615a9..2c21de6 100644 (file)
@@ -44,7 +44,7 @@ class LoginForm {
         * @param WebRequest $request A WebRequest object passed by reference
         */
        function LoginForm( &$request, $par = '' ) {
-               global $wgLang, $wgAllowRealName, $wgEnableEmail;
+               global $wgLang, $wgHiddenPrefs, $wgEnableEmail;
                global $wgAuth, $wgRedirectOnLogin;
 
                $this->mType = ( $par == 'signup' ) ? $par : $request->getText( 'type' ); # Check for [[Special:Userlogin/signup]]
@@ -75,7 +75,7 @@ class LoginForm {
                } else {
                        $this->mEmail = '';
                }
-               if( $wgAllowRealName ) {
+               if( !in_array( 'realname', $wgHiddenPrefs ) ) {
                    $this->mRealName = $request->getText( 'wpRealName' );
                } else {
                    $this->mRealName = '';
@@ -798,7 +798,7 @@ class LoginForm {
         * @private
         */
        function mainLoginForm( $msg, $msgtype = 'error' ) {
-               global $wgUser, $wgOut, $wgAllowRealName, $wgEnableEmail;
+               global $wgUser, $wgOut, $wgHiddenPrefs, $wgEnableEmail;
                global $wgCookiePrefix, $wgLoginLanguageSelector;
                global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration;
                
@@ -874,7 +874,7 @@ class LoginForm {
                $template->set( 'message', $msg );
                $template->set( 'messagetype', $msgtype );
                $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
-               $template->set( 'userealname', $wgAllowRealName );
+               $template->set( 'userealname', !in_array( 'realname', $wgHiddenPrefs ) );
                $template->set( 'useemail', $wgEnableEmail );
                $template->set( 'emailrequired', $wgEmailConfirmToEdit );
                $template->set( 'canreset', $wgAuth->allowPasswordChange() );