From: Ævar Arnfjörð Bjarmason Date: Mon, 25 Apr 2005 23:04:44 +0000 (+0000) Subject: * Completely re-arranged the preferences. X-Git-Tag: 1.5.0alpha1~128 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=9abb0efdac248b8774bef8eef9562d915b097abc;p=lhc%2Fweb%2Fwiklou.git * Completely re-arranged the preferences. --- diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index cf52974a2d..471e6fef85 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -52,7 +52,7 @@ class PreferencesForm { $this->mMath = $request->getVal( 'wpMath' ); $this->mDate = $request->getVal( 'wpDate' ); $this->mUserEmail = $request->getVal( 'wpUserEmail' ); - $this->mRealName = ($wgAllowRealName) ? $request->getVal( 'wpRealName' ) : ''; + $this->mRealName = $wgAllowRealName ? $request->getVal( 'wpRealName' ) : ''; $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0; $this->mNick = $request->getVal( 'wpNick' ); $this->mUserLanguage = $request->getVal( 'wpUserLanguage' ); @@ -64,7 +64,6 @@ class PreferencesForm { $this->mSearchChars = $request->getVal( 'wpSearchChars' ); $this->mImageSize = $request->getVal( 'wpImageSize' ); $this->mThumbSize = $request->getInt( 'wpThumbSize' ); - $this->mAction = $request->getVal( 'action' ); $this->mReset = $request->getCheck( 'wpReset' ); $this->mPosted = $request->wasPosted(); @@ -123,7 +122,7 @@ class PreferencesForm { } } - /** + /** * @access private */ function validateInt( &$val, $min=0, $max=0x7fffffff ) { @@ -237,31 +236,32 @@ class PreferencesForm { $wgUser->setCookies(); $wgUser->saveSettings(); - $error = wfMsg( 'savedprefs' ); if( $wgEnableEmail ) { - $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( 'passwordsentforemailauthentication', $wgUser->getName() ); - } + $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 ) ); } - } else { - $error = wfMsg( 'invalidemailaddress' ); + # if user returns, that new email address gets authenticated in checkpassword() } } else { - $wgUser->setEmail( $this->mUserEmail ); + $wgUser->setEmail( strtolower($this->mUserEmail) ); $wgUser->setCookies(); $wgUser->saveSettings(); } @@ -269,7 +269,7 @@ class PreferencesForm { $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) ); $po = ParserOptions::newFromUser( $wgUser ); - $this->mainPrefsForm( $error ); + $this->mainPrefsForm( wfMsg( 'savedprefs' ) ); } /** @@ -280,7 +280,7 @@ class PreferencesForm { $this->mOldpass = $this->mNewpass = $this->mRetypePass = ''; $this->mUserEmail = $wgUser->getEmail(); - $this->mUserEmailAuthenticated = $wgUser->getEmailAuthenticationTimestamp(); + $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp(); $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : ''; $this->mUserLanguage = $wgUser->getOption( 'language' ); if( empty( $this->mUserLanguage ) ) { @@ -289,8 +289,7 @@ class PreferencesForm { $this->mUserLanguage = $wgContLanguageCode; } $this->mUserVariant = $wgUser->getOption( 'variant'); - if ( 1 == $wgUser->getOption( 'disablemail' ) ) { $this->mEmailFlag = 1; } - else { $this->mEmailFlag = 0; } + $this->mEmailFlag = $wgUser->getOption( 'disablemail' ) == 1 ? 1 : 0; $this->mNick = $wgUser->getOption( 'nickname' ); $this->mQuickbar = $wgUser->getOption( 'quickbar' ); @@ -362,14 +361,14 @@ class PreferencesForm { $this->mUsedToggles[$tname] = true; $ttext = $wgLang->getUserToggle( $tname ); - if ( 1 == $wgUser->getOption( $tname ) ) { - $checked = ' checked="checked"'; - } else { - $checked = ''; - } - $trailer =($trailer) ? $trailer : ''; - return "
$trailer
\n"; + $checked = $wgUser->getOption( $tname ) == 1 ? ' checked="checked"' : ''; + $trailer = $trailer ? $trailer : ''; + return "" . + "$trailer"; + } + + function addRow($td1, $td2) { + return "$td1$td2"; } /** @@ -406,219 +405,181 @@ class PreferencesForm { $titleObj = Title::makeTitle( NS_SPECIAL, 'Preferences' ); $action = $titleObj->escapeLocalURL(); - $qb = wfMsg( 'qbsettings' ); - $cp = wfMsg( 'changepassword' ); - $sk = wfMsg( 'skin' ); - $math = wfMsg( 'math' ); - $files = wfMsg( 'files' ); - $dateFormat = wfMsg('dateformat'); - $opw = wfMsg( 'oldpassword' ); - $npw = wfMsg( 'newpassword' ); - $rpw = wfMsg( 'retypenew' ); - $svp = wfMsg( 'saveprefs' ); - $rsp = wfMsg( 'resetprefs' ); - $tbs = wfMsg( 'textboxsize' ); - $tbr = wfMsg( 'rows' ); - $tbc = wfMsg( 'columns' ); - $ltz = wfMsg( 'localtime' ); - $timezone = wfMsg( 'timezonelegend' ); - $tzt = wfMsg( 'timezonetext' ); - $tzo = wfMsg( 'timezoneoffset' ); - $tzGuess = wfMsg( 'guesstimezone' ); - $tzServerTime = wfMsg( 'servertime' ); - $yem = wfMsg( 'youremail' ); - $yrn = ($wgAllowRealName) ? wfMsg( 'yourrealname' ) : ''; - $yl = wfMsg( 'yourlanguage' ); - $yv = wfMsg( 'yourvariant' ); - $emf = wfMsg( 'emailflag' ); - $ynn = wfMsg( 'yournick' ); - $stt = wfMsg ( 'stubthreshold' ) ; - $srh = wfMsg( 'searchresultshead' ); - $rpp = wfMsg( 'resultsperpage' ); - $scl = wfMsg( 'contextlines' ); - $scc = wfMsg( 'contextchars' ); - $rcc = wfMsg( 'recentchangescount' ); - $dsn = wfMsg( 'defaultns' ); - - $wgOut->addHTML( "
" ); + $wgOut->addHTML( "" ); - # First section: identity - # Email, etc. + # User data # - $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 ) ).'
'; - $disabled = ''; - } else { - $skin = $wgUser->getSkin(); - $emailauthenticated = wfMsg('emailnotauthenticated').'
' . - $skin->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Confirmemail' ), - wfMsg( 'emailconfirmlink' ) ); - $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') : ''; - $prefs_help_realname = ''; - - $wgOut->addHTML( "
- ".wfMsg('prefs-personal').""); + $wgOut->addHTML( "
\n" . wfMsg('prefs-personal') . "\n\n"); - if ($wgAllowRealName) { - $wgOut->addHTML("
"); - $prefs_help_realname = wfMsg('prefs-help-realname').'
'; - } - - if( $wgEnableEmail ) { - $wgOut->addHTML(" -
" ); + if (!empty($this->mRealName)) { $wgOut->addHTML( - $emailauthenticated. - $enotifrevealaddr. - $enotifwatchlistpages. - $enotifusertalkpages. - $enotifminoredits ); - if( $wgEnableUserEmail ) { - $wgOut->addHTML( - "
" ); - } + $this->addRow( + wfMsg('yourrealname'), + "mRealName}\" size='25' />" + ) . + $this->addRow( + wfMsg( 'youremail' ), + "mUserEmail}\" size='25' />" + ) + ); } - $fancysig = $this->getToggle( 'fancysig' ); - $wgOut->addHTML(" -
-
$fancysig
-
\n" ); + $wgOut->addHTML( $this->addRow( wfMsg('yourlanguage'), "" )); /* see if there are multiple language variants to choose from*/ if(!$wgDisableLangConversion) { $variants = $wgContLang->getVariants(); - $size=sizeof($variants); - $variantArray=array(); foreach($variants as $v) { $v = str_replace( '_', '-', strtolower($v)); - if($name=$wgLanguageNames[$v]) { + if($name = $wgLanguageNames[$v]) { $variantArray[$v] = $name; } } - $size=sizeof($variantArray); - - if(sizeof($variantArray) > 1) { - $wgOut->addHtml(" -
'); + + # Password $this->mOldpass = htmlspecialchars( $this->mOldpass ); $this->mNewpass = htmlspecialchars( $this->mNewpass ); $this->mRetypePass = htmlspecialchars( $this->mRetypePass ); - $wgOut->addHTML( "
- $cp -
-
-
- " . $this->getToggle( "rememberpassword" ) . " -
-
".$prefs_help_realname.wfMsg('prefs-help-email').$prefs_help_email_enotif."
\n
\n" ); + $wgOut->addHTML( '
' . wfMsg( 'changepassword' ) . ''); + $wgOut->addHTML( + $this->addRow( wfMsg( 'oldpassword' ), "mOldpass}\" size='20' />" ) . + $this->addRow( wfMsg( 'newpassword' ), "mNewpass}\" size='20' />" ) . + $this->addRow( wfMsg( 'retypenew' ), "mRetypePass}\" size='20' />" ) . + $this->getToggle( "rememberpassword" ) . "
\n
\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 ) ).'
'; + $disabled = ''; + } else { + $emailauthenticated = wfMsg('emailnotauthenticated').'
'; + $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( "
" . wfMsg('email') . ""); + $wgOut->addHTML( + $emailauthenticated. + $enotifrevealaddr. + $enotifwatchlistpages. + $enotifusertalkpages. + $enotifminoredits ); + if( $wgEnableUserEmail ) { + $emfc = $this->mEmailFlag ? 'checked="checked"' : ''; + $wgOut->addHTML( + "". wfMsg( 'emailflag' ) . $disabled ); + $prefs_help_realname = $wgAllowRealName ? wfMsg('prefs-help-realname') : ''; + } + $wgOut->addHTML( '
' ); + } + + if ($wgAllowRealName || $wgEnableEmail) { + $wgOut->addHTML("
"); + $rn = $wgAllowRealName ? wfMsg('prefs-help-realname') : ''; + $em = $wgEnableEmail ? '
' . wfMsg('prefs-help-email') : ''; + $wgOut->addHTML( $rn . $em . '
'); + } - # Quickbar setting + $wgOut->addHTML( '
' ); + + # Quickbar # if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') { - $wgOut->addHtml( "
\n$qb\n" ); + $wgOut->addHtml( "
\n" . wfMsg( 'qbsettings' ) . "\n" ); for ( $i = 0; $i < count( $qbs ); ++$i ) { if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; } else { $checked = ""; } - $wgOut->addHTML( "
\n" ); + $wgOut->addHTML( "
\n" ); } $wgOut->addHtml( "
\n\n" ); } - # Skin setting + # Skin # - $wgOut->addHTML( "
\n$sk\n" ); + $wgOut->addHTML( "
\n\n" . wfMsg('skin') . "\n" ); # Only show members of $wgValidSkinNames rather than # $skinNames (skins is all skin names from Language.php) foreach ($wgValidSkinNames as $skinkey => $skinname ) { - if ( $skinkey == $this->mSkin ) { - $checked = ' checked="checked"'; - } else { - $checked = ''; - } - if ( isset( $skinNames[$skinkey] ) ) { - $sn = $skinNames[$skinkey]; - } else { - $sn = $skinname; - } global $wgDefaultSkin; - if( $skinkey == $wgDefaultSkin ) { + + $checked = $skinkey == $this->mSkin ? ' checked="checked"' : ''; + $sn = isset( $skinNames[$skinkey] ) ? $skinNames[$skinkey] : $skinname; + + if( $skinkey == $wgDefaultSkin ) $sn .= ' (' . wfMsg( 'default' ) . ')'; - } - $wgOut->addHTML( "
\n" ); + $wgOut->addHTML( " {$sn}
\n" ); } $wgOut->addHTML( "
\n\n" ); - # Math setting + # Math # - $wgOut->addHTML( "
\n$math\n" ); - for ( $i = 0; $i < count( $mathopts ); ++$i ) { - if ( $i == $this->mMath ) { $checked = ' checked="checked"'; } - else { $checked = ""; } - $wgOut->addHTML( "
\n" ); + $wgOut->addHTML( "
\n" . wfMsg('math') . '' ); + foreach ( $mathopts as $k => $v ) { + $checked = $k == $this->mMath ? ' checked="checked"' : ''; + $wgOut->addHTML( "
\n" ); } $wgOut->addHTML( "
\n\n" ); # Files # $wgOut->addHTML("
- $files + " . wfMsg( 'files' ) . "
" . $this->getToggle( "editsection" ) . $this->getToggle( "editsectiononrightclick" ) . $this->getToggle( "editondblclick" ) . @@ -683,56 +647,49 @@ class PreferencesForm { $this->getToggle( "externaleditor" ) . $this->getToggle( "externaldiff" ) . " - "); +
"); $shownumberswatching = ($wgRCShowWatchingUsers) ? $this->getToggle('shownumberswatching') : ''; $wgOut->addHTML( " -
".wfMsg('prefs-rc')." -
" . +
".htmlspecialchars(wfMsg('prefs-rc'))." +
" . $this->getToggle( "hideminor" ) . $shownumberswatching . $this->getToggle( "usenewrc" ) . $this->getToggle( "rcusemodstyle" ) . $this->getToggle('showupdated', wfMsg('updatedmarker')) . - "
-
+ "
+
"); -
- $srh -
-
-
- -
- $dsn - $ps -
-
- " ); + $wgOut->addHTML( "
" . wfMsg( 'searchresultshead' ) . "" . + $this->addRow( wfMsg( 'resultsperpage' ), "mSearch\" size='4' />" ) . + $this->addRow( wfMsg( 'contextlines' ), "mSearchLines\" size='4' />") . + $this->addRow( wfMsg( 'contextchars' ), "mSearchChars\" size='4' />") . + "
" . wfMsg( 'defaultns' ) . "$ps
" ); - # Various checkbox options + # Misc # - $wgOut->addHTML("
".wfMsg('prefs-misc').""); + $wgOut->addHTML('
' . wfMsg('prefs-misc') . ''); foreach ( $togs as $tname ) { if( !array_key_exists( $tname, $this->mUsedToggles ) ) { $wgOut->addHTML( $this->getToggle( $tname ) ); } } - $wgOut->addHTML( "\n\n" ); + $wgOut->addHTML( '
' ); - $token = htmlspecialchars( $wgUser->editToken() ); + $token = $wgUser->editToken(); $wgOut->addHTML( "
- - +
- + \n" ); } }