* (bug 13982) Disable ccmeonemails preference when user-to-user mails disabled
[lhc/web/wiklou.git] / includes / SpecialPreferences.php
index 4b0f3d0..c9ab9a7 100644 (file)
@@ -66,6 +66,7 @@ class PreferencesForm {
                $this->mWatchlistDays = $request->getVal( 'wpWatchlistDays' );
                $this->mWatchlistEdits = $request->getVal( 'wpWatchlistEdits' );
                $this->mUseAjaxSearch = $request->getCheck( 'wpUseAjaxSearch' );
+               $this->mDisableMWSuggest = $request->getCheck( 'wpDisableMWSuggest' );
 
                $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) &&
                        $this->mPosted &&
@@ -288,6 +289,7 @@ class PreferencesForm {
                $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline, 0, 2) );
                $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays, 0, 7 ) );
                $wgUser->setOption( 'ajaxsearch', $this->mUseAjaxSearch );
+               $wgUser->setOption( 'disablesuggest', $this->mDisableMWSuggest );
 
                # Set search namespace options
                foreach( $this->mSearchNs as $i => $value ) {
@@ -400,6 +402,7 @@ class PreferencesForm {
                $this->mUnderline = $wgUser->getOption( 'underline' );
                $this->mWatchlistDays = $wgUser->getOption( 'watchlistdays' );
                $this->mUseAjaxSearch = $wgUser->getBoolOption( 'ajaxsearch' );
+               $this->mDisableMWSuggest = $wgUser->getBoolOption( 'disablesuggest' );
 
                $togs = User::getToggles();
                foreach ( $togs as $tname ) {
@@ -471,7 +474,7 @@ class PreferencesForm {
        }
 
        function addRow($td1, $td2) {
-               return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
+               return "<tr><td class='mw-label'>$td1</td><td class='mw-input'>$td2</td></tr>";
        }
 
        /**
@@ -517,7 +520,7 @@ class PreferencesForm {
                global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
                global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
                global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth;
-               global $wgEmailConfirmToEdit, $wgAjaxSearch;
+               global $wgEmailConfirmToEdit, $wgAjaxSearch, $wgEnableMWSuggest;
 
                $wgOut->setPageTitle( wfMsg( 'preferences' ) );
                $wgOut->setArticleRelated( false );
@@ -734,10 +737,13 @@ class PreferencesForm {
 
                        $moreEmail = '';
                        if ($wgEnableUserEmail) {
+                               // fixme -- the "allowemail" pseudotoggle is a hacked-together
+                               // inversion for the "disableemail" preference.
                                $emf = wfMsg( 'allowemail' );
                                $disabled = $disableEmailPrefs ? ' disabled="disabled"' : '';
                                $moreEmail =
-                               "<input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label>";
+                                       "<input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label>" .
+                                       $this->getToggle( 'ccmeonemails', '', $disableEmailPrefs );
                        }
 
 
@@ -749,8 +755,7 @@ class PreferencesForm {
                                        $enotifwatchlistpages.
                                        $enotifusertalkpages.
                                        $enotifminoredits.
-                                       $moreEmail.
-                                       $this->getToggle( 'ccmeonemails' )
+                                       $moreEmail
                                )
                        );
                }
@@ -867,40 +872,62 @@ class PreferencesForm {
                # Date/Time
                #
 
-               $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
+               $wgOut->addHTML(
+                       Xml::openElement( 'fieldset' ) .
+                       Xml::element( 'legend', null, wfMsg( 'datetime' ) ) . "\n"
+               );
 
                if ($dateopts) {
-                       $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
+                       $wgOut->addHTML(
+                               Xml::openElement( 'fieldset' ) .
+                               Xml::element( 'legend', null, wfMsg( 'dateformat' ) ) . "\n"
+                       );
                        $idCnt = 0;
                        $epoch = '20010115161234'; # Wikipedia day
                        foreach( $dateopts as $key ) {
                                if( $key == 'default' ) {
-                                       $formatted = wfMsgHtml( 'datedefault' );
+                                       $formatted = wfMsg( 'datedefault' );
                                } else {
-                                       $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
+                                       $formatted = $wgLang->timeanddate( $epoch, false, $key );
                                }
-                               ($key == $this->mDate) ? $checked = ' checked="checked"' : $checked = '';
-                               $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
-                                       "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
+                               $wgOut->addHTML(
+                                       Xml::tags( 'div', null,
+                                               Xml::radioLabel( $formatted, 'wpDate', $key, "wpDate$idCnt", $key == $this->mDate )
+                                       ) . "\n"
+                               );
                                $idCnt++;
                        }
-                       $wgOut->addHTML( "</fieldset>\n" );
+                       $wgOut->addHTML( Xml::closeElement( 'fieldset' ) . "\n" );
                }
 
                $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
                $nowserver = $wgLang->time( $now, false );
 
-               $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
+               $wgOut->addHTML(
+                       Xml::openElement( 'fieldset' ) .
+                       Xml::element( 'legend', null, wfMsg( 'timezonelegend' ) ) .
+                       Xml::openElement( 'table' ) .
                        $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
                        $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
                        $this->addRow(
-                               '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
-                               "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff ) . "\" size='6' />"
-                       ) . "<tr><td colspan='2'>
-                               <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
-                               onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
-                               </td></tr></table><div class='prefsectiontip'>ยน" .  wfMsg( 'timezonetext' ) . "</div></fieldset>
-               </fieldset>\n\n" );
+                               Xml::label( wfMsg( 'timezoneoffset' ), 'wpHourDiff'  ),
+                               Xml::input( 'wpHourDiff', 6, $this->mHourDiff, array( 'id' => 'wpHourDiff' ) ) ) .
+                       "<tr>
+                               <td></td>
+                               <td class='mw-submit'>" .
+                                       Xml::element( 'input',
+                                               array( 'type' => 'button',
+                                                       'value' => wfMsg( 'guesstimezone' ),
+                                                       'onclick' => 'javascript:guessTimezone()',
+                                                       'id' => 'guesstimezonebutton',
+                                                       'style' => 'display:none;' ) ) .
+                               "</td>
+                       </tr>" .
+                       Xml::closeElement( 'table' ) .
+                       Xml::element( 'div', array( 'class' => 'prefsectiontip' ), wfMsg( 'timezonetext' ) ).
+                       Xml::closeElement( 'fieldset' ) .
+                       Xml::closeElement( 'fieldset' ) . "\n\n"
+               );
 
                # Editing
                #
@@ -977,24 +1004,39 @@ class PreferencesForm {
                # Search
                $ajaxsearch = $wgAjaxSearch ?
                        $this->addRow(
-                               wfLabel( wfMsg( 'useajaxsearch' ), 'wpUseAjaxSearch' ),
-                               wfCheck( 'wpUseAjaxSearch', $this->mUseAjaxSearch, array( 'id' => 'wpUseAjaxSearch' ) )
+                               Xml::label( wfMsg( 'useajaxsearch' ), 'wpUseAjaxSearch' ),
+                               Xml::check( 'wpUseAjaxSearch', $this->mUseAjaxSearch, array( 'id' => 'wpUseAjaxSearch' ) )
+                       ) : '';
+               $mwsuggest = $wgEnableMWSuggest ?
+                       $this->addRow(
+                               Xml::label( wfMsg( 'mwsuggest-disable' ), 'wpDisableMWSuggest' ),
+                               Xml::check( 'wpDisableMWSuggest', $this->mDisableMWSuggest, array( 'id' => 'wpDisableMWSuggest' ) )
                        ) : '';
-               $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
+               $wgOut->addHTML(
+                       Xml::openElement( 'fieldset' ) .
+                       Xml::element( 'legend', null, wfMsg( 'searchresultshead' ) ) .
+                       Xml::openElement( 'table' ) .
                        $ajaxsearch .
                        $this->addRow(
-                               wfLabel( wfMsg( 'resultsperpage' ), 'wpSearch' ),
-                               wfInput( 'wpSearch', 4, $this->mSearch, array( 'id' => 'wpSearch' ) )
+                               Xml::label( wfMsg( 'resultsperpage' ), 'wpSearch' ),
+                               Xml::input( 'wpSearch', 4, $this->mSearch, array( 'id' => 'wpSearch' ) )
                        ) .
                        $this->addRow(
-                               wfLabel( wfMsg( 'contextlines' ), 'wpSearchLines' ),
-                               wfInput( 'wpSearchLines', 4, $this->mSearchLines, array( 'id' => 'wpSearchLines' ) )
+                               Xml::label( wfMsg( 'contextlines' ), 'wpSearchLines' ),
+                               Xml::input( 'wpSearchLines', 4, $this->mSearchLines, array( 'id' => 'wpSearchLines' ) )
                        ) .
                        $this->addRow(
-                               wfLabel( wfMsg( 'contextchars' ), 'wpSearchChars' ),
-                               wfInput( 'wpSearchChars', 4, $this->mSearchChars, array( 'id' => 'wpSearchChars' ) )
+                               Xml::label( wfMsg( 'contextchars' ), 'wpSearchChars' ),
+                               Xml::input( 'wpSearchChars', 4, $this->mSearchChars, array( 'id' => 'wpSearchChars' ) )
                        ) .
-               "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
+                       $mwsuggest .
+                       Xml::closeElement( 'table' ) .
+                       Xml::openElement( 'fieldset' ) .
+                       Xml::element( 'legend', null, wfMsg( 'defaultns' ) ) .
+                       $ps .
+                       Xml::closeElement( 'fieldset' ) .
+                       Xml::closeElement( 'fieldset' )
+               );
 
                # Misc
                #