if( !defined( 'MEDIAWIKI' ) )
die();
-/** to get a list of languages in setting user's language preference */
-require_once('languages/Names.php');
-
/**
* Entry point that create the "Preferences" object
*/
var $mUserLanguage, $mUserVariant;
var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
+ var $mUnderline;
/**
* Constructor
$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' ) );
global $wgUser, $wgLang, $wgOut;
global $wgEnableUserEmail, $wgEnableEmail;
global $wgEmailAuthentication, $wgMinimalPasswordLength;
+ global $wgAuth;
+
if ( '' != $this->mNewpass ) {
if ( $this->mNewpass != $this->mRetypePass ) {
$this->mainPrefsForm( wfMsg( 'wrongpassword' ) );
return;
}
+ if (!$wgAuth->setPassword( $wgUser, $this->mNewpass )) {
+ $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
+ return;
+ }
$wgUser->setPassword( $this->mNewpass );
}
$wgUser->setRealName( $this->mRealName );
$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 ) );
$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 ) {
foreach ( $this->mToggles as $tname => $tvalue ) {
$wgUser->setOption( $tname, $tvalue );
}
+ if (!$wgAuth->updateExternalDB($wgUser)) {
+ $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
+ return;
+ }
$wgUser->setCookies();
$wgUser->saveSettings();
+ $error = wfMsg( 'savedprefs' );
if( $wgEnableEmail ) {
- $newadr = strtolower( $this->mUserEmail );
- $oldadr = strtolower($wgUser->getEmail());
- if (($newadr <> '') && ($newadr <> $oldadr)) { # the user has supplied a new email address on the login page
- # prepare for authentication and mail a temporary password to newadr
- require_once( 'SpecialUserlogin.php' );
- if ( !$wgUser->isValidEmailAddr( $newadr ) ) {
- $this->mainPrefsForm( wfMsg( 'invalidemailaddress' ) );
- return;
- }
- $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record
- $wgUser->mEmailAuthenticationtimestamp = 0; # but flag as "dirty" = unauthenticated
- $wgUser->saveSettings();
- if ($wgEmailAuthentication) {
- # mail a temporary password to the dirty address
- # on "save options", this user will be logged-out automatically
- $error = LoginForm::mailPasswordInternal( $wgUser, true, $dummy );
- if ($error === '') {
- return LoginForm::mainLoginForm( wfMsg( 'passwordsentforemailauthentication', $wgUser->getName() ) );
- } else {
- return LoginForm::mainLoginForm( wfMsg( 'mailerror', $error ) );
+ $newadr = $this->mUserEmail;
+ $oldadr = $wgUser->getEmail();
+ if( ($newadr != '') && ($newadr != $oldadr) ) {
+ # the user has supplied a new email address on the login page
+ if( $wgUser->isValidEmailAddr( $newadr ) ) {
+ $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record
+ $wgUser->mEmailAuthenticated = null; # but flag as "dirty" = unauthenticated
+ $wgUser->saveSettings();
+ if ($wgEmailAuthentication) {
+ # Mail a temporary password to the dirty address.
+ # User can come back through the confirmation URL to re-enable email.
+ $result = $wgUser->sendConfirmationMail();
+ if( WikiError::isError( $result ) ) {
+ $error = wfMsg( 'mailerror', $result->getMessage() );
+ } else {
+ $error = wfMsg( 'eauthentsent', $wgUser->getName() );
+ }
}
- # if user returns, that new email address gets authenticated in checkpassword()
+ } else {
+ $error = wfMsg( 'invalidemailaddress' );
}
} else {
- $wgUser->setEmail( strtolower($this->mUserEmail) );
+ $wgUser->setEmail( $this->mUserEmail );
$wgUser->setCookies();
$wgUser->saveSettings();
}
$wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
$po = ParserOptions::newFromUser( $wgUser );
- $this->mainPrefsForm( wfMsg( 'savedprefs' ) );
+ $this->mainPrefsForm( $error );
}
/**
$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 ) {
$namespaces = $wgContLang->getNamespaces();
foreach ( $namespaces as $i => $namespace ) {
- if ( $i >= 0 ) {
+ if ( $i >= NS_MAIN ) {
$this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
}
}
# Determine namespace checkboxes
$namespaces = $wgContLang->getNamespaces();
- $r1 = '';
+ $r1 = null;
foreach ( $namespaces as $i => $name ) {
- # Skip special or anything similar
- if ( $i >= 0 ) {
- $checked = '';
- if ( $this->mSearchNs[$i] ) {
- $checked = ' checked="checked"';
- }
- $name = str_replace( '_', ' ', $namespaces[$i] );
- if ( '' == $name ) {
- $name = wfMsg( 'blanknamespace' );
- }
+ if ($i < 0)
+ continue;
+ $checked = $this->mSearchNs[$i] ? "checked='checked'" : '';
+ $name = str_replace( '_', ' ', $namespaces[$i] );
+
+ if ( empty($name) )
+ $name = wfMsg( 'blanknamespace' );
- if ( 0 != $i ) {
- $r1 .= ' ';
- }
- $r1 .= "<label><input type='checkbox' value=\"1\" name=\"" .
- "wpNs$i\"{$checked} />{$name}</label>\n";
- }
+ $r1 .= "<label><input type='checkbox' value='1' name='wpNs$i' {$checked}/>{$name}</label>\n";
}
-
return $r1;
}
function mainPrefsForm( $err ) {
global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
- global $wgLanguageNames, $wgDisableLangConversion;
- global $wgEmailNotificationForWatchlistPages, $wgEmailNotificationForUserTalkPages,$wgEmailNotificationForMinorEdits;
- global $wgRCShowWatchingUsers, $wgEmailNotificationRevealPageEditorAddress;
+ global $wgDisableLangConversion;
+ global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
+ global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
- global $wgContLanguageCode;
+ global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins;
$wgOut->setPageTitle( wfMsg( 'preferences' ) );
$wgOut->setArticleRelated( false );
$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>
+ $this->mUserEmail = htmlspecialchars( $this->mUserEmail );
+ $this->mRealName = htmlspecialchars( $this->mRealName );
+ $this->mNick = htmlspecialchars( $this->mNick );
+ if ( $this->mEmailFlag ) { $emfc = 'checked="checked"'; }
+ else { $emfc = ''; }
+
+ if ($wgEmailAuthentication && ($this->mUserEmail != '') ) {
+ if( $wgUser->getEmailAuthenticationTimestamp() ) {
+ $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
+ } else {
+ $skin = $wgUser->getSkin();
+ $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
+ $skin->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Confirmemail' ),
+ wfMsg( 'emailconfirmlink' ) );
+ }
+ } else {
+ $emailauthenticated = '';
+ }
+
+ if ($this->mUserEmail == '') {
+ $emailauthenticated = wfMsg( 'noemailprefs' );
+ }
+
+ $ps = $this->namespacesCheckboxes();
+
+ $enotifwatchlistpages = ($wgEnotifWatchlist) ? $this->getToggle( 'enotifwatchlistpages' ) : '';
+ $enotifusertalkpages = ($wgEnotifUserTalk) ? $this->getToggle( 'enotifusertalkpages' ) : '';
+ $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 = '';
+
+ # </FIXME>
$wgOut->addHTML( "<form id='preferences' name='preferences' action=\"$action\" method='post'>" );
* Otherwise, no default is selected and the user ends up
* with an Afrikaans interface since it's first in the list.
*/
- $selectedLang = isset( $wgLanguageNames[$this->mUserLanguage] ) ? $this->mUserLanguage : $wgContLanguageCode;
+ $languages = $wgLang->getLanguageNames();
+ $selectedLang = isset( $languages[$this->mUserLanguage] ) ? $this->mUserLanguage : $wgContLanguageCode;
$selbox = null;
- foreach($wgLanguageNames as $code => $name) {
+ foreach($languages as $code => $name) {
global $IP;
/* only add languages that have a file */
$langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
foreach($variants as $v) {
$v = str_replace( '_', '-', strtolower($v));
- if($name = $wgLanguageNames[$v]) {
+ if($name = $languages[$v]) {
$variantArray[$v] = $name;
}
}
$this->addRow( wfMsg( 'retypenew' ), "<input type='password' name='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />" ) .
"</table>\n" .
$this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
-
- # Enotif
- $this->mUserEmail = htmlspecialchars( $this->mUserEmail );
- $this->mRealName = htmlspecialchars( $this->mRealName );
- $this->mNick = htmlspecialchars( $this->mNick );
- if ($wgEmailAuthentication && ($this->mUserEmail != '') ) {
- if ($wgUser->getEmailAuthenticationtimestamp() != 0) {
- $emailauthenticated = wfMsg('emailauthenticated',
- $wgLang->timeanddate($wgUser->getEmailAuthenticationtimestamp(), true ) ).'<br />';
- $disabled = '';
- } else {
- $emailauthenticated = wfMsg('emailnotauthenticated').'<br />';
- $disabled = ' '.wfMsg('disableduntilauthent');
- }
- } else {
- $emailauthenticated = '';
- }
-
- if ($this->mUserEmail == '') {
- $disabled = ' '.wfMsg('disablednoemail');
- }
-
- $ps = $this->namespacesCheckboxes();
-
- $enotifwatchlistpages = $wgEmailNotificationForWatchlistPages ? $this->getToggle( 'enotifwatchlistpages', $disabled) : '';
- $enotifusertalkpages = $wgEmailNotificationForUserTalkPages ? $this->getToggle( 'enotifusertalkpages', $disabled) : '';
- $enotifminoredits = $wgEmailNotificationForMinorEdits ? $this->getToggle( 'enotifminoredits', $disabled) : '';
- $enotifrevealaddr = $wgEmailNotificationRevealPageEditorAddress ? $this->getToggle( 'enotifrevealaddr', $disabled) : '';
- $prefs_help_email_enotif = ( $wgEmailNotificationForWatchlistPages || $wgEmailNotificationForUserTalkPages) ? ' ' . wfMsg('prefs-help-email-enotif') : '';
- if( $wgEnableEmail ) {
- $wgOut->addHTML( "<fieldset><legend>" . wfMsg('email') . "</legend>");
- $wgOut->addHTML(
- $emailauthenticated.
- $enotifrevealaddr.
- $enotifwatchlistpages.
- $enotifusertalkpages.
- $enotifminoredits );
- if( $wgEnableUserEmail ) {
- $emfc = $this->mEmailFlag ? 'checked="checked"' : '';
- $wgOut->addHTML(
- "<div class='toggle'><input type='checkbox' $emfc value='1' name='wpEmailFlag' id='wpEmailFlag' />".
- " <span class='toggletext'><label for='wpEmailFlag'>" .
- htmlspecialchars( wfMsg( 'emailflag' ) ) . $disabled .
- "</label></span></div>\n" );
- $prefs_help_realname = $wgAllowRealName ? wfMsg('prefs-help-realname') : '';
- }
+ # <FIXME>
+ # Enotif
+ if ($wgEnableEmail) {
+ $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
+ $wgOut->addHTML(
+ $emailauthenticated.
+ $enotifrevealaddr.
+ $enotifwatchlistpages.
+ $enotifusertalkpages.
+ $enotifminoredits );
+ if ($wgEnableUserEmail) {
+ $emf = wfMsg( 'emailflag' );
+ $wgOut->addHTML(
+ "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf</label></div>" );
+ }
+
$wgOut->addHTML( '</fieldset>' );
- }
-
+ }
+ # </FIXME>
+
if ($wgAllowRealName || $wgEnableEmail) {
$wgOut->addHTML("<div class='prefsectiontip'>");
$rn = $wgAllowRealName ? wfMsg('prefs-help-realname') : '';
$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
# 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;
# 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
#
<input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
</td></tr></table>
- <div class='prefsectiontip'>*" . wfMsg( 'timezonetext' ) . "</div>
+ <div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div>
</fieldset>\n\n" );
# Editing
#
- $wgOut->addHTML( "<fieldset><legend>" . wfMsg( 'textboxsize' ) . " </legend>\n
- <div>
- <label>" . wfMsg( 'rows' ) . ": <input type='text' name='wpRows' value=\"{$this->mRows}\" size='6' /></label>
- <label>" . wfMsg( 'columns' ) . ": <input type='text' name='wpCols' value=\"{$this->mCols}\" size='6' /></label>
- </div>" .
- $this->getToggles( array(
- "editsection",
- "editsectiononrightclick",
- "editondblclick",
- "editwidth",
- "showtoolbar",
- "previewonfirst",
- "previewontop",
- "watchdefault",
- "minordefault",
- "externaleditor",
- "externaldiff" ) ) .
- "
- </fieldset>");
+ $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
+ <div>
+ <label>' . wfMsg( 'rows' ) . ": <input type='text' name='wpRows' value=\"{$this->mRows}\" size='6' /></label>
+ <label>" . wfMsg( 'columns' ) . ": <input type='text' name='wpCols' value=\"{$this->mCols}\" size='6' /></label>
+ </div>" .
+ $this->getToggles( array(
+ 'editsection',
+ 'editsectiononrightclick',
+ 'editondblclick',
+ 'editwidth',
+ 'showtoolbar',
+ 'previewonfirst',
+ 'previewontop',
+ 'watchdefault',
+ 'minordefault',
+ 'externaleditor',
+ 'externaldiff' )
+ ) . '</fieldset>'
+ );
- $wgOut->addHTML( "
- <fieldset><legend>".htmlspecialchars(wfMsg('prefs-rc'))."</legend>
- <div><label>" . wfMsg( 'recentchangescount' ) . ": <input type='text' name=\"wpRecent\" value=\"$this->mRecent\" size='6' /></label></div>" .
- $this->getToggles( array(
- "hideminor",
- ($wgRCShowWatchingUsers) ? 'shownumberswatching' : false,
- "usenewrc",
- "rcusemodstyle",
- array( 'showupdated', wfMsg('updatedmarker') )
- ) ) .
- "<div><label>". wfMsg ( 'stubthreshold' ) . ": <input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' /></label></div>
- </fieldset>");
+ $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>
+ <table>' .
+ $this->addRow(
+ wfMsg ( 'stubthreshold' ),
+ "<input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' />"
+ ) .
+ $this->addRow(
+ wfMsg( 'recentchangescount' ),
+ "<input type='text' name='wpRecent' value=\"$this->mRecent\" size='6' />"
+ ) .
+ '</table>' .
+ $this->getToggles( array(
+ 'hideminor',
+ $wgRCShowWatchingUsers ? 'shownumberswatching' : false,
+ 'usenewrc' )
+ ) . '</fieldset>'
+ );
- $wgOut->addHTML( "<fieldset><legend>" . wfMsg( 'searchresultshead' ) . "</legend><table>" .
- $this->addRow( wfMsg( 'resultsperpage' ), "<input type='text' name='wpSearch' value=\"$this->mSearch\" size='4' />" ) .
- $this->addRow( wfMsg( 'contextlines' ), "<input type='text' name='wpSearchLines' value=\"$this->mSearchLines\" size='4' />") .
- $this->addRow( wfMsg( 'contextchars' ), "<input type='text' name='wpSearchChars' value=\"$this->mSearchChars\" size='4' />") .
+ $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
+ $this->addRow( wfMsg( 'resultsperpage' ), "<input type='text' name='wpSearch' value=\"$this->mSearch\" size='4' />" ) .
+ $this->addRow( wfMsg( 'contextlines' ), "<input type='text' name='wpSearchLines' value=\"$this->mSearchLines\" size='4' />" ) .
+ $this->addRow( wfMsg( 'contextchars' ), "<input type='text' name='wpSearchChars' value=\"$this->mSearchChars\" size='4' />" ) .
"</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
# Misc
#
$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 ) );