* 'Listusers/'.'sysop' => 'Listusers/sysop'
[lhc/web/wiklou.git] / includes / SpecialPreferences.php
index a689052..4616fcc 100644 (file)
@@ -30,6 +30,7 @@ class PreferencesForm {
        var $mUserLanguage, $mUserVariant;
        var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
        var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
+       var $mUnderline;
 
        /**
         * Constructor
@@ -61,9 +62,11 @@ class PreferencesForm {
                $this->mSearchChars = $request->getVal( 'wpSearchChars' );
                $this->mImageSize = $request->getVal( 'wpImageSize' );
                $this->mThumbSize = $request->getInt( 'wpThumbSize' );
+               $this->mUnderline = $request->getInt( 'wpOpunderline' );
                $this->mAction = $request->getVal( 'action' );
                $this->mReset = $request->getCheck( 'wpReset' );
                $this->mPosted = $request->wasPosted();
+
                $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) &&
                        $this->mPosted &&
                        $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
@@ -180,6 +183,8 @@ class PreferencesForm {
                global $wgUser, $wgLang, $wgOut;
                global $wgEnableUserEmail, $wgEnableEmail;
                global $wgEmailAuthentication, $wgMinimalPasswordLength;
+               global $wgAuth;
+
 
                if ( '' != $this->mNewpass ) {
                        if ( $this->mNewpass != $this->mRetypePass ) {
@@ -196,6 +201,10 @@ class PreferencesForm {
                                $this->mainPrefsForm( wfMsg( 'wrongpassword' ) );
                                return;
                        }
+                       if (!$wgAuth->setPassword( $wgUser, $this->mNewpass )) {
+                               $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
+                               return;
+                       }
                        $wgUser->setPassword( $this->mNewpass );
                }
                $wgUser->setRealName( $this->mRealName );
@@ -204,8 +213,11 @@ class PreferencesForm {
                $wgUser->setOption( 'nickname', $this->mNick );
                $wgUser->setOption( 'quickbar', $this->mQuickbar );
                $wgUser->setOption( 'skin', $this->mSkin );
-               $wgUser->setOption( 'math', $this->mMath );
-               $wgUser->setOption( 'date', $this->mDate );
+               global $wgUseTeX;
+               if( $wgUseTeX ) {
+                       $wgUser->setOption( 'math', $this->mMath );
+               }
+               $wgUser->setOption( 'date', $this->validateInt( $this->mDate, 0, 10 ) );
                $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) );
                $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) );
                $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) );
@@ -216,6 +228,7 @@ class PreferencesForm {
                $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff, -12, 14 ) );
                $wgUser->setOption( 'imagesize', $this->mImageSize );
                $wgUser->setOption( 'thumbsize', $this->mThumbSize );
+               $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline, 0, 2) );
 
                # Set search namespace options
                foreach( $this->mSearchNs as $i => $value ) {
@@ -230,6 +243,10 @@ class PreferencesForm {
                foreach ( $this->mToggles as $tname => $tvalue ) {
                        $wgUser->setOption( $tname, $tvalue );
                }
+               if (!$wgAuth->updateExternalDB($wgUser)) {
+                       $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
+                       return;
+               }
                $wgUser->setCookies();
                $wgUser->saveSettings();
                
@@ -248,7 +265,7 @@ class PreferencesForm {
                                                # User can come back through the confirmation URL to re-enable email.
                                                $result = $wgUser->sendConfirmationMail();
                                                if( WikiError::isError( $result ) ) {
-                                                       $error = wfMsg( 'mailerror', $result->toString() );
+                                                       $error = wfMsg( 'mailerror', $result->getMessage() );
                                                } else {
                                                        $error = wfMsg( 'eauthentsent', $wgUser->getName() );
                                                }
@@ -302,6 +319,7 @@ class PreferencesForm {
                $this->mImageSize = $wgUser->getOption( 'imagesize' );
                $this->mThumbSize = $wgUser->getOption( 'thumbsize' );
                $this->mRecent = $wgUser->getOption( 'rclimit' );
+               $this->mUnderline = $wgUser->getOption( 'underline' );
 
                $togs = $wgLang->getUserToggles();
                foreach ( $togs as $tname ) {
@@ -384,7 +402,7 @@ class PreferencesForm {
                global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
                global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
                global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
-               global $wgContLanguageCode;
+               global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins;
 
                $wgOut->setPageTitle( wfMsg( 'preferences' ) );
                $wgOut->setArticleRelated( false );
@@ -407,7 +425,14 @@ class PreferencesForm {
 
                $titleObj = Title::makeTitle( NS_SPECIAL, 'Preferences' );
                $action = $titleObj->escapeLocalURL();
-
+               
+               # Pre-expire some toggles so they won't show if disabled
+               $this->mUsedToggles[ 'shownumberswatching' ] = true;
+               $this->mUsedToggles[ 'showupdated' ] = true;
+               $this->mUsedToggles[ 'enotifwatchlistpages' ] = true;
+               $this->mUsedToggles[ 'enotifusertalkpages' ] = true;
+               $this->mUsedToggles[ 'enotifminoredits' ] = true;
+               $this->mUsedToggles[ 'enotifrevealaddr' ] = true;
 
                # Enotif
                # <FIXME>
@@ -438,8 +463,8 @@ class PreferencesForm {
 
                $enotifwatchlistpages = ($wgEnotifWatchlist) ? $this->getToggle( 'enotifwatchlistpages' ) : '';
                $enotifusertalkpages = ($wgEnotifUserTalk) ? $this->getToggle( 'enotifusertalkpages' ) : '';
-               $enotifminoredits = ($wgEnotifMinorEdits) ? $this->getToggle( 'enotifminoredits' ) : '';
-               $enotifrevealaddr = ($wgEnotifRevealEditorAddress) ? $this->getToggle( 'enotifrevealaddr' ) : '';
+               $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ? $this->getToggle( 'enotifminoredits' ) : '';
+               $enotifrevealaddr = (($wgEnotifWatchlist || $wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ? $this->getToggle( 'enotifrevealaddr' ) : '';
                $prefs_help_email_enotif = ( $wgEnotifWatchlist || $wgEnotifUserTalk) ? ' ' . wfMsg('prefs-help-email-enotif') : '';
                $prefs_help_realname = '';
 
@@ -578,6 +603,10 @@ class PreferencesForm {
                                $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
                        }
                        $wgOut->addHtml( "</fieldset>\n\n" );
+               } else {
+                       # Need to output a hidden option even if the relevant skin is not in use, 
+                       # otherwise the preference will get reset to 0 on submit
+                       $wgOut->addHTML( "<input type='hidden' name='wpQuickbar' value='{$this->mQuickbar}' />" );
                }
 
                # Skin
@@ -586,8 +615,9 @@ class PreferencesForm {
                # Only show members of $wgValidSkinNames rather than
                # $skinNames (skins is all skin names from Language.php)
                foreach ($wgValidSkinNames as $skinkey => $skinname ) {
-                       global $wgDefaultSkin;
-                       
+                       if ( in_array( $skinkey, $wgSkipSkins ) ) {
+                               continue;
+                       }       
                        $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
                        $sn = isset( $skinNames[$skinkey] ) ? $skinNames[$skinkey] : $skinname;
                        
@@ -599,12 +629,15 @@ class PreferencesForm {
 
                # Math
                #
-               $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
-               foreach ( $mathopts as $k => $v ) {
-                       $checked = $k == $this->mMath ? ' checked="checked"' : '';
-                       $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
+               global $wgUseTeX;
+               if( $wgUseTeX ) {
+                       $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
+                       foreach ( $mathopts as $k => $v ) {
+                               $checked = $k == $this->mMath ? ' checked="checked"' : '';
+                               $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
+                       }
+                       $wgOut->addHTML( "</fieldset>\n\n" );
                }
-               $wgOut->addHTML( "</fieldset>\n\n" );
 
                # Files
                #
@@ -694,12 +727,7 @@ class PreferencesForm {
                        $this->getToggles( array(
                                'hideminor',
                                $wgRCShowWatchingUsers ? 'shownumberswatching' : false,
-                               'usenewrc',
-                               'rcusemodstyle',
-                               array(
-                                       'showupdated',
-                                       wfMsg('updatedmarker')
-                               ) )
+                               'usenewrc' )
                        ) . '</fieldset>'
                );
        
@@ -713,6 +741,23 @@ class PreferencesForm {
                #
                $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
 
+               $msgUnderline = htmlspecialchars(wfMsg("tog-underline"));
+               $msgUnderlinenever = htmlspecialchars(wfMsg("underline-never"));
+               $msgUnderlinealways = htmlspecialchars(wfMsg("underline-always"));
+               $msgUnderlinedefault = htmlspecialchars(wfMsg("underline-default"));
+               $uopt = $wgUser->getOption("underline");
+               $s0 = $uopt == 0 ? " selected=\"selected\"" : "";
+               $s1 = $uopt == 1 ? " selected=\"selected\"" : "";
+               $s2 = $uopt == 2 ? " selected=\"selected\"" : "";
+               $wgOut->addHTML("
+<div class='toggle'><label>$msgUnderline 
+<select name=\"wpOpunderline\">
+<option value=\"0\"$s0>$msgUnderlinenever</option>
+<option value=\"1\"$s1>$msgUnderlinealways</option>
+<option value=\"2\"$s2>$msgUnderlinedefault</option>
+</select>
+</label></div>
+");
                foreach ( $togs as $tname ) {
                        if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
                                $wgOut->addHTML( $this->getToggle( $tname ) );