static $defaultPreferences = null;
static $saveFilters = array(
'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ),
+ 'cols' => array( 'Preferences', 'filterIntval' ),
+ 'rows' => array( 'Preferences', 'filterIntval' ),
+ 'rclimit' => array( 'Preferences', 'filterIntval' ),
+ 'wllimit' => array( 'Preferences', 'filterIntval' ),
+ 'searchlimit' => array( 'Preferences', 'filterIntval' ),
);
+ /**
+ * @throws MWException
+ * @param $user User
+ * @return array|null
+ */
static function getPreferences( $user ) {
- if ( self::$defaultPreferences )
+ if ( self::$defaultPreferences ) {
return self::$defaultPreferences;
-
- global $wgRCMaxAge;
+ }
$defaultPreferences = array();
self::profilePreferences( $user, $defaultPreferences );
self::skinPreferences( $user, $defaultPreferences );
self::filesPreferences( $user, $defaultPreferences );
- self::mathPreferences( $user, $defaultPreferences );
self::datetimePreferences( $user, $defaultPreferences );
self::renderingPreferences( $user, $defaultPreferences );
self::editingPreferences( $user, $defaultPreferences );
}
## Prod in defaults from the user
- global $wgDefaultUserOptions;
foreach ( $defaultPreferences as $name => &$info ) {
$prefFromUser = self::getOptionFromUser( $name, $info, $user );
- $field = HTMLForm::loadInputFromParameters( $info ); // For validation
+ $field = HTMLForm::loadInputFromParameters( $name, $info ); // For validation
$defaultOptions = User::getDefaultOptions();
$globalDefault = isset( $defaultOptions[$name] )
? $defaultOptions[$name]
return $defaultPreferences;
}
- // Pull option from a user account. Handles stuff like array-type preferences.
+ /**
+ * Pull option from a user account. Handles stuff like array-type preferences.
+ *
+ * @param $name
+ * @param $info
+ * @param $user User
+ * @return array|String
+ */
static function getOptionFromUser( $name, $info, $user ) {
$val = $user->getOption( $name );
$prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name;
$val = array();
- foreach ( $options as $label => $value ) {
+ foreach ( $options as $value ) {
if ( $user->getOption( "$prefix$value" ) ) {
$val[] = $value;
}
return $val;
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences
+ * @return void
+ */
static function profilePreferences( $user, &$defaultPreferences ) {
- global $wgLang, $wgUser;
+ global $wgLang;
## User info #####################################
// Information panel
$defaultPreferences['username'] = array(
);
if ( $wgAuth->allowPasswordChange() ) {
- $link = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Resetpass' ),
+ $link = Linker::link( SpecialPage::getTitleFor( 'ChangePassword' ),
wfMsgHtml( 'prefs-resetpass' ), array(),
array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' ) ) );
}
// Language
- global $wgContLanguageCode;
- $languages = array_reverse( Language::getLanguageNames( false ) );
- if ( !array_key_exists( $wgContLanguageCode, $languages ) ) {
- $languages[$wgContLanguageCode] = $wgContLanguageCode;
+ global $wgLanguageCode;
+ $languages = Language::getLanguageNames( false );
+ if ( !array_key_exists( $wgLanguageCode, $languages ) ) {
+ $languages[$wgLanguageCode] = $wgLanguageCode;
}
ksort( $languages );
if ( !$wgDisableLangConversion ) {
$variants = $wgContLang->getVariants();
- $languages = Language::getLanguageNames( true );
foreach ( $variants as $v ) {
$v = str_replace( '_', '-', strtolower( $v ) );
- if ( array_key_exists( $v, $languages ) ) {
- // If it doesn't have a name, we'll pretend it doesn't exist
- $variantArray[$v] = $languages[$v];
- }
+ $variantArray[$v] = $wgContLang->getVariantname( $v, false );
}
$options = array();
'type' => 'select',
'options' => $options,
'section' => 'personal/i18n',
+ 'help-message' => 'prefs-help-variant',
);
}
}
global $wgMaxSigChars, $wgOut, $wgParser;
// show a preview of the old signature first
- $oldsigWikiText = $wgParser->preSaveTransform( "~~~", new Title , $user, new ParserOptions );
- $oldsigHTML = $wgOut->parseInline( $oldsigWikiText );
+ $oldsigWikiText = $wgParser->preSaveTransform( "~~~", new Title, $user, new ParserOptions );
+ $oldsigHTML = $wgOut->parseInline( $oldsigWikiText, true, true );
$defaultPreferences['oldsig'] = array(
'type' => 'info',
'raw' => true,
global $wgEnableEmail;
if ( $wgEnableEmail ) {
global $wgEmailConfirmToEdit;
+ global $wgEnableUserEmail;
+
+ $helpMessages[] = $wgEmailConfirmToEdit
+ ? 'prefs-help-email-required'
+ : 'prefs-help-email' ;
+
+ if( $wgEnableUserEmail ) {
+ // additional messages when users can send email to each other
+ $helpMessages[] = 'prefs-help-email-others';
+ }
+
+ $link = Linker::link(
+ SpecialPage::getTitleFor( 'ChangeEmail' ),
+ wfMsgHtml( $user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' ),
+ array(),
+ array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' ) ) );
$defaultPreferences['emailaddress'] = array(
- 'type' => $wgAuth->allowPropChange( 'emailaddress' ) ? 'email' : 'info',
- 'default' => $user->getEmail(),
- 'section' => 'personal/email',
+ 'type' => 'info',
+ 'raw' => true,
+ 'default' => $user->getEmail()
+ ? htmlspecialchars( $user->getEmail() ) . " ($link)"
+ : $link,
'label-message' => 'youremail',
- 'help-message' => $wgEmailConfirmToEdit
- ? 'prefs-help-email-required'
- : 'prefs-help-email',
- 'validation-callback' => array( 'Preferences', 'validateEmail' ),
+ 'section' => 'personal/email',
);
- global $wgEnableUserEmail, $wgEmailAuthentication;
+ global $wgEmailAuthentication;
$disableEmailPrefs = false;
$disableEmailPrefs = false;
} else {
$disableEmailPrefs = true;
- $skin = $wgUser->getSkin();
$emailauthenticated = wfMsgExt( 'emailnotauthenticated', 'parseinline' ) . '<br />' .
- $skin->link(
+ Linker::linkKnown(
SpecialPage::getTitleFor( 'Confirmemail' ),
- wfMsg( 'emailconfirmlink' ),
- array(),
- array(),
- array( 'known', 'noclasses' )
+ wfMsg( 'emailconfirmlink' )
) . '<br />';
}
} else {
}
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences
+ * @return void
+ */
static function skinPreferences( $user, &$defaultPreferences ) {
## Skin #####################################
global $wgLang, $wgAllowUserCss, $wgAllowUserJs;
# This code is basically copied from generateSkinOptions(). It'd
# be nice to somehow merge this back in there to avoid redundancy.
if ( $wgAllowUserCss || $wgAllowUserJs ) {
- $sk = $user->getSkin();
$linkTools = array();
if ( $wgAllowUserCss ) {
$cssPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/common.css' );
- $linkTools[] = $sk->link( $cssPage, wfMsgHtml( 'prefs-custom-css' ) );
+ $linkTools[] = Linker::link( $cssPage, wfMsgHtml( 'prefs-custom-css' ) );
}
if ( $wgAllowUserJs ) {
$jsPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/common.js' );
- $linkTools[] = $sk->link( $jsPage, wfMsgHtml( 'prefs-custom-js' ) );
+ $linkTools[] = Linker::link( $jsPage, wfMsgHtml( 'prefs-custom-js' ) );
}
$defaultPreferences['commoncssjs'] = array(
$selectedSkin = $user->getOption( 'skin' );
if ( in_array( $selectedSkin, array( 'cologneblue', 'standard' ) ) ) {
- global $wgLang;
-
$settings = array_flip( $wgLang->getQuickbarSettings() );
$defaultPreferences['quickbar'] = array(
}
}
- static function mathPreferences( $user, &$defaultPreferences ) {
- ## Math #####################################
- global $wgUseTeX, $wgLang;
- if ( $wgUseTeX ) {
- $defaultPreferences['math'] = array(
- 'type' => 'radio',
- 'options' => array_flip( array_map( 'wfMsgHtml', $wgLang->getMathNames() ) ),
- 'label' => ' ',
- 'section' => 'rendering/math',
- );
- }
- }
-
+ /**
+ * @param $user User
+ * @param $defaultPreferences Array
+ */
static function filesPreferences( $user, &$defaultPreferences ) {
## Files #####################################
$defaultPreferences['imagesize'] = array(
);
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences
+ * @return void
+ */
static function datetimePreferences( $user, &$defaultPreferences ) {
global $wgLang;
}
// Info
+ $now = wfTimestampNow();
$nowlocal = Xml::element( 'span', array( 'id' => 'wpLocalTime' ),
- $wgLang->time( $now = wfTimestampNow(), true ) );
+ $wgLang->time( $now, true ) );
$nowserver = $wgLang->time( $now, false ) .
- Xml::hidden( 'wpServerTime', substr( $now, 8, 2 ) * 60 + substr( $now, 10, 2 ) );
+ Html::hidden( 'wpServerTime', (int)substr( $now, 8, 2 ) * 60 + (int)substr( $now, 10, 2 ) );
$defaultPreferences['nowserver'] = array(
'type' => 'info',
);
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences Array
+ */
static function renderingPreferences( $user, &$defaultPreferences ) {
## Page Rendering ##############################
global $wgAllowUserCssPrefs;
);
}
- $stubThresholdValues = array( 0, 50, 100, 500, 1000, 2000, 5000, 10000 );
- $stubThresholdOptions = array();
+ $stubThresholdValues = array( 50, 100, 500, 1000, 2000, 5000, 10000 );
+ $stubThresholdOptions = array( wfMsg( 'stub-threshold-disabled' ) => 0 );
foreach ( $stubThresholdValues as $value ) {
$stubThresholdOptions[wfMsg( 'size-bytes', $value )] = $value;
}
);
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences Array
+ */
static function editingPreferences( $user, &$defaultPreferences ) {
global $wgUseExternalEditor, $wgAllowUserCssPrefs;
'section' => 'editing/advancedediting',
'label-message' => 'tog-showtoolbar',
);
- $defaultPreferences['minordefault'] = array(
- 'type' => 'toggle',
- 'section' => 'editing/advancedediting',
- 'label-message' => 'tog-minordefault',
- );
+
+ if ( $user->isAllowed( 'minoredit' ) ) {
+ $defaultPreferences['minordefault'] = array(
+ 'type' => 'toggle',
+ 'section' => 'editing/advancedediting',
+ 'label-message' => 'tog-minordefault',
+ );
+ }
if ( $wgUseExternalEditor ) {
$defaultPreferences['externaleditor'] = array(
'label-message' => 'tog-forceeditsummary',
);
-
+
$defaultPreferences['uselivepreview'] = array(
'type' => 'toggle',
'section' => 'editing/advancedediting',
);
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences Array
+ */
static function rcPreferences( $user, &$defaultPreferences ) {
- global $wgRCMaxAge, $wgUseRCPatrol, $wgLang;
+ global $wgRCMaxAge, $wgLang;
## RecentChanges #####################################
$defaultPreferences['rcdays'] = array(
'type' => 'float',
'label-message' => 'recentchangesdays',
- 'section' => 'rc/display',
+ 'section' => 'rc/displayrc',
'min' => 1,
'max' => ceil( $wgRCMaxAge / ( 3600 * 24 ) ),
'help' => wfMsgExt(
'type' => 'int',
'label-message' => 'recentchangescount',
'help-message' => 'prefs-help-recentchangescount',
- 'section' => 'rc/display',
+ 'section' => 'rc/displayrc',
);
$defaultPreferences['usenewrc'] = array(
'type' => 'toggle',
'section' => 'rc/advancedrc',
);
- if ( $wgUseRCPatrol ) {
+ if ( $user->useRCPatrol() ) {
$defaultPreferences['hidepatrolled'] = array(
'type' => 'toggle',
'section' => 'rc/advancedrc',
}
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences
+ */
static function watchlistPreferences( $user, &$defaultPreferences ) {
global $wgUseRCPatrol, $wgEnableAPI;
'type' => 'float',
'min' => 0,
'max' => 7,
- 'section' => 'watchlist/display',
+ 'section' => 'watchlist/displaywatchlist',
'help' => wfMsgHtml( 'prefs-watchlist-days-max' ),
'label-message' => 'prefs-watchlist-days',
);
'max' => 1000,
'label-message' => 'prefs-watchlist-edits',
'help' => wfMsgHtml( 'prefs-watchlist-edits-max' ),
- 'section' => 'watchlist/display',
+ 'section' => 'watchlist/displaywatchlist',
);
$defaultPreferences['extendwatchlist'] = array(
'type' => 'toggle',
}
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences Array
+ */
static function searchPreferences( $user, &$defaultPreferences ) {
global $wgContLang;
$defaultPreferences['searchlimit'] = array(
'type' => 'int',
'label-message' => 'resultsperpage',
- 'section' => 'searchoptions/display',
- 'min' => 0,
- );
- $defaultPreferences['contextlines'] = array(
- 'type' => 'int',
- 'label-message' => 'contextlines',
- 'section' => 'searchoptions/display',
- 'min' => 0,
- );
- $defaultPreferences['contextchars'] = array(
- 'type' => 'int',
- 'label-message' => 'contextchars',
- 'section' => 'searchoptions/display',
+ 'section' => 'searchoptions/displaysearchoptions',
'min' => 0,
);
$defaultPreferences['disablesuggest'] = array(
'type' => 'toggle',
'label-message' => 'mwsuggest-disable',
- 'section' => 'searchoptions/display',
+ 'section' => 'searchoptions/displaysearchoptions',
);
}
-
+
global $wgVectorUseSimpleSearch;
if ( $wgVectorUseSimpleSearch ) {
$defaultPreferences['vector-simplesearch'] = array(
'type' => 'toggle',
'label-message' => 'vector-simplesearch-preference',
- 'section' => 'searchoptions/display'
+ 'section' => 'searchoptions/displaysearchoptions'
);
}
'section' => 'searchoptions/advancedsearchoptions',
);
- // Searchable namespaces back-compat with old format
- $searchableNamespaces = SearchEngine::searchableNamespaces();
-
$nsOptions = array();
foreach ( $wgContLang->getNamespaces() as $ns => $name ) {
);
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences Array
+ */
static function miscPreferences( $user, &$defaultPreferences ) {
## Misc #####################################
$defaultPreferences['diffonly'] = array(
}
/**
- * @param object $user The user object
- * @return array Text/links to display as key; $skinkey as value
+ * @param $user User The User object
+ * @return Array: text/links to display as key; $skinkey as value
*/
static function generateSkinOptions( $user ) {
global $wgDefaultSkin, $wgLang, $wgAllowUserCss, $wgAllowUserJs;
# Sort by UI skin name. First though need to update validSkinNames as sometimes
# the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
foreach ( $validSkinNames as $skinkey => &$skinname ) {
- $msgName = "skinname-{$skinkey}";
- $localisedSkinName = wfMsg( $msgName );
- if ( !wfEmptyMsg( $msgName, $localisedSkinName ) ) {
- $skinname = htmlspecialchars( $localisedSkinName );
+ $msg = wfMessage( "skinname-{$skinkey}" );
+ if ( $msg->exists() ) {
+ $skinname = htmlspecialchars( $msg->text() );
}
}
asort( $validSkinNames );
- $sk = $user->getSkin();
foreach ( $validSkinNames as $skinkey => $sn ) {
$linkTools = array();
# Create links to user CSS/JS pages
if ( $wgAllowUserCss ) {
$cssPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/' . $skinkey . '.css' );
- $linkTools[] = $sk->link( $cssPage, wfMsgHtml( 'prefs-custom-css' ) );
+ $linkTools[] = Linker::link( $cssPage, wfMsgHtml( 'prefs-custom-css' ) );
}
if ( $wgAllowUserJs ) {
$jsPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/' . $skinkey . '.js' );
- $linkTools[] = $sk->link( $jsPage, wfMsgHtml( 'prefs-custom-js' ) );
+ $linkTools[] = Linker::link( $jsPage, wfMsgHtml( 'prefs-custom-js' ) );
}
$display = $sn . ' ' . wfMsg( 'parentheses', $wgLang->pipeList( $linkTools ) );
return $ret;
}
+ /**
+ * @return array
+ */
static function getDateOptions() {
global $wgLang;
$dateopts = $wgLang->getDatePreferences();
$wgDefaultUserOptions['date'] = 'default';
}
- $idCnt = 0;
$epoch = wfTimestampNow();
foreach ( $dateopts as $key ) {
if ( $key == 'default' ) {
return $ret;
}
+ /**
+ * @return array
+ */
static function getImageSizes() {
global $wgImageLimits;
return $ret;
}
+ /**
+ * @return array
+ */
static function getThumbSizes() {
global $wgThumbLimits;
return $ret;
}
+ /**
+ * @param $signature
+ * @param $alldata
+ * @return bool|string
+ */
static function validateSignature( $signature, $alldata ) {
global $wgParser, $wgMaxSigChars, $wgLang;
if ( mb_strlen( $signature ) > $wgMaxSigChars ) {
$wgLang->formatNum( $wgMaxSigChars )
)
);
- } elseif ( !empty( $alldata['fancysig'] ) &&
+ } elseif ( isset( $alldata['fancysig'] ) &&
+ $alldata['fancysig'] &&
false === $wgParser->validateSig( $signature ) ) {
return Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) );
} else {
}
}
+ /**
+ * @param $signature string
+ * @param $alldata array
+ * @return string
+ */
static function cleanSignature( $signature, $alldata ) {
global $wgParser;
- if ( $alldata['fancysig'] ) {
+ if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) {
$signature = $wgParser->cleanSig( $signature );
} else {
// When no fancy sig used, make sure ~{3,5} get removed.
return $signature;
}
+ /**
+ * @param $email
+ * @param $alldata
+ * @return bool|String
+ */
static function validateEmail( $email, $alldata ) {
- if ( $email && !User::isValidEmailAddr( $email ) ) {
+ if ( $email && !Sanitizer::validateEmail( $email ) ) {
return wfMsgExt( 'invalidemailaddress', 'parseinline' );
}
return true;
}
- static function getFormObject( $user ) {
+ /**
+ * @param $user User
+ * @param $context IContextSource
+ * @param $formClass string
+ * @return HtmlForm
+ */
+ static function getFormObject( $user, IContextSource $context, $formClass = 'PreferencesForm' ) {
$formDescriptor = Preferences::getPreferences( $user );
- $htmlForm = new PreferencesForm( $formDescriptor, 'prefs' );
+ $htmlForm = new $formClass( $formDescriptor, $context, 'prefs' );
+ $htmlForm->setId( 'mw-prefs-form' );
$htmlForm->setSubmitText( wfMsg( 'saveprefs' ) );
# Used message keys: 'accesskey-preferences-save', 'tooltip-preferences-save'
$htmlForm->setSubmitTooltip( 'preferences-save' );
return $htmlForm;
}
+ /**
+ * @return array
+ */
static function getTimezoneOptions() {
$opt = array();
- global $wgLocalTZoffset;
-
- $opt[wfMsg( 'timezoneuseserverdefault' )] = "System|$wgLocalTZoffset";
+ global $wgLocalTZoffset, $wgLocaltimezone;
+ // Check that $wgLocalTZoffset is the same as $wgLocaltimezone
+ if ( $wgLocalTZoffset == date( 'Z' ) / 60 ) {
+ $server_tz_msg = wfMsg( 'timezoneuseserverdefault', $wgLocaltimezone );
+ } else {
+ $tzstring = sprintf( '%+03d:%02d', floor( $wgLocalTZoffset / 60 ), abs( $wgLocalTZoffset ) % 60 );
+ $server_tz_msg = wfMsg( 'timezoneuseserverdefault', $tzstring );
+ }
+ $opt[$server_tz_msg] = "System|$wgLocalTZoffset";
$opt[wfMsg( 'timezoneuseoffset' )] = 'other';
$opt[wfMsg( 'guesstimezone' )] = 'guess';
return $opt;
}
+ /**
+ * @param $value
+ * @param $alldata
+ * @return int
+ */
+ static function filterIntval( $value, $alldata ){
+ return intval( $value );
+ }
+
+ /**
+ * @param $tz
+ * @param $alldata
+ * @return string
+ */
static function filterTimezoneInput( $tz, $alldata ) {
$data = explode( '|', $tz, 3 );
switch ( $data[0] ) {
return $tz;
default:
$data = explode( ':', $tz, 2 );
- $minDiff = 0;
if ( count( $data ) == 2 ) {
$data[0] = intval( $data[0] );
$data[1] = intval( $data[1] );
}
}
+ /**
+ * @param $formData
+ * @param $entryPoint string
+ * @return bool|Status|string
+ */
static function tryFormSubmit( $formData, $entryPoint = 'internal' ) {
- global $wgUser, $wgEmailAuthentication, $wgEnableEmail;
+ global $wgUser;
$result = true;
'emailaddress',
);
- if ( $wgEnableEmail ) {
- $newaddr = $formData['emailaddress'];
- $oldaddr = $wgUser->getEmail();
- if ( ( $newaddr != '' ) && ( $newaddr != $oldaddr ) ) {
- # the user has supplied a new email address on the login page
- # new behaviour: set this new emailaddr from login-page into user database record
- $wgUser->setEmail( $newaddr );
- # but flag as "dirty" = unauthenticated
- $wgUser->invalidateEmail();
- 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( $oldaddr != '' );
- if ( WikiError::isError( $result ) ) {
- return wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
- } elseif ( $entryPoint == 'ui' ) {
- $result = 'eauth';
- }
- }
- } else {
- $wgUser->setEmail( $newaddr );
- }
- if ( $oldaddr != $newaddr ) {
- wfRunHooks( 'PrefsEmailAudit', array( $wgUser, $oldaddr, $newaddr ) );
- }
- }
-
// Fortunately, the realname field is MUCH simpler
global $wgHiddenPrefs;
if ( !in_array( 'realname', $wgHiddenPrefs ) ) {
unset( $formData[$b] );
}
+ # If users have saved a value for a preference which has subsequently been disabled
+ # via $wgHiddenPrefs, we don't want to destroy that setting in case the preference
+ # is subsequently re-enabled
+ # TODO: maintenance script to actually delete these
+ foreach( $wgHiddenPrefs as $pref ){
+ # If the user has not set a non-default value here, the default will be returned
+ # and subsequently discarded
+ $formData[$pref] = $wgUser->getOption( $pref, null, true );
+ }
+
// Keeps old preferences from interfering due to back-compat
// code, etc.
$wgUser->resetOptions();
return $result;
}
+ /**
+ * @param $formData
+ * @return Status
+ */
public static function tryUISubmit( $formData ) {
$res = self::tryFormSubmit( $formData, 'ui' );
$wgOut->redirect( $url );
}
- return true;
+ return Status::newGood();
+ }
+
+ /*
+ * Try to set a user's email address.
+ * This does *not* try to validate the address.
+ * @param $user User
+ * @param $newaddr string New email address
+ * @return Array (true on success or Status on failure, info string)
+ */
+ public static function trySetUserEmail( User $user, $newaddr ) {
+ global $wgEnableEmail, $wgEmailAuthentication;
+ $info = ''; // none
+
+ if ( $wgEnableEmail ) {
+ $oldaddr = $user->getEmail();
+ if ( ( $newaddr != '' ) && ( $newaddr != $oldaddr ) ) {
+ # The user has supplied a new email address on the login page
+ # new behaviour: set this new emailaddr from login-page into user database record
+ $user->setEmail( $newaddr );
+ # But flag as "dirty" = unauthenticated
+ $user->invalidateEmail();
+ if ( $wgEmailAuthentication ) {
+ # Mail a temporary password to the dirty address.
+ # User can come back through the confirmation URL to re-enable email.
+ $type = $oldaddr != '' ? 'changed' : 'set';
+ $result = $user->sendConfirmationMail( $type );
+ if ( !$result->isGood() ) {
+ return array( $result, 'mailerror' );
+ }
+ $info = 'eauth';
+ }
+ } else {
+ $user->setEmail( $newaddr );
+ }
+ if ( $oldaddr != $newaddr ) {
+ wfRunHooks( 'PrefsEmailAudit', array( $user, $oldaddr, $newaddr ) );
+ }
+ }
+
+ return array( true, $info );
}
+ /**
+ * @param $user User
+ * @return array
+ */
public static function loadOldSearchNs( $user ) {
$searchableNamespaces = SearchEngine::searchableNamespaces();
// Back compat with old format
/** Some tweaks to allow js prefs to work */
class PreferencesForm extends HTMLForm {
+
+ /**
+ * @param $html string
+ * @return String
+ */
function wrapForm( $html ) {
$html = Xml::tags( 'div', array( 'id' => 'preferences' ), $html );
return parent::wrapForm( $html );
}
+ /**
+ * @return String
+ */
function getButtons() {
$html = parent::getButtons();
- global $wgUser;
-
- $sk = $wgUser->getSkin();
$t = SpecialPage::getTitleFor( 'Preferences', 'reset' );
- $html .= "\n" . $sk->link( $t, wfMsgHtml( 'restoreprefs' ) );
+ $html .= "\n" . Linker::link( $t, wfMsgHtml( 'restoreprefs' ) );
$html = Xml::tags( 'div', array( 'class' => 'mw-prefs-buttons' ), $html );
return $html;
}
+ /**
+ * @param $data array
+ * @return array
+ */
function filterDataForSubmit( $data ) {
// Support for separating MultiSelect preferences into multiple preferences
// Due to lack of array support.
return $data;
}
+ /**
+ * Get the whole body of the form.
+ */
+ function getBody() {
+ return $this->displaySection( $this->mFieldTree, '', 'mw-prefsection-' );
+ }
}