Don't show the autopatrol preference if recent changes patrol is disabled
[lhc/web/wiklou.git] / includes / SpecialPreferences.php
index ebbb6da..a3b5617 100644 (file)
@@ -5,9 +5,6 @@
  * @subpackage SpecialPage
  */
 
-if( !defined( 'MEDIAWIKI' ) )
-       die();
-
 /**
  * Entry point that create the "Preferences" object
  */
@@ -190,7 +187,7 @@ class PreferencesForm {
         * @access private
         */
        function savePreferences() {
-               global $wgUser, $wgLang, $wgOut;
+               global $wgUser, $wgOut, $wgParser;
                global $wgEnableUserEmail, $wgEnableEmail;
                global $wgEmailAuthentication, $wgMinimalPasswordLength;
                global $wgAuth;
@@ -227,6 +224,15 @@ class PreferencesForm {
                        $needRedirect = false;
                }
 
+               # Validate the signature and clean it up as needed
+               if( $this->mToggles['fancysig'] ) {
+                       if( Parser::validateSig( $this->mNick ) !== false ) {
+                               $this->mNick = $wgParser->cleanSig( $this->mNick );
+                       } else {
+                               $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
+                       }
+               }
+
                $wgUser->setOption( 'language', $this->mUserLanguage );
                $wgUser->setOption( 'variant', $this->mUserVariant );
                $wgUser->setOption( 'nickname', $this->mNick );
@@ -331,7 +337,7 @@ class PreferencesForm {
                $this->mNick = $wgUser->getOption( 'nickname' );
 
                $this->mQuickbar = $wgUser->getOption( 'quickbar' );
-               $this->mSkin = $wgUser->getOption( 'skin' );
+               $this->mSkin = Skin::normalizeKey( $wgUser->getOption( 'skin' ) );
                $this->mMath = $wgUser->getOption( 'math' );
                $this->mDate = $wgUser->getOption( 'date' );
                $this->mRows = $wgUser->getOption( 'rows' );
@@ -364,7 +370,7 @@ class PreferencesForm {
         * @access private
         */
        function namespacesCheckboxes() {
-               global $wgContLang, $wgUser;
+               global $wgContLang;
 
                # Determine namespace checkboxes
                $namespaces = $wgContLang->getNamespaces();
@@ -458,6 +464,7 @@ class PreferencesForm {
                $this->mUsedToggles[ 'enotifusertalkpages' ] = true;
                $this->mUsedToggles[ 'enotifminoredits' ] = true;
                $this->mUsedToggles[ 'enotifrevealaddr' ] = true;
+               $this->mUsedToggles[ 'uselivepreview' ] = true;
 
                # Enotif
                # <FIXME>
@@ -521,8 +528,8 @@ class PreferencesForm {
                                $wgUser->getID()
                        )
                );
-                               
-               
+
+
                if ($wgAllowRealName) {
                        $wgOut->addHTML(
                                $this->addRow(
@@ -550,7 +557,7 @@ class PreferencesForm {
                } else {
                        $invalidSig = '';
                }
-               
+
                $wgOut->addHTML(
                        $this->addRow(
                                '<label for="wpNick">' . wfMsg( 'yournick' ) . '</label>',
@@ -574,7 +581,7 @@ class PreferencesForm {
                        $languages[$wgContLanguageCode] = $wgContLanguageCode;
                }
                ksort( $languages );
-               
+
                /**
                 * If a bogus value is set, default to the content language.
                 * Otherwise, no default is selected and the user ends up
@@ -649,14 +656,14 @@ class PreferencesForm {
 
                # <FIXME>
                # Enotif
-                if ($wgEnableEmail) {
+               if ($wgEnableEmail) {
                        $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
-                        $wgOut->addHTML(
-                                $emailauthenticated.
-                                $enotifrevealaddr.
-                                $enotifwatchlistpages.
-                                $enotifusertalkpages.
-                                $enotifminoredits );
+                       $wgOut->addHTML(
+                                       $emailauthenticated.
+                                       $enotifrevealaddr.
+                                       $enotifwatchlistpages.
+                                       $enotifusertalkpages.
+                                       $enotifminoredits );
                        if ($wgEnableUserEmail) {
                        $emf = wfMsg( 'allowemail' );
                                $disabled = $disableEmailPrefs ? ' disabled="disabled"' : '';
@@ -665,7 +672,7 @@ class PreferencesForm {
                        }
 
                        $wgOut->addHTML( '</fieldset>' );
-                }
+               }
                # </FIXME>
 
                if ($wgAllowRealName || $wgEnableEmail) {
@@ -748,8 +755,8 @@ class PreferencesForm {
                        }
                        $wgOut->addHTML( "{$imageThumbOptions}</select></div></fieldset>\n\n");
 
-                # Date format
-                #
+               # Date format
+               #
                # Date/Time
                #
 
@@ -791,6 +798,7 @@ class PreferencesForm {
 
                # Editing
                #
+               global $wgLivePreview, $wgUseRCPatrol;
                $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
                        <div>
                                <label for="wpRows">' . wfMsg( 'rows' ) . "</label> <input type='text' name='wpRows' id='wpRows' value=\"{$this->mRows}\" size='3' />
@@ -804,14 +812,19 @@ class PreferencesForm {
                                'showtoolbar',
                                'previewonfirst',
                                'previewontop',
+                               'watchcreations',
                                'watchdefault',
                                'minordefault',
                                'externaleditor',
-                               'externaldiff' )
-                       ) . '</fieldset>'
+                               'externaldiff',
+                               $wgLivePreview ? 'uselivepreview' : false,
+                               $wgUser->isAllowed( 'patrol' ) && $wgUseRCPatrol ? 'autopatrol' : false,
+                               'forceeditsummary',
+                       ) ) . '</fieldset>'
                );
+               $this->mUsedToggles['autopatrol'] = true; # Don't show this up for users who can't; the handler below is dumb and doesn't know it
 
-               $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>' . 
+               $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>' .
                                        '<label for="wpRecent">' . wfMsg ( 'recentchangescount' ) .
                                        "</label> <input type='text' name='wpRecent' id='wpRecent' value=\"$this->mRecent\" size='3' />" .
                        $this->getToggles( array(
@@ -871,9 +884,9 @@ class PreferencesForm {
                $wgOut->addHTML( "
        <div id='prefsubmit'>
        <div>
-               <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsg( 'saveprefs' ) . "\" accesskey=\"".
-               wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
-               <input type='submit' name='wpReset' value=\"" . wfMsg( 'resetprefs' ) . "\" />
+               <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . "\" accesskey=\"".
+               wfMsgHtml('accesskey-save')."\" title=\"".wfMsgHtml('tooltip-save')."\" />
+               <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
        </div>
 
        </div>
@@ -881,7 +894,7 @@ class PreferencesForm {
        <input type='hidden' name='wpEditToken' value='{$token}' />
        </div></form>\n" );
 
-       $wgOut->addWikiText( '<div class="prefcache">' . wfMsg('clearyourcache') . '</div>' );
+               $wgOut->addWikiText( '<div class="prefcache">' . wfMsg('clearyourcache') . '</div>' );
 
        }
 }